Skip to content

Open-source SEO, GEO, and marketing skills for AI agents.

feat: project-scoped MCP connections + markdown chat

Yuting Zhongc300b4dcab09
diff --git a/package.json b/package.json
index f915c805..a2635b21 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,7 @@
"public/"
],
"scripts": {
- "dev": "next dev --turbopack",
+ "dev": "next dev --turbopack -p 3326",
"build": "next build && node scripts/copy-standalone-assets.mjs",
"start": "next start",
"cli": "tsx bin/cli.ts",
@@ -40,6 +40,8 @@
"radix-ui": "^1.4.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
+ "react-markdown": "^10.1.0",
+ "remark-gfm": "^4.0.1",
"sonner": "^2.0.7",
"tailwind-merge": "^2.5.0",
"ws": "^8.20.1",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9f2b4e7c..959f2e77 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -65,6 +65,12 @@ importers:
react-dom:
specifier: ^19.0.0
version: 19.2.6([email protected])
+ react-markdown:
+ specifier: ^10.1.0
+ version: 10.1.0(@types/[email protected])([email protected])
+ remark-gfm:
+ specifier: ^4.0.1
+ version: 4.0.1
sonner:
specifier: ^2.0.7
@@ -1517,18 +1523,33 @@ packages:
resolution: {integrity: sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==}
+
resolution: {integrity: sha512-xFdR6tkm0MWvBfO8xXCSsinYxHcqkQUlcHeSpMC2ukzOb6lwQAfDmW+Qt0AvlGd8HpsS28qKsB+oPeJn9I39jg==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==}
+
resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==}
+
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==}
+
+ '@types/[email protected]':
+ resolution: {integrity: sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==}
+
resolution: {integrity: sha512-dyh/xO2Fh5bYrfWaaqGrRQQGkNdmYw6AmaAUvYeUMNTWQtvb796ikLdmTchRmOlOiIJ1TDXfWgVx1QkUlQ6Hew==}
@@ -1540,6 +1561,12 @@ packages:
resolution: {integrity: sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==}
+
+ '@types/[email protected]':
+ resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==}
+
resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==}
@@ -1602,6 +1629,9 @@ packages:
resolution: {integrity: sha512-f1UQF7ggd42YiwI5wGrRaPsa+P0CINBlrkLPmGfpq/u/I/oVtecoEIfFR9ag/oa1sLOsRNZ6xehf6qMZhQGBDg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ '@ungap/[email protected]':
+ resolution: {integrity: sha512-mUFwbeTqrVgDQxFveS+df2yfap6iuP20NAKAsBt5jDEoOTDew+zwLAOilHCeQJOVSvmgCX4ogqIrA0mnyr08yQ==}
+
resolution: {integrity: sha512-ppLRUgHVaGRWUx0R0Ut06Mjo9gBaBkg3v/8AxusGLhsIotbBLuRk51rAzqLC8gq6NyyAojEXglNjzf6R948DNw==}
cpu: [arm]
@@ -1794,6 +1824,9 @@ packages:
resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==}
+
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
@@ -1861,6 +1894,9 @@ packages:
resolution: {integrity: sha512-iwSsYWaCOoh26cV8NwNRViHlrfUvYsHDfRVcbtmw0Kg6PJIZZXwMkj1442FYLBGkeUf1juAsU3DTfxW579mrPA==}
+ resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==}
+
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
engines: {node: '>=10'}
@@ -1869,6 +1905,18 @@ packages:
resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==}
engines: {node: ^12.17.0 || ^14.13 || >=16.0.0}
+ resolution: {integrity: sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==}
+
+ resolution: {integrity: sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==}
+
+ resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==}
+
+ resolution: {integrity: sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==}
+
resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==}
@@ -1889,6 +1937,9 @@ packages:
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
+ resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==}
+
resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==}
engines: {node: '>=18'}
@@ -1942,6 +1993,9 @@ packages:
supports-color:
optional: true
+ resolution: {integrity: sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==}
+
resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==}
engines: {node: '>=10'}
@@ -1984,6 +2038,9 @@ packages:
resolution: {integrity: sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==}
+ resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==}
+
resolution: {integrity: sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==}
@@ -2053,6 +2110,10 @@ packages:
resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==}
engines: {node: '>=10'}
+ resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==}
+ engines: {node: '>=12'}
+
resolution: {integrity: sha512-z2ELYSkyrrJ6cuunTU8vhsT/RpouPkjaSah06nVW6Rg2Hpg0Vs8s497/e5s8G8qtdp4ccsiovz5P1rv+5VSW2Q==}
peerDependencies:
@@ -2169,6 +2230,9 @@ packages:
resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==}
engines: {node: '>=4.0'}
+ resolution: {integrity: sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==}
+
resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}
engines: {node: '>=0.10.0'}
@@ -2177,6 +2241,9 @@ packages:
resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==}
engines: {node: '>=6'}
+ resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==}
+
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
@@ -2330,12 +2397,21 @@ packages:
resolution: {integrity: sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-zl6s8LwNyo1P9uw+XJGvZtdFF1GdAkOg8ujOw+4Pyb76874fLps4ueHXDhXWdk6YHQ6OgUtinliG7RsYvCbbBg==}
+
+ resolution: {integrity: sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==}
+
resolution: {integrity: sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw==}
resolution: {integrity: sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA==}
+ resolution: {integrity: sha512-ol6UPyBWqsrO6EJySPz2O7ZSr856WDrEzM5zMqp+FJJLGMW35cLYmmZnl0vztAZxRUoNZJFTCohfjuIJ8I4QBQ==}
+
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
@@ -2361,10 +2437,19 @@ packages:
resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==}
+ resolution: {integrity: sha512-Nb2ctOyNR8DqQoR0OwRG95uNWIC0C1lCgf5Naz5H6Ji72KZ8OcFZLz2P5sNgwlyoJ8Yif11oMuYs5pBQa86csA==}
+
resolution: {integrity: sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==}
+
+ resolution: {integrity: sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==}
+
resolution: {integrity: sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==}
engines: {node: '>= 0.4'}
@@ -2400,6 +2485,9 @@ packages:
resolution: {integrity: sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==}
+
resolution: {integrity: sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
@@ -2421,6 +2509,9 @@ packages:
resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==}
+
resolution: {integrity: sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==}
engines: {node: '>=14.16'}
@@ -2442,6 +2533,10 @@ packages:
resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==}
engines: {node: '>=0.12.0'}
+ resolution: {integrity: sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==}
+ engines: {node: '>=12'}
+
resolution: {integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==}
engines: {node: '>= 0.4'}
@@ -2636,6 +2731,9 @@ packages:
resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==}
+ resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==}
+
resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==}
hasBin: true
@@ -2655,14 +2753,146 @@ packages:
resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
+ resolution: {integrity: sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==}
+
resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-Tmd1Vg/m3Xz43afeNxDIhWRtFZgM2VLyaf4vSTYwudTyeuTneoL3qtWMA5jeLyz/O1vDJmmV4QuScFCA2tBPwg==}
+
+ resolution: {integrity: sha512-W4mAWTvSlKvf8L6J+VN9yLSqQ9AOAAvHuoDAmPkz4dHf553m5gVj2ejadHJhoJmcmxEnOv6Pa8XJhpxE93kb8Q==}
+
+ resolution: {integrity: sha512-5HVP2MKaP6L+G6YaxPNjuL0BPrq9orG3TsrZ9YXbA3vDw/ACI4MEsnoDpn6ZNm7GnZgtAcONJyPhOP8tNJQavQ==}
+
+ resolution: {integrity: sha512-sqpDWlsHn7Ac9GNZQMeUzPQSMzR6Wv0WKRNvQRg0KqHh02fpTz69Qc1QSseNX29bhz1ROIyNyxExfawVKTm1GQ==}
+
+ resolution: {integrity: sha512-mKKb915TF+OC5ptj5bJ7WFRPdYtuHv0yTRxK2tJvi+BDqbkiG7h7u/9SI89nRAYcmap2xHQL9D+QG/6wSrTtXg==}
+
+ resolution: {integrity: sha512-78UEvebzz/rJIxLvE7ZtDd/vIQ0RHv+3Mh5DR96p7cS7HsBhYIICDBCu8csTNWNO6tBWfqXPWekRuj2FNOGOZg==}
+
+ resolution: {integrity: sha512-IrtvNvjxC1o06taBAVJznEnkiHxLFTzgonUdy8hzFVeDun0uTjxxrRGVaNFqkU1wJR3RBPEfsxmU6jDWPofrTQ==}
+
+ resolution: {integrity: sha512-0ulfdQOM3ysHhCJ1p06l0b0VKlhU0wuQs3thxZQagjcjPrlFRqY215uZGHHJan9GEAXd9MbfPjFJz+qMkVR6zQ==}
+
+ resolution: {integrity: sha512-J6f+9hUp+ldTZqKRSg7Vw5V6MqjATc+3E4gf3CFNcuZNWD8XdyI6zQ8GqH7f8169MM6P7hMBRDVGnn7oHB9kXQ==}
+
+ resolution: {integrity: sha512-lj/z8v0r6ZtsN/cGNNtemmmfoLAFZnjMbNyLzBafjzikOM+glrjNHPlf6lQDOTccj9n5b0PPihEBbhneMyGs1Q==}
+
+ resolution: {integrity: sha512-EcmOpxsZ96CvlP03NghtH1EsLtr0n9Tm4lPUJUBccV9RwUOneqSycg19n5HGzCf+10LozMRSObtVr3ee1WoHtg==}
+
+ resolution: {integrity: sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==}
+
+ resolution: {integrity: sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==}
+
+ resolution: {integrity: sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==}
+
+ resolution: {integrity: sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==}
+
resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==}
engines: {node: '>= 8'}
+ resolution: {integrity: sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==}
+
+ resolution: {integrity: sha512-oOg7knzhicgQ3t4QCjCWgTmfNhvQbDDnJeVu9v81r7NltNCVmhPy1fJRX27pISafdjL+SVc4d3l48Gb6pbRypw==}
+
+ resolution: {integrity: sha512-/yPhxI1ntnDNsiHtzLKYnE3vf9JZ6cAisqVDauhp4CEHxlb4uoOTxOCJ+9s51bIB8U1N1FJ1RXOKTIlD5B/gqw==}
+
+ resolution: {integrity: sha512-ADVjpOOkjz1hhkZLlBiYA9cR2Anf8F4HqZUO6e5eDcPQd0Txw5fxLzzxnEkSkfnD0wziSGiv7sYhk/ktvbf1uw==}
+
+ resolution: {integrity: sha512-t2OU/dXXioARrC6yWfJ4hqB7rct14e8f7m0cbI5hUmDyyIlwv5vEtooptH8INkbLzOatzKuVbQmAYcbWoyz6Dg==}
+
+ resolution: {integrity: sha512-xHlTOmuCSotIA8TW1mDIM6X2O1SiX5P9IuDtqGonFhEK0qgRI4yeC6vMxEV2dgyr2TiD+2PQ10o+cOhdVAcwfg==}
+
+ resolution: {integrity: sha512-qIBZhqxqI6fjLDYFTBIa4eivDMnP+OZqsNwmQ3xNLE4Cxwc+zfQEfbs6tzAo2Hjq+bh6q5F+Z8/cksrLFYWQQw==}
+
+ resolution: {integrity: sha512-vsKArQsicm7t0z2GugkCKtZehqUm31oeGBV/KVSorWSy8ZlNAv7ytjFhvaryUiCUJYqs+NoE6AFhpQvBTM6Q4w==}
+
+ resolution: {integrity: sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==}
+
+ resolution: {integrity: sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==}
+
+ resolution: {integrity: sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==}
+
+ resolution: {integrity: sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==}
+
+ resolution: {integrity: sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==}
+
+ resolution: {integrity: sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==}
+
+ resolution: {integrity: sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==}
+
+ resolution: {integrity: sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==}
+
+ resolution: {integrity: sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==}
+
+ resolution: {integrity: sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==}
+
+ resolution: {integrity: sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==}
+
+ resolution: {integrity: sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==}
+
+ resolution: {integrity: sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==}
+
+ resolution: {integrity: sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==}
+
+ resolution: {integrity: sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==}
+
+ resolution: {integrity: sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==}
+
+ resolution: {integrity: sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==}
+
+ resolution: {integrity: sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==}
+
+ resolution: {integrity: sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==}
+
+ resolution: {integrity: sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==}
+
resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==}
engines: {node: '>=8.6'}
@@ -2803,6 +3033,9 @@ packages:
resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}
engines: {node: '>=6'}
+ resolution: {integrity: sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw==}
+
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
engines: {node: '>=8'}
@@ -2850,6 +3083,9 @@ packages:
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
+ resolution: {integrity: sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ==}
+
resolution: {integrity: sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==}
@@ -2885,6 +3121,12 @@ packages:
resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}
+ resolution: {integrity: sha512-qKxVopLT/TyA6BX3Ue5NwabOsAzm0Q7kAPwq6L+wWDwisYs7R8vZ0nRXqq6rkueboxpkjvLGU9fWifiX/ZZFxQ==}
+ peerDependencies:
+ '@types/react': '>=18'
+ react: '>=18'
+
resolution: {integrity: sha512-9r+yi9+mgU33AKcj6IbT9oRCO78WriSj6t/cF8DWBZJ9aOGPOTEDvdUDz1FwKim7QXWwmHqtdHnRJfhAxEG46Q==}
engines: {node: '>=10'}
@@ -2931,6 +3173,18 @@ packages:
resolution: {integrity: sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-1quofZ2RQ9EWdeN34S79+KExV1764+wCUGop5CPL1WGdD0ocPpu91lzPGbwWMECpEpd42kJGQwzRfyov9j4yNg==}
+
+ resolution: {integrity: sha512-FCxlKLNGknS5ba/1lmpYijMUzX2esxW5xQqjWxw2eHFfS2MSdaHVINFmhjo+qN1WhZhNimq0dZATN9pH0IDrpA==}
+
+ resolution: {integrity: sha512-Dh7l57ianaEoIpzbp0PC9UKAdCSVklD8E5Rpw7ETfbTl3FqcOOgq5q2LVDhgGCkaBv7p24JXikPdvhhmHvKMsw==}
+
+ resolution: {integrity: sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==}
+
resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==}
engines: {node: '>=4'}
@@ -3040,6 +3294,9 @@ packages:
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==}
+
resolution: {integrity: sha512-+L3ccpzibovGXFK+Ap/f8LOS0ahMrHTf3xu7mMLSpEGU0EO9ucaysSylKo9eRDFNhWve/y275iPmIZ4z39a9iA==}
@@ -3073,6 +3330,9 @@ packages:
resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
+ resolution: {integrity: sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==}
+
resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==}
engines: {node: '>=4'}
@@ -3085,6 +3345,12 @@ packages:
resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-RjQetxJrrUJLQPHbLku6U/ocGtzyjbJMP9lCNK7Ag0CNh690nSH8woqWH9u16nMjYBAok+i7JO1NP2pOy8IsPQ==}
+
+ resolution: {integrity: sha512-LIN7rULI0jBscWQYaSswptyderlarFkjQ+t79nzty8tcIAceVomEVlLzH5VP4Cmsv6MtKhs7qaAiwlcp+Mgaxw==}
+
resolution: {integrity: sha512-qSVyDTeMotdvQYoHWLNGwRFJHC+i+ZvdBRYosOFgC+Wg1vx4frN2/RG/NA7SYqqvKNLf39P2LSRA2pu6n0XYZA==}
engines: {node: '>= 12.0.0'}
@@ -3140,6 +3406,12 @@ packages:
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
+ resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==}
+
+ resolution: {integrity: sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==}
+
resolution: {integrity: sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==}
engines: {node: '>=18.12'}
@@ -3199,6 +3471,24 @@ packages:
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
+ resolution: {integrity: sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==}
+
+ resolution: {integrity: sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==}
+
+ resolution: {integrity: sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==}
+
+ resolution: {integrity: sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==}
+
+ resolution: {integrity: sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ==}
+
+ resolution: {integrity: sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==}
+
resolution: {integrity: sha512-bSjt9pjaEBnNiGgc9rUiHGKv5l4/TGzDmYw3RhnkJGtLhbnnA/5qJj7x3dNDCRx/PJxu774LlH8lCOlB4hEfKg==}
@@ -3239,6 +3529,12 @@ packages:
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
+ resolution: {integrity: sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==}
+
+ resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==}
+
resolution: {integrity: sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==}
engines: {node: '>= 0.4'}
@@ -3304,6 +3600,9 @@ packages:
resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==}
+ resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
+
snapshots:
@@ -4628,14 +4927,32 @@ snapshots:
dependencies:
'@types/node': 22.19.19
+ '@types/[email protected]':
+ dependencies:
+ '@types/ms': 2.1.0
+
'@types/[email protected]': {}
+ '@types/[email protected]':
+ dependencies:
+ '@types/estree': 1.0.9
+
'@types/[email protected]': {}
+ '@types/[email protected]':
+ dependencies:
+ '@types/unist': 3.0.3
+
'@types/[email protected]': {}
'@types/[email protected]': {}
+ '@types/[email protected]':
+ dependencies:
+ '@types/unist': 3.0.3
+
+ '@types/[email protected]': {}
+
dependencies:
undici-types: 6.21.0
@@ -4648,6 +4965,10 @@ snapshots:
dependencies:
csstype: 3.2.3
+ '@types/[email protected]': {}
+
+ '@types/[email protected]': {}
+
dependencies:
'@types/node': 22.19.19
@@ -4743,6 +5064,8 @@ snapshots:
'@typescript-eslint/types': 8.59.3
eslint-visitor-keys: 5.0.1
+ '@ungap/[email protected]': {}
+
optional: true
@@ -4918,6 +5241,8 @@ snapshots:
+
@@ -4992,6 +5317,8 @@ snapshots:
+
dependencies:
ansi-styles: 4.3.0
@@ -4999,6 +5326,14 @@ snapshots:
+
+
+
+
@@ -5015,6 +5350,8 @@ snapshots:
+
@@ -5061,6 +5398,10 @@ snapshots:
dependencies:
ms: 2.1.3
+ dependencies:
+ character-entities: 2.0.2
+
dependencies:
mimic-response: 3.1.0
@@ -5096,6 +5437,10 @@ snapshots:
+ dependencies:
+ dequal: 2.0.3
+
@@ -5255,6 +5600,8 @@ snapshots:
+
dependencies:
'@next/eslint-plugin-next': 16.2.6
@@ -5458,10 +5805,14 @@ snapshots:
+
+
@@ -5607,12 +5958,38 @@ snapshots:
dependencies:
function-bind: 1.1.2
+ dependencies:
+ '@types/estree': 1.0.9
+ '@types/hast': 3.0.4
+ '@types/unist': 3.0.3
+ comma-separated-tokens: 2.0.3
+ devlop: 1.1.0
+ estree-util-is-identifier-name: 3.0.0
+ hast-util-whitespace: 3.0.0
+ mdast-util-mdx-expression: 2.0.1
+ mdast-util-mdx-jsx: 3.2.0
+ mdast-util-mdxjs-esm: 2.0.1
+ property-information: 7.1.0
+ space-separated-tokens: 2.0.2
+ style-to-js: 1.1.21
+ unist-util-position: 5.0.0
+ vfile-message: 4.0.3
+ transitivePeerDependencies:
+ - supports-color
+
+ dependencies:
+ '@types/hast': 3.0.4
+
dependencies:
hermes-estree: 0.25.1
+
@@ -5630,12 +6007,21 @@ snapshots:
+
dependencies:
es-errors: 1.3.0
hasown: 2.0.3
side-channel: 1.1.0
+
+ dependencies:
+ is-alphabetical: 2.0.1
+ is-decimal: 2.0.1
+
dependencies:
call-bind: 1.0.9
@@ -5680,6 +6066,8 @@ snapshots:
call-bound: 1.0.4
has-tostringtag: 1.0.2
+
@@ -5700,6 +6088,8 @@ snapshots:
dependencies:
is-extglob: 2.1.1
+
dependencies:
is-docker: 3.0.0
@@ -5715,6 +6105,8 @@ snapshots:
+
dependencies:
call-bound: 1.0.4
@@ -5883,6 +6275,8 @@ snapshots:
+
dependencies:
js-tokens: 4.0.0
@@ -5901,10 +6295,356 @@ snapshots:
dependencies:
'@jridgewell/sourcemap-codec': 1.5.5
+
+ dependencies:
+ '@types/mdast': 4.0.4
+ escape-string-regexp: 5.0.0
+ unist-util-is: 6.0.1
+ unist-util-visit-parents: 6.0.2
+
+ dependencies:
+ '@types/mdast': 4.0.4
+ '@types/unist': 3.0.3
+ decode-named-character-reference: 1.3.0
+ devlop: 1.1.0
+ mdast-util-to-string: 4.0.0
+ micromark: 4.0.2
+ micromark-util-decode-numeric-character-reference: 2.0.2
+ micromark-util-decode-string: 2.0.1
+ micromark-util-normalize-identifier: 2.0.1
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+ unist-util-stringify-position: 4.0.0
+ transitivePeerDependencies:
+ - supports-color
+
+ dependencies:
+ '@types/mdast': 4.0.4
+ ccount: 2.0.1
+ devlop: 1.1.0
+ mdast-util-find-and-replace: 3.0.2
+ micromark-util-character: 2.1.1
+
+ dependencies:
+ '@types/mdast': 4.0.4
+ devlop: 1.1.0
+ mdast-util-from-markdown: 2.0.3
+ mdast-util-to-markdown: 2.1.2
+ micromark-util-normalize-identifier: 2.0.1
+ transitivePeerDependencies:
+ - supports-color
+
+ dependencies:
+ '@types/mdast': 4.0.4
+ mdast-util-from-markdown: 2.0.3
+ mdast-util-to-markdown: 2.1.2
+ transitivePeerDependencies:
+ - supports-color
+
+ dependencies:
+ '@types/mdast': 4.0.4
+ devlop: 1.1.0
+ markdown-table: 3.0.4
+ mdast-util-from-markdown: 2.0.3
+ mdast-util-to-markdown: 2.1.2
+ transitivePeerDependencies:
+ - supports-color
+
+ dependencies:
+ '@types/mdast': 4.0.4
+ devlop: 1.1.0
+ mdast-util-from-markdown: 2.0.3
+ mdast-util-to-markdown: 2.1.2
+ transitivePeerDependencies:
+ - supports-color
+
+ dependencies:
+ mdast-util-from-markdown: 2.0.3
+ mdast-util-gfm-autolink-literal: 2.0.1
+ mdast-util-gfm-footnote: 2.1.0
+ mdast-util-gfm-strikethrough: 2.0.0
+ mdast-util-gfm-table: 2.0.0
+ mdast-util-gfm-task-list-item: 2.0.0
+ mdast-util-to-markdown: 2.1.2
+ transitivePeerDependencies:
+ - supports-color
+
+ dependencies:
+ '@types/estree-jsx': 1.0.5
+ '@types/hast': 3.0.4
+ '@types/mdast': 4.0.4
+ devlop: 1.1.0
+ mdast-util-from-markdown: 2.0.3
+ mdast-util-to-markdown: 2.1.2
+ transitivePeerDependencies:
+ - supports-color
+
+ dependencies:
+ '@types/estree-jsx': 1.0.5
+ '@types/hast': 3.0.4
+ '@types/mdast': 4.0.4
+ '@types/unist': 3.0.3
+ ccount: 2.0.1
+ devlop: 1.1.0
+ mdast-util-from-markdown: 2.0.3
+ mdast-util-to-markdown: 2.1.2
+ parse-entities: 4.0.2
+ stringify-entities: 4.0.4
+ unist-util-stringify-position: 4.0.0
+ vfile-message: 4.0.3
+ transitivePeerDependencies:
+ - supports-color
+
+ dependencies:
+ '@types/estree-jsx': 1.0.5
+ '@types/hast': 3.0.4
+ '@types/mdast': 4.0.4
+ devlop: 1.1.0
+ mdast-util-from-markdown: 2.0.3
+ mdast-util-to-markdown: 2.1.2
+ transitivePeerDependencies:
+ - supports-color
+
+ dependencies:
+ '@types/mdast': 4.0.4
+ unist-util-is: 6.0.1
+
+ dependencies:
+ '@types/hast': 3.0.4
+ '@types/mdast': 4.0.4
+ '@ungap/structured-clone': 1.3.1
+ devlop: 1.1.0
+ micromark-util-sanitize-uri: 2.0.1
+ trim-lines: 3.0.1
+ unist-util-position: 5.0.0
+ unist-util-visit: 5.1.0
+ vfile: 6.0.3
+
+ dependencies:
+ '@types/mdast': 4.0.4
+ '@types/unist': 3.0.3
+ longest-streak: 3.1.0
+ mdast-util-phrasing: 4.1.0
+ mdast-util-to-string: 4.0.0
+ micromark-util-classify-character: 2.0.1
+ micromark-util-decode-string: 2.0.1
+ unist-util-visit: 5.1.0
+ zwitch: 2.0.4
+
+ dependencies:
+ '@types/mdast': 4.0.4
+
+ dependencies:
+ decode-named-character-reference: 1.3.0
+ devlop: 1.1.0
+ micromark-factory-destination: 2.0.1
+ micromark-factory-label: 2.0.1
+ micromark-factory-space: 2.0.1
+ micromark-factory-title: 2.0.1
+ micromark-factory-whitespace: 2.0.1
+ micromark-util-character: 2.1.1
+ micromark-util-chunked: 2.0.1
+ micromark-util-classify-character: 2.0.1
+ micromark-util-html-tag-name: 2.0.1
+ micromark-util-normalize-identifier: 2.0.1
+ micromark-util-resolve-all: 2.0.1
+ micromark-util-subtokenize: 2.1.0
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ micromark-util-character: 2.1.1
+ micromark-util-sanitize-uri: 2.0.1
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ devlop: 1.1.0
+ micromark-core-commonmark: 2.0.3
+ micromark-factory-space: 2.0.1
+ micromark-util-character: 2.1.1
+ micromark-util-normalize-identifier: 2.0.1
+ micromark-util-sanitize-uri: 2.0.1
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ devlop: 1.1.0
+ micromark-util-chunked: 2.0.1
+ micromark-util-classify-character: 2.0.1
+ micromark-util-resolve-all: 2.0.1
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ devlop: 1.1.0
+ micromark-factory-space: 2.0.1
+ micromark-util-character: 2.1.1
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ devlop: 1.1.0
+ micromark-factory-space: 2.0.1
+ micromark-util-character: 2.1.1
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ micromark-extension-gfm-autolink-literal: 2.1.0
+ micromark-extension-gfm-footnote: 2.1.0
+ micromark-extension-gfm-strikethrough: 2.1.0
+ micromark-extension-gfm-table: 2.1.1
+ micromark-extension-gfm-tagfilter: 2.0.0
+ micromark-extension-gfm-task-list-item: 2.1.0
+ micromark-util-combine-extensions: 2.0.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ micromark-util-character: 2.1.1
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ devlop: 1.1.0
+ micromark-util-character: 2.1.1
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ micromark-util-character: 2.1.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ micromark-factory-space: 2.0.1
+ micromark-util-character: 2.1.1
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ micromark-factory-space: 2.0.1
+ micromark-util-character: 2.1.1
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ micromark-util-symbol: 2.0.1
+
+ dependencies:
+ micromark-util-character: 2.1.1
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ micromark-util-chunked: 2.0.1
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ micromark-util-symbol: 2.0.1
+
+ dependencies:
+ decode-named-character-reference: 1.3.0
+ micromark-util-character: 2.1.1
+ micromark-util-decode-numeric-character-reference: 2.0.2
+ micromark-util-symbol: 2.0.1
+
+
+
+ dependencies:
+ micromark-util-symbol: 2.0.1
+
+ dependencies:
+ micromark-util-types: 2.0.2
+
+ dependencies:
+ micromark-util-character: 2.1.1
+ micromark-util-encode: 2.0.1
+ micromark-util-symbol: 2.0.1
+
+ dependencies:
+ devlop: 1.1.0
+ micromark-util-chunked: 2.0.1
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+
+
+
+ dependencies:
+ '@types/debug': 4.1.13
+ debug: 4.4.3
+ decode-named-character-reference: 1.3.0
+ devlop: 1.1.0
+ micromark-core-commonmark: 2.0.3
+ micromark-factory-space: 2.0.1
+ micromark-util-character: 2.1.1
+ micromark-util-chunked: 2.0.1
+ micromark-util-combine-extensions: 2.0.1
+ micromark-util-decode-numeric-character-reference: 2.0.2
+ micromark-util-encode: 2.0.1
+ micromark-util-normalize-identifier: 2.0.1
+ micromark-util-resolve-all: 2.0.1
+ micromark-util-sanitize-uri: 2.0.1
+ micromark-util-subtokenize: 2.1.0
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+ transitivePeerDependencies:
+ - supports-color
+
dependencies:
braces: 3.0.3
@@ -6059,6 +6799,16 @@ snapshots:
dependencies:
callsites: 3.1.0
+ dependencies:
+ '@types/unist': 2.0.11
+ character-entities-legacy: 3.0.0
+ character-reference-invalid: 2.0.1
+ decode-named-character-reference: 1.3.0
+ is-alphanumerical: 2.0.1
+ is-decimal: 2.0.1
+ is-hexadecimal: 2.0.1
+
@@ -6108,6 +6858,8 @@ snapshots:
object-assign: 4.1.1
react-is: 16.13.1
+
dependencies:
end-of-stream: 1.4.5
@@ -6194,6 +6946,24 @@ snapshots:
+ dependencies:
+ '@types/hast': 3.0.4
+ '@types/mdast': 4.0.4
+ '@types/react': 19.2.14
+ devlop: 1.1.0
+ hast-util-to-jsx-runtime: 2.3.6
+ html-url-attributes: 3.0.1
+ mdast-util-to-hast: 13.2.1
+ react: 19.2.6
+ remark-parse: 11.0.0
+ remark-rehype: 11.1.2
+ unified: 11.0.5
+ unist-util-visit: 5.1.0
+ vfile: 6.0.3
+ transitivePeerDependencies:
+ - supports-color
+
dependencies:
react: 19.2.6
@@ -6249,6 +7019,40 @@ snapshots:
gopd: 1.2.0
set-function-name: 2.0.2
+ dependencies:
+ '@types/mdast': 4.0.4
+ mdast-util-gfm: 3.1.0
+ micromark-extension-gfm: 3.0.0
+ remark-parse: 11.0.0
+ remark-stringify: 11.0.0
+ unified: 11.0.5
+ transitivePeerDependencies:
+ - supports-color
+
+ dependencies:
+ '@types/mdast': 4.0.4
+ mdast-util-from-markdown: 2.0.3
+ micromark-util-types: 2.0.2
+ unified: 11.0.5
+ transitivePeerDependencies:
+ - supports-color
+
+ dependencies:
+ '@types/hast': 3.0.4
+ '@types/mdast': 4.0.4
+ mdast-util-to-hast: 13.2.1
+ unified: 11.0.5
+ vfile: 6.0.3
+
+ dependencies:
+ '@types/mdast': 4.0.4
+ mdast-util-to-markdown: 2.1.2
+ unified: 11.0.5
+
@@ -6402,6 +7206,8 @@ snapshots:
+
@@ -6463,12 +7269,25 @@ snapshots:
dependencies:
safe-buffer: 5.2.1
+ dependencies:
+ character-entities-html4: 2.1.0
+ character-entities-legacy: 3.0.0
+
+ dependencies:
+ style-to-object: 1.0.14
+
+ dependencies:
+ inline-style-parser: 0.2.7
+
dependencies:
client-only: 0.0.1
@@ -6520,6 +7339,10 @@ snapshots:
dependencies:
is-number: 7.0.0
+
+
dependencies:
typescript: 5.9.3
@@ -6602,6 +7425,39 @@ snapshots:
+ dependencies:
+ '@types/unist': 3.0.3
+ bail: 2.0.2
+ devlop: 1.1.0
+ extend: 3.0.2
+ is-plain-obj: 4.1.0
+ trough: 2.2.0
+ vfile: 6.0.3
+
+ dependencies:
+ '@types/unist': 3.0.3
+
+ dependencies:
+ '@types/unist': 3.0.3
+
+ dependencies:
+ '@types/unist': 3.0.3
+
+ dependencies:
+ '@types/unist': 3.0.3
+ unist-util-is: 6.0.1
+
+ dependencies:
+ '@types/unist': 3.0.3
+ unist-util-is: 6.0.1
+ unist-util-visit-parents: 6.0.2
+
dependencies:
napi-postinstall: 0.3.4
@@ -6657,6 +7513,16 @@ snapshots:
+ dependencies:
+ '@types/unist': 3.0.3
+ unist-util-stringify-position: 4.0.0
+
+ dependencies:
+ '@types/unist': 3.0.3
+ vfile-message: 4.0.3
+
dependencies:
is-bigint: 1.1.0
@@ -6725,3 +7591,5 @@ snapshots:
zod: 3.25.76
+
diff --git a/src/app/(app)/agents/[agent]/chat/[thread]/page.tsx b/src/app/(app)/agents/[agent]/chat/[thread]/page.tsx
index 395f595a..71003bd8 100644
--- a/src/app/(app)/agents/[agent]/chat/[thread]/page.tsx
+++ b/src/app/(app)/agents/[agent]/chat/[thread]/page.tsx
@@ -92,6 +92,7 @@ export default async function AgentChatThreadPage({
agentDisplayName={resolved.display_name}
sessionId={threadId}
sessionKey={sessionKey}
+ templateKey={resolved.template_key}
initialMessages={history.map((m) => ({ id: m.id, role: m.role, body: m.body }))}
/>
</div>
diff --git a/src/app/(app)/connections/page.tsx b/src/app/(app)/connections/page.tsx
index 884eb9ab..efbb4084 100644
--- a/src/app/(app)/connections/page.tsx
+++ b/src/app/(app)/connections/page.tsx
@@ -1,30 +1,20 @@
-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
-import { Button } from "@/components/ui/button";
-import { Badge } from "@/components/ui/badge";
-import { Plug } from "lucide-react";
+import { Card, CardContent } from "@/components/ui/card";
import { getActiveProject } from "@/server/active-project";
-import { listOAuthTokens } from "@/server/db/oauth";
-import type { OAuthProvider } from "@/types";
+import { MCP_CATALOG, storedMcpKey } from "@/server/mcp-catalog";
+import { getMcpStatus } from "@/server/mcp-state";
+import { McpCard } from "@/components/mcp-card";
+import { McpFlashBanner } from "@/components/mcp-flash-banner";
-const PROVIDERS: Array<{
- id: OAuthProvider;
- label: string;
- description: string;
-}> = [
- {
- id: "google_ads",
- label: "Google Ads",
- description: "OAuth for the Google Ads agent. Required for bid/budget/keyword automation.",
- },
- {
- id: "gsc",
- label: "Google Search Console",
- description: "OAuth for the SEO agent. Required for ranking + content data.",
- },
-];
+type Search = { mcp_connected?: string; mcp_error?: string };
-export default async function ConnectionsPage() {
+export default async function ConnectionsPage({
+ searchParams,
+}: {
+ searchParams: Promise<Search>;
+}) {
const project = await getActiveProject();
+ const { mcp_connected, mcp_error } = await searchParams;
+
if (!project) {
return (
<div className="mx-auto max-w-md pt-12 text-sm text-muted-foreground">
@@ -33,58 +23,39 @@ export default async function ConnectionsPage() {
);
}
- const tokens = listOAuthTokens(project.slug);
- const tokensByProvider = new Map<OAuthProvider, number>();
- for (const t of tokens) {
- tokensByProvider.set(t.provider, (tokensByProvider.get(t.provider) ?? 0) + 1);
- }
+ // Status probes happen in parallel — each has its own 2s timeout so a
+ // flaky upstream doesn't gate the whole page.
+ const statuses = await Promise.all(
+ MCP_CATALOG.map((s) => getMcpStatus(storedMcpKey(project.slug, s.key))),
+ );
return (
<div className="mx-auto max-w-3xl space-y-6">
<header>
<h1 className="text-2xl font-semibold tracking-tight">Connections</h1>
<p className="text-sm text-muted-foreground">
- Project <span className="font-mono">{project.slug}</span> · OAuth tokens are
- encrypted with your OS keychain master key and stored locally.
+ Project <span className="font-mono">{project.slug}</span> · MCP servers
+ configured here are shared by every agent in this project. Each project
+ gets its own OpenClaw key (and its own bearer token), so connecting
+ here doesn&rsquo;t touch other projects&rsquo; setups.
</p>
</header>
- <div className="space-y-3">
- {PROVIDERS.map((p) => {
- const connected = (tokensByProvider.get(p.id) ?? 0) > 0;
- return (
- <Card key={p.id}>
- <CardHeader className="flex flex-row items-start justify-between space-y-0">
- <div className="space-y-1">
- <CardTitle className="flex items-center gap-2 text-base">
- <Plug className="size-4" />
- {p.label}
- {connected && (
- <Badge variant="secondary" className="text-[10px]">
- connected
- </Badge>
- )}
- </CardTitle>
- <CardDescription>{p.description}</CardDescription>
- </div>
- <Button asChild variant={connected ? "outline" : "default"} size="sm">
- <a href={`/api/oauth/${p.id}/start?project=${project.slug}`}>
- {connected ? "Reconnect" : "Connect"}
- </a>
- </Button>
- </CardHeader>
- <CardContent className="pt-0">
- <p className="text-xs text-muted-foreground">
- Status:{" "}
- {connected
- ? `${tokensByProvider.get(p.id)} account(s) connected`
- : "not connected"}
- </p>
- </CardContent>
- </Card>
- );
- })}
- </div>
+ <McpFlashBanner connected={mcp_connected} error={mcp_error} />
+
+ {MCP_CATALOG.length === 0 ? (
+ <Card>
+ <CardContent className="py-12 text-center text-sm text-muted-foreground">
+ No MCP servers in the catalog yet.
+ </CardContent>
+ </Card>
+ ) : (
+ <div className="space-y-3">
+ {MCP_CATALOG.map((spec, i) => (
+ <McpCard key={spec.key} spec={spec} status={statuses[i]} />
+ ))}
+ </div>
+ )}
</div>
);
}
diff --git a/src/app/api/mcp-oauth/callback/route.ts b/src/app/api/mcp-oauth/callback/route.ts
new file mode 100644
index 00000000..dd909eca
--- /dev/null
+++ b/src/app/api/mcp-oauth/callback/route.ts
@@ -0,0 +1,133 @@
+import { NextResponse } from "next/server";
+import { consumePending } from "@/server/mcp-pending";
+import { setMcpBearer } from "@/server/mcp-state";
+
+export const dynamic = "force-dynamic";
+export const runtime = "nodejs";
+
+/**
+ * OAuth 2.0 redirect URI for the one-click MCP connect flow. The browser
+ * lands here after the user authorizes upstream. We look up the pending
+ * flow by `state`, exchange the code for an access token, write the
+ * MCP config via `openclaw mcp set`, and bounce the user back to the
+ * agent's MCP tab.
+ *
+ * On failure we still redirect (so the browser doesn't end up on a raw
+ * JSON page); the destination carries `?mcp_error=…` for the page to
+ * surface. The pending entry is always consumed.
+ */
+export async function GET(request: Request) {
+ const url = new URL(request.url);
+ const code = url.searchParams.get("code");
+ const state = url.searchParams.get("state");
+ const upstreamError = url.searchParams.get("error");
+
+ if (!state) {
+ return htmlErrorPage("Missing state parameter; cannot resume the OAuth flow.");
+ }
+
+ const pending = consumePending(state);
+ if (!pending) {
+ return htmlErrorPage("This authorization link has expired or was already used.");
+ }
+
+ const back = new URL("/connections", request.url);
+
+ if (upstreamError) {
+ back.searchParams.set(
+ "mcp_error",
+ `Authorization rejected: ${upstreamError}`,
+ );
+ return NextResponse.redirect(back);
+ }
+ if (!code) {
+ back.searchParams.set("mcp_error", "Authorization callback returned no code.");
+ return NextResponse.redirect(back);
+ }
+
+ // Token exchange. Send PKCE + (defensively) the secret. Servers that
+ // honor token_endpoint_auth_method=none ignore the secret; servers that
+ // require it still accept this request. Either way PKCE is validated.
+ const body = new URLSearchParams({
+ grant_type: "authorization_code",
+ code,
+ client_id: pending.client_id,
+ redirect_uri: pending.redirect_uri,
+ code_verifier: pending.code_verifier,
+ resource: pending.resource_url,
+ });
+ if (pending.client_secret) body.set("client_secret", pending.client_secret);
+
+ let access_token: string;
+ try {
+ const res = await fetch(pending.token_endpoint, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/x-www-form-urlencoded",
+ Accept: "application/json",
+ },
+ body: body.toString(),
+ });
+ const text = await res.text();
+ if (!res.ok) {
+ back.searchParams.set(
+ "mcp_error",
+ `Token exchange failed (HTTP ${res.status}): ${truncate(text, 200)}`,
+ );
+ return NextResponse.redirect(back);
+ }
+ const parsed = JSON.parse(text) as { access_token?: string };
+ if (!parsed.access_token) {
+ back.searchParams.set("mcp_error", "Token endpoint returned no access_token.");
+ return NextResponse.redirect(back);
+ }
+ access_token = parsed.access_token;
+ } catch (err) {
+ back.searchParams.set(
+ "mcp_error",
+ `Token exchange error: ${err instanceof Error ? err.message : String(err)}`,
+ );
+ return NextResponse.redirect(back);
+ }
+
+ try {
+ await setMcpBearer(pending.stored_key, pending.resource_url, access_token);
+ } catch (err) {
+ back.searchParams.set(
+ "mcp_error",
+ `Saving MCP config failed: ${err instanceof Error ? err.message : String(err)}`,
+ );
+ return NextResponse.redirect(back);
+ }
+
+ // Flash banner uses the catalog name (what the user recognizes), not the
+ // project-prefixed openclaw key.
+ back.searchParams.set("mcp_connected", pending.display_name);
+ return NextResponse.redirect(back);
+}
+
+function htmlErrorPage(message: string): Response {
+ // Shown only when we can't even resolve the pending flow, so we have no
+ // agent slug to redirect to. Bare minimal HTML — Tailwind isn't loaded.
+ const body = `<!doctype html><html><body style="font-family:system-ui;padding:2rem;max-width:36rem;margin:auto">
+<h1 style="margin:0 0 1rem;font-size:1.25rem">Couldn’t complete MCP connection</h1>
+<p style="color:#666">${escapeHtml(message)}</p>
+<p style="margin-top:2rem"><a href="/">← Back to app</a></p>
+</body></html>`;
+ return new Response(body, {
+ status: 400,
+ headers: { "Content-Type": "text/html; charset=utf-8" },
+ });
+}
+
+function escapeHtml(s: string): string {
+ return s
+ .replace(/&/g, "&amp;")
+ .replace(/</g, "&lt;")
+ .replace(/>/g, "&gt;")
+ .replace(/"/g, "&quot;");
+}
+
+function truncate(s: string, n: number): string {
+ return s.length > n ? `${s.slice(0, n)}…` : s;
+}
diff --git a/src/components/agent-chat.tsx b/src/components/agent-chat.tsx
index 7cdc1cac..158d60c2 100644
--- a/src/components/agent-chat.tsx
+++ b/src/components/agent-chat.tsx
@@ -13,6 +13,7 @@ import {
type SlashCommand,
} from "@/lib/slash-commands";
import { SlashCommandPopover } from "./slash-command-popover";
+import { Markdown } from "./markdown";
type Message = {
id: string;
@@ -37,6 +38,11 @@ type Props = {
* thread the resolved key through instead of reconstructing it server-side.
*/
sessionKey: string;
+ /**
+ * Template key the agent was provisioned from (e.g. "google_ads"). Kept
+ * for future per-template chat affordances; currently unused.
+ */
+ templateKey?: string;
initialMessages?: InitialMessage[];
};
@@ -46,6 +52,7 @@ export function AgentChat({
agentDisplayName,
sessionId,
sessionKey,
+ templateKey: _templateKey,
initialMessages = [],
}: Props) {
const [messages, setMessages] = useState<Message[]>(initialMessages);
@@ -105,13 +112,18 @@ export function AgentChat({
el.style.height = `${Math.min(el.scrollHeight, 200)}px`;
}
- async function send() {
- const text = input.trim();
+ async function send(overrideText?: string) {
+ // overrideText: bypass the composer and send a programmatic message
+ // (e.g., the MCP connect kickoff). When provided, we do NOT touch the
+ // input/textarea state so the user's draft is preserved.
+ const usingOverride = typeof overrideText === "string";
+ const text = (usingOverride ? overrideText : input).trim();
if (!text || pending) return;
// Local-only slash commands (clear, new, stop, help) — mirror OpenClaw web
- // UI behavior: handle client-side, do NOT send to the agent.
- const parsed = parseSlashMessage(text);
+ // UI behavior: handle client-side, do NOT send to the agent. Skip when
+ // sending programmatically: overrides are always plain prompts.
+ const parsed = usingOverride ? null : parseSlashMessage(text);
if (parsed) {
const action = executeLocalSlashCommand(parsed.command);
if (action) {
@@ -149,9 +161,11 @@ export function AgentChat({
const userMessage: Message = { id: `u-${Date.now()}`, role: "user", body: text };
const assistantId = `a-${Date.now()}`;
setMessages((m) => [...m, userMessage, { id: assistantId, role: "assistant", body: "" }]);
- setInput("");
- if (textareaRef.current) {
- textareaRef.current.style.height = "auto";
+ if (!usingOverride) {
+ setInput("");
+ if (textareaRef.current) {
+ textareaRef.current.style.height = "auto";
+ }
}
setPending(true);
@@ -419,17 +433,23 @@ function MessageRow({
</div>
);
}
- // Assistant: plain prose, full width within max-w-3xl. No bubble — Claude.ai pattern.
+ // Assistant: rendered as markdown for code blocks, lists, bold, tables, etc.
+ // Plain text falls through unchanged because markdown is a superset. While
+ // streaming, partial markdown (e.g. an unclosed fence) is rendered as far as
+ // remark can parse it — visually fine because the next chunk arrives within
+ // milliseconds.
+ if (message.body === "") {
+ return (
+ <div className="group">
+ <div className="text-sm italic text-muted-foreground">
+ {`${agentDisplayName} is thinking…`}
+ </div>
+ </div>
+ );
+ }
return (
<div className="group">
- <div
- className={cn(
- "text-sm leading-relaxed whitespace-pre-wrap break-words text-foreground",
- message.body === "" && "italic text-muted-foreground",
- )}
- >
- {message.body || `${agentDisplayName} is thinking…`}
- </div>
+ <Markdown>{message.body}</Markdown>
</div>
);
}
diff --git a/src/components/markdown.tsx b/src/components/markdown.tsx
new file mode 100644
index 00000000..c1480b49
--- /dev/null
+++ b/src/components/markdown.tsx
@@ -0,0 +1,133 @@
+"use client";
+
+import { memo } from "react";
+import ReactMarkdown, { type Components } from "react-markdown";
+import remarkGfm from "remark-gfm";
+import { cn } from "@/lib/utils";
+
+/**
+ * Renders an agent message as markdown. Tailored to the streaming chat
+ * surface: rules favor compact layout, monospace for code/JSON, and
+ * safe link behavior. Anything react-markdown doesn't know about falls
+ * back to plain text — we deliberately don't enable raw HTML.
+ *
+ * Memoized because the chat re-renders the whole transcript on every
+ * stream tick; bailing out of re-parsing unchanged messages keeps long
+ * threads from regressing under heavy streaming.
+ */
+
+const COMPONENTS: Components = {
+ p: ({ className, ...props }) => (
+ <p className={cn("mb-3 last:mb-0 leading-relaxed", className)} {...props} />
+ ),
+ ul: ({ className, ...props }) => (
+ <ul className={cn("mb-3 list-disc space-y-1 pl-5 last:mb-0", className)} {...props} />
+ ),
+ ol: ({ className, ...props }) => (
+ <ol className={cn("mb-3 list-decimal space-y-1 pl-5 last:mb-0", className)} {...props} />
+ ),
+ li: ({ className, ...props }) => (
+ <li className={cn("leading-relaxed", className)} {...props} />
+ ),
+ h1: ({ className, ...props }) => (
+ <h1 className={cn("mb-2 mt-4 text-base font-semibold first:mt-0", className)} {...props} />
+ ),
+ h2: ({ className, ...props }) => (
+ <h2 className={cn("mb-2 mt-4 text-base font-semibold first:mt-0", className)} {...props} />
+ ),
+ h3: ({ className, ...props }) => (
+ <h3 className={cn("mb-2 mt-3 text-sm font-semibold first:mt-0", className)} {...props} />
+ ),
+ h4: ({ className, ...props }) => (
+ <h4 className={cn("mb-1 mt-3 text-sm font-semibold first:mt-0", className)} {...props} />
+ ),
+ strong: ({ className, ...props }) => (
+ <strong className={cn("font-semibold text-foreground", className)} {...props} />
+ ),
+ em: ({ className, ...props }) => (
+ <em className={cn("italic", className)} {...props} />
+ ),
+ a: ({ className, href, ...props }) => (
+ <a
+ className={cn("font-medium text-foreground underline underline-offset-2 hover:opacity-80", className)}
+ href={href}
+ target="_blank"
+ rel="noopener noreferrer"
+ {...props}
+ />
+ ),
+ blockquote: ({ className, ...props }) => (
+ <blockquote
+ className={cn("mb-3 border-l-2 border-muted-foreground/30 pl-3 text-muted-foreground last:mb-0", className)}
+ {...props}
+ />
+ ),
+ hr: ({ className, ...props }) => (
+ <hr className={cn("my-4 border-border", className)} {...props} />
+ ),
+ table: ({ className, ...props }) => (
+ <div className="mb-3 w-full overflow-x-auto last:mb-0">
+ <table className={cn("min-w-full border-collapse text-xs", className)} {...props} />
+ </div>
+ ),
+ th: ({ className, ...props }) => (
+ <th
+ className={cn("border-b px-2 py-1.5 text-left font-medium", className)}
+ {...props}
+ />
+ ),
+ td: ({ className, ...props }) => (
+ <td className={cn("border-b border-border/50 px-2 py-1.5 align-top", className)} {...props} />
+ ),
+ code: ({ className, children, ...props }) => {
+ // react-markdown emits both inline and fenced `code`. Inline gets no
+ // language hint and no surrounding `<pre>`. Fenced gets a language hint
+ // ("language-json"). We distinguish by checking the language class.
+ const isFenced = typeof className === "string" && className.startsWith("language-");
+ if (isFenced) {
+ // Render as plain inner; <pre> below provides the block container.
+ return (
+ <code className={cn("font-mono text-[12px] leading-relaxed", className)} {...props}>
+ {children}
+ </code>
+ );
+ }
+ return (
+ <code
+ className={cn(
+ "rounded bg-muted px-1 py-0.5 font-mono text-[0.9em] text-foreground",
+ className,
+ )}
+ {...props}
+ >
+ {children}
+ </code>
+ );
+ },
+ pre: ({ className, ...props }) => (
+ <pre
+ className={cn(
+ "mb-3 max-w-full overflow-x-auto rounded-md border bg-muted/50 p-3 last:mb-0",
+ className,
+ )}
+ {...props}
+ />
+ ),
+};
+
+function MarkdownBase({ children, className }: { children: string; className?: string }) {
+ return (
+ <div
+ className={cn(
+ "text-sm leading-relaxed text-foreground break-words [&>:first-child]:mt-0",
+ className,
+ )}
+ >
+ <ReactMarkdown remarkPlugins={[remarkGfm]} components={COMPONENTS}>
+ {children}
+ </ReactMarkdown>
+ </div>
+ );
+}
+
+export const Markdown = memo(MarkdownBase);
diff --git a/src/components/mcp-card.tsx b/src/components/mcp-card.tsx
new file mode 100644
index 00000000..ba4a2161
--- /dev/null
+++ b/src/components/mcp-card.tsx
@@ -0,0 +1,202 @@
+"use client";
+
+import { useState, useTransition } from "react";
+import { useRouter } from "next/navigation";
+import { Plug, CheckCircle2, AlertTriangle, Loader2, Unplug, XCircle } from "lucide-react";
+import { Card, CardContent } from "@/components/ui/card";
+import { Button } from "@/components/ui/button";
+import { Badge } from "@/components/ui/badge";
+import { toast } from "sonner";
+import { startMcpConnect, disconnectMcpAction } from "@/server/actions/mcp";
+import type { McpSpec } from "@/server/mcp-catalog";
+import type { McpRuntimeStatus } from "@/server/mcp-state";
+
+type Props = {
+ spec: McpSpec;
+ status: McpRuntimeStatus;
+};
+
+export function McpCard({ spec, status }: Props) {
+ const [pending, startTransition] = useTransition();
+ const [busy, setBusy] = useState<"connect" | "disconnect" | null>(null);
+ const router = useRouter();
+
+ async function onConnect() {
+ setBusy("connect");
+ try {
+ const result = await startMcpConnect({ mcp_key: spec.key });
+ if (!result.ok) {
+ toast.error(result.error);
+ setBusy(null);
+ return;
+ }
+ // Full-page navigation: the authorize URL is on a different origin
+ // (the MCP issuer), so we can't push() into Next's router.
+ window.location.href = result.authorize_url;
+ } catch (err) {
+ toast.error(err instanceof Error ? err.message : String(err));
+ setBusy(null);
+ }
+ }
+
+ function onDisconnect() {
+ setBusy("disconnect");
+ startTransition(async () => {
+ const result = await disconnectMcpAction({ mcp_key: spec.key });
+ if (!result.ok) {
+ toast.error(result.error);
+ } else {
+ toast.success(`${spec.display_name} disconnected`);
+ // revalidatePath inside the action invalidates the cached server
+ // render, but the client still needs to re-fetch — router.refresh()
+ // forces the RSC payload to repopulate this card's `status` prop.
+ router.refresh();
+ }
+ setBusy(null);
+ });
+ }
+
+ const isBusy = busy !== null || pending;
+
+ return (
+ <Card>
+ <CardContent className="space-y-4 p-5">
+ <div className="flex items-start justify-between gap-3">
+ <div className="flex items-start gap-3 min-w-0">
+ <div className="flex size-9 shrink-0 items-center justify-center rounded-md bg-muted">
+ <Plug className="size-4" />
+ </div>
+ <div className="min-w-0">
+ <div className="flex items-center gap-2">
+ <h3 className="text-sm font-medium">{spec.display_name}</h3>
+ <StatusBadge status={status} />
+ </div>
+ <p className="mt-0.5 text-xs text-muted-foreground">
+ {spec.description}
+ </p>
+ <p className="mt-1 truncate font-mono text-[11px] text-muted-foreground">
+ {spec.resource_url}
+ </p>
+ </div>
+ </div>
+ <div className="shrink-0">
+ {status.state === "connected" ? (
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ disabled={isBusy}
+ onClick={onDisconnect}
+ >
+ {busy === "disconnect" ? (
+ <Loader2 className="size-3.5 animate-spin" />
+ ) : (
+ <Unplug className="size-3.5" />
+ )}
+ Disconnect
+ </Button>
+ ) : (
+ <Button type="button" size="sm" disabled={isBusy} onClick={onConnect}>
+ {busy === "connect" ? (
+ <Loader2 className="size-3.5 animate-spin" />
+ ) : (
+ <Plug className="size-3.5" />
+ )}
+ {status.state === "stale_token" ? "Reconnect" : "Connect"}
+ </Button>
+ )}
+ </div>
+ </div>
+
+ <StatusDetail status={status} />
+ </CardContent>
+ </Card>
+ );
+}
+
+function StatusBadge({ status }: { status: McpRuntimeStatus }) {
+ switch (status.state) {
+ case "connected":
+ return (
+ <Badge variant="secondary" className="gap-1 text-[10px]">
+ <CheckCircle2 className="size-3 text-emerald-600" />
+ connected
+ </Badge>
+ );
+ case "stale_token":
+ return (
+ <Badge variant="outline" className="gap-1 text-[10px]">
+ <AlertTriangle className="size-3 text-amber-600" />
+ token expired
+ </Badge>
+ );
+ case "unreachable":
+ return (
+ <Badge variant="outline" className="gap-1 text-[10px]">
+ <XCircle className="size-3 text-destructive" />
+ unreachable
+ </Badge>
+ );
+ case "configured_no_token":
+ return (
+ <Badge variant="outline" className="gap-1 text-[10px]">
+ <AlertTriangle className="size-3 text-amber-600" />
+ no token
+ </Badge>
+ );
+ case "not_configured":
+ return (
+ <Badge variant="outline" className="text-[10px]">
+ not connected
+ </Badge>
+ );
+ }
+}
+
+function StatusDetail({ status }: { status: McpRuntimeStatus }) {
+ switch (status.state) {
+ case "connected":
+ return (
+ <p className="text-xs text-muted-foreground">
+ {status.tools_count !== null
+ ? `${status.tools_count} tool${status.tools_count === 1 ? "" : "s"} available`
+ : "Live."}
+ {" · Verified "}
+ {timeAgo(status.last_checked_at)}
+ </p>
+ );
+ case "stale_token":
+ return (
+ <p className="text-xs text-muted-foreground">
+ Server rejected the saved token (HTTP {status.http_status}). Reconnect
+ to refresh.
+ </p>
+ );
+ case "unreachable":
+ return (
+ <p className="text-xs text-muted-foreground">
+ Couldn’t reach the MCP server: {status.error}
+ </p>
+ );
+ case "configured_no_token":
+ return (
+ <p className="text-xs text-muted-foreground">
+ Config exists but has no bearer token. Click Connect to fix.
+ </p>
+ );
+ case "not_configured":
+ return (
+ <p className="text-xs text-muted-foreground">
+ One click runs the OAuth flow against the issuer and saves the token to
+ your local OpenClaw config.
+ </p>
+ );
+ }
+}
+
+function timeAgo(iso: string): string {
+ const ms = Date.now() - new Date(iso).getTime();
+ if (ms < 60_000) return "just now";
+ if (ms < 3_600_000) return `${Math.floor(ms / 60_000)}m ago`;
+ return `${Math.floor(ms / 3_600_000)}h ago`;
+}
diff --git a/src/components/mcp-flash-banner.tsx b/src/components/mcp-flash-banner.tsx
new file mode 100644
index 00000000..f7fd440d
--- /dev/null
+++ b/src/components/mcp-flash-banner.tsx
@@ -0,0 +1,36 @@
+"use client";
+
+import { useEffect, useRef } from "react";
+import { useRouter } from "next/navigation";
+import { toast } from "sonner";
+
+/**
+ * One-shot banner driven by the `?mcp_connected` / `?mcp_error` query
+ * params the OAuth callback redirects with. Fires the toast once on mount
+ * and strips the params so a refresh doesn't re-toast.
+ */
+export function McpFlashBanner({
+ connected,
+ error,
+}: {
+ connected?: string;
+ error?: string;
+}) {
+ const router = useRouter();
+ const fired = useRef(false);
+
+ useEffect(() => {
+ if (fired.current) return;
+ if (!connected && !error) return;
+ fired.current = true;
+ if (error) toast.error(error);
+ else if (connected) toast.success(`Connected: ${connected}`);
+ // Clean the URL so a refresh / back-button doesn't re-fire.
+ const url = new URL(window.location.href);
+ url.searchParams.delete("mcp_connected");
+ url.searchParams.delete("mcp_error");
+ router.replace(url.pathname + (url.search ? url.search : ""));
+ }, [connected, error, router]);
+
+ return null;
+}
diff --git a/src/server/actions/mcp.ts b/src/server/actions/mcp.ts
new file mode 100644
index 00000000..1eaa3a0d
--- /dev/null
+++ b/src/server/actions/mcp.ts
@@ -0,0 +1,209 @@
+"use server";
+
+import { randomBytes, createHash } from "node:crypto";
+import { revalidatePath } from "next/cache";
+import { headers } from "next/headers";
+import { getActiveProject } from "@/server/active-project";
+import { mcpSpecByKey, storedMcpKey } from "@/server/mcp-catalog";
+import { setPending } from "@/server/mcp-pending";
+import { disconnectMcp as runDisconnect } from "@/server/mcp-state";
+
+export type StartMcpConnectResult =
+ | { ok: true; authorize_url: string }
+ | { ok: false; error: string };
+
+/**
+ * Begin a one-click MCP OAuth flow. Server-side: discovery → DCR →
+ * PKCE-pair → pending-state stash → caller redirects browser to the
+ * authorize URL we return. The callback handler in
+ * `/api/mcp-oauth/callback` finishes the exchange + writes the openclaw
+ * mcp config.
+ */
+export async function startMcpConnect(input: {
+ mcp_key: string;
+}): Promise<StartMcpConnectResult> {
+ const spec = mcpSpecByKey(input.mcp_key);
+ if (!spec) return { ok: false, error: `Unknown MCP key: ${input.mcp_key}` };
+
+ const project = await getActiveProject();
+ if (!project) {
+ return { ok: false, error: "No active project. Pick one before connecting an MCP." };
+ }
+ const stored_key = storedMcpKey(project.slug, spec.key);
+
+ let resolved: ResolvedAuthServer;
+ try {
+ resolved = await resolveAuthServer(spec.discovery_url);
+ } catch (err) {
+ return { ok: false, error: `Discovery failed: ${humanError(err)}` };
+ }
+
+ const origin = await originFromIncomingRequest();
+ const redirect_uri = `${origin}/api/mcp-oauth/callback`;
+
+ let dcr: DcrResponse;
+ try {
+ dcr = await dynamicRegister(resolved.registration_endpoint, redirect_uri);
+ } catch (err) {
+ return { ok: false, error: `Registration failed: ${humanError(err)}` };
+ }
+
+ // PKCE — S256 challenge from a 64-byte verifier.
+ const code_verifier = base64url(randomBytes(64));
+ const code_challenge = base64url(
+ createHash("sha256").update(code_verifier).digest(),
+ );
+ const state = base64url(randomBytes(24));
+
+ setPending(state, {
+ catalog_key: spec.key,
+ stored_key,
+ display_name: spec.display_name,
+ resource_url: spec.resource_url,
+ issuer: resolved.issuer,
+ token_endpoint: resolved.token_endpoint,
+ client_id: dcr.client_id,
+ client_secret: dcr.client_secret,
+ code_verifier,
+ redirect_uri,
+ project_slug: project.slug,
+ created_at: Date.now(),
+ });
+
+ const u = new URL(resolved.authorization_endpoint);
+ u.searchParams.set("response_type", "code");
+ u.searchParams.set("client_id", dcr.client_id);
+ u.searchParams.set("redirect_uri", redirect_uri);
+ u.searchParams.set("code_challenge", code_challenge);
+ u.searchParams.set("code_challenge_method", "S256");
+ u.searchParams.set("state", state);
+ u.searchParams.set("resource", spec.resource_url);
+
+ return { ok: true, authorize_url: u.toString() };
+}
+
+export async function disconnectMcpAction(input: {
+ mcp_key: string;
+}): Promise<{ ok: true } | { ok: false; error: string }> {
+ const project = await getActiveProject();
+ if (!project) {
+ return { ok: false, error: "No active project to disconnect from." };
+ }
+ const stored_key = storedMcpKey(project.slug, input.mcp_key);
+ try {
+ await runDisconnect(stored_key);
+ } catch (err) {
+ return { ok: false, error: humanError(err) };
+ }
+ revalidatePath("/connections");
+ return { ok: true };
+}
+
+// ─── helpers ────────────────────────────────────────────────────────
+
+type ResolvedAuthServer = {
+ issuer: string;
+ authorization_endpoint: string;
+ token_endpoint: string;
+ registration_endpoint: string;
+};
+
+async function resolveAuthServer(
+ resourceDiscoveryUrl: string,
+): Promise<ResolvedAuthServer> {
+ // RFC 9728: GET .well-known/oauth-protected-resource → carries the
+ // `authorization_servers` array. We pick the first and then fetch its
+ // RFC 8414 AS metadata to learn registration/token/authorize endpoints.
+ const r1 = await fetchJson(resourceDiscoveryUrl, 8000);
+ const servers = (r1 as { authorization_servers?: unknown }).authorization_servers;
+ if (!Array.isArray(servers) || servers.length === 0) {
+ throw new Error("no authorization_servers in discovery doc");
+ }
+ const issuer = String(servers[0]).replace(/\/$/, "");
+ // Standard AS metadata path; some notfair-style servers also accept a
+ // path-suffixed variant. Try the standard first — the path-suffixed
+ // variant is a hint for clients that skip RFC 9728, which we just
+ // didn't.
+ const asMetaUrl = `${issuer}/.well-known/oauth-authorization-server`;
+ const meta = (await fetchJson(asMetaUrl, 8000)) as Partial<ResolvedAuthServer>;
+ if (
+ !meta.authorization_endpoint
+ || !meta.token_endpoint
+ || !meta.registration_endpoint
+ ) {
+ throw new Error("AS metadata missing endpoints");
+ }
+ return {
+ issuer,
+ authorization_endpoint: meta.authorization_endpoint,
+ token_endpoint: meta.token_endpoint,
+ registration_endpoint: meta.registration_endpoint,
+ };
+}
+
+type DcrResponse = {
+ client_id: string;
+ client_secret?: string;
+ token_endpoint_auth_method?: string;
+};
+
+async function dynamicRegister(
+ registration_endpoint: string,
+ redirect_uri: string,
+): Promise<DcrResponse> {
+ // Register as `none` (public client) so we drive token exchange with
+ // PKCE + no secret per the MCP spec. Servers that don't yet support
+ // public clients will still return a client_secret — we keep it for
+ // back-compat fallback, but the token handler favors PKCE.
+ const body = {
+ client_name: "notfair-cmo",
+ redirect_uris: [redirect_uri],
+ grant_types: ["authorization_code"],
+ response_types: ["code"],
+ token_endpoint_auth_method: "none",
+ };
+ const res = await fetch(registration_endpoint, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(body),
+ });
+ if (!res.ok) {
+ const text = await res.text();
+ throw new Error(`DCR ${res.status}: ${text.slice(0, 200)}`);
+ }
+ const json = (await res.json()) as DcrResponse;
+ if (!json.client_id) throw new Error("DCR response missing client_id");
+ return json;
+}
+
+async function fetchJson(url: string, timeout_ms: number): Promise<unknown> {
+ const ctl = new AbortController();
+ const t = setTimeout(() => ctl.abort(), timeout_ms);
+ try {
+ const res = await fetch(url, { signal: ctl.signal });
+ if (!res.ok) throw new Error(`HTTP ${res.status} from ${url}`);
+ return await res.json();
+ } finally {
+ clearTimeout(t);
+ }
+}
+
+function base64url(b: Buffer): string {
+ return b.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
+}
+
+async function originFromIncomingRequest(): Promise<string> {
+ const h = await headers();
+ // Next surfaces forwarded headers when behind a proxy; fall back to host.
+ const proto = h.get("x-forwarded-proto") ?? "http";
+ const host = h.get("x-forwarded-host") ?? h.get("host");
+ if (!host) {
+ throw new Error("Could not derive origin from request headers");
+ }
+ return `${proto}://${host}`;
+}
+
+function humanError(err: unknown): string {
+ if (err instanceof Error) return err.message;
+ return String(err);
+}
diff --git a/src/server/mcp-catalog.ts b/src/server/mcp-catalog.ts
new file mode 100644
index 00000000..50ada0c0
--- /dev/null
+++ b/src/server/mcp-catalog.ts
@@ -0,0 +1,53 @@
+/**
+ * Static catalog of MCP servers the notfair-cmo UI knows how to connect.
+ *
+ * "Known" means we have a stable URL + OAuth discovery doc the server-side
+ * connect flow can drive end-to-end with zero LLM in the loop. Arbitrary
+ * MCPs (user describes one in chat) still go through the agent — the
+ * catalog is just the fast path for the ones we ship with.
+ *
+ * MCPs are managed at the project level (the Connections page). All agents
+ * inside a given project share the same MCP rows; cross-project boundaries
+ * are enforced by OpenClaw's `codex.agents` allowlist (see docs:
+ * gateway/configuration-reference#mcp) which `actions/mcp.ts` populates
+ * with every agent id in the active project.
+ */
+
+export type McpSpec = {
+ /** OpenClaw mcp config key (used by `openclaw mcp show/set/unset`). */
+ key: string;
+ display_name: string;
+ description: string;
+ /** Resource URL the token authenticates against (RFC 8707 audience). */
+ resource_url: string;
+ /** RFC 9728 protected-resource discovery endpoint. */
+ discovery_url: string;
+};
+
+export const MCP_CATALOG: McpSpec[] = [
+ {
+ key: "notfair-googleads",
+ display_name: "NotFair Google Ads",
+ description:
+ "Live Google Ads operations: campaigns, bids, budgets, keywords, search terms, change history.",
+ resource_url: "https://notfair.co/api/mcp/google_ads",
+ discovery_url:
+ "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/google_ads",
+ },
+];
+
+export function mcpSpecByKey(key: string): McpSpec | undefined {
+ return MCP_CATALOG.find((m) => m.key === key);
+}
+
+/**
+ * OpenClaw's mcp config is workspace-global. To keep projects' tokens
+ * independent (so connecting an MCP from project A doesn't stomp project
+ * B's bearer), we namespace the stored openclaw key with the project
+ * slug. Catalog key `notfair-googleads` + project `notfairco` becomes
+ * stored key `notfairco-notfair-googleads`. Runtime visibility is still
+ * gated by `codex.agents`.
+ */
+export function storedMcpKey(project_slug: string, catalog_key: string): string {
+ return `${project_slug}-${catalog_key}`;
+}
diff --git a/src/server/mcp-pending.ts b/src/server/mcp-pending.ts
new file mode 100644
index 00000000..56dda5d9
--- /dev/null
+++ b/src/server/mcp-pending.ts
@@ -0,0 +1,68 @@
+/**
+ * In-process map of pending MCP OAuth flows. Keyed by `state` (the CSRF
+ * token in the authorize URL). Lives in the Next.js server process and is
+ * lost on restart — that's fine because the flow is short-lived: from
+ * "click Connect" to "back at callback" is seconds, not days.
+ *
+ * Keeping this in-memory (vs. SQLite) avoids a migration + cleanup job for
+ * what is otherwise transient data. Two entries with the same `state` is
+ * cryptographically improbable; we still use `consume` (pop, not peek) so
+ * a replayed callback can't reuse the same exchange context.
+ */
+
+export type PendingMcpFlow = {
+ /** Catalog identifier (e.g. `notfair-googleads`) — what the UI shows. */
+ catalog_key: string;
+ /**
+ * Openclaw mcp config key the callback will `mcp set` against. Project-
+ * scoped (e.g. `notfairco-notfair-googleads`) so different projects don't
+ * stomp each other's tokens.
+ */
+ stored_key: string;
+ /** OpenClaw-side display name; mirrors the catalog spec. */
+ display_name: string;
+ resource_url: string;
+ /** OAuth issuer (the protected resource's authorization server). */
+ issuer: string;
+ /** The token endpoint resolved during start. */
+ token_endpoint: string;
+ client_id: string;
+ /** May be undefined for public clients registered with auth_method=none. */
+ client_secret?: string;
+ code_verifier: string;
+ redirect_uri: string;
+ /** Project slug (the active project at the time the flow started). */
+ project_slug: string;
+ created_at: number;
+};
+
+// In Next dev, edits to any file in the action's module graph trigger a
+// recompile that re-evaluates this module — a fresh `Map()` drops every
+// in-flight flow. Pinning to `globalThis` survives hot reloads because the
+// global is not recreated. The single-process invariant still holds (the
+// CLI launches one local Next.js server), so we don't need a real KV.
+const GLOBAL_KEY = "__notfair_cmo_mcp_pending__";
+type GlobalSlot = { store?: Map<string, PendingMcpFlow> };
+const slot = globalThis as unknown as GlobalSlot;
+const STORE: Map<string, PendingMcpFlow> = slot.store ?? (slot.store = new Map());
+const TTL_MS = 10 * 60 * 1000;
+
+function evictExpired() {
+ const cutoff = Date.now() - TTL_MS;
+ for (const [k, v] of STORE) {
+ if (v.created_at < cutoff) STORE.delete(k);
+ }
+}
+
+export function setPending(state: string, flow: PendingMcpFlow): void {
+ evictExpired();
+ STORE.set(state, flow);
+}
+
+export function consumePending(state: string): PendingMcpFlow | null {
+ evictExpired();
+ const hit = STORE.get(state);
+ if (!hit) return null;
+ STORE.delete(state);
+ return hit;
+}
diff --git a/src/server/mcp-state.ts b/src/server/mcp-state.ts
new file mode 100644
index 00000000..30b41694
--- /dev/null
+++ b/src/server/mcp-state.ts
@@ -0,0 +1,173 @@
+import { openclaw, OpenClawError } from "@/server/openclaw/cli";
+
+/**
+ * Read the merged state of a configured MCP server from OpenClaw + a fast
+ * health probe. We keep this thin: source of truth is openclaw.json (the
+ * config the CLI manages); we don't shadow-store tokens locally.
+ *
+ * `connection_state`:
+ * - "not_configured": no row in `openclaw mcp` for this key
+ * - "configured_no_token": row exists but lacks an Authorization header
+ * - "connected": row + token + probe succeeded
+ * - "stale_token": row + token but probe came back 401/403
+ * - "unreachable": row + token but probe failed (network/timeout/5xx)
+ */
+
+export type McpRuntimeStatus =
+ | { state: "not_configured" }
+ | { state: "configured_no_token"; url: string }
+ | {
+ state: "connected";
+ url: string;
+ tools_count: number | null;
+ last_checked_at: string;
+ }
+ | {
+ state: "stale_token";
+ url: string;
+ http_status: number;
+ last_checked_at: string;
+ }
+ | {
+ state: "unreachable";
+ url: string;
+ error: string;
+ last_checked_at: string;
+ };
+
+type McpConfigRow = {
+ url?: string;
+ transport?: string;
+ headers?: Record<string, string>;
+};
+
+async function readMcpConfig(key: string): Promise<McpConfigRow | null> {
+ try {
+ const out = await openclaw(["mcp", "show", key], { json: true });
+ if (!out || typeof out !== "object") return null;
+ return out as McpConfigRow;
+ } catch (err) {
+ // OpenClaw exits non-zero when the key is unknown — treat as "not configured".
+ if (err instanceof OpenClawError) return null;
+ throw err;
+ }
+}
+
+function bearerFromHeaders(headers: Record<string, string> | undefined): string | null {
+ if (!headers) return null;
+ // Headers can arrive case-mixed; check both common spellings.
+ const raw = headers.Authorization ?? headers.authorization;
+ if (!raw) return null;
+ const m = raw.match(/^Bearer\s+(.+)$/i);
+ return m ? m[1].trim() : null;
+}
+
+export async function getMcpStatus(key: string): Promise<McpRuntimeStatus> {
+ const config = await readMcpConfig(key);
+ if (!config || !config.url) return { state: "not_configured" };
+ const url = config.url;
+ const token = bearerFromHeaders(config.headers);
+ if (!token) return { state: "configured_no_token", url };
+ return probe(url, token);
+}
+
+/**
+ * Lightweight liveness probe. We POST a JSON-RPC `tools/list` — that's the
+ * cheapest MCP call that exercises auth + transport in one round-trip.
+ * 2s timeout: this is rendered server-side on the MCP tab and we'd rather
+ * show "unreachable" than block the page.
+ */
+async function probe(url: string, token: string): Promise<McpRuntimeStatus> {
+ const last_checked_at = new Date().toISOString();
+ try {
+ const controller = new AbortController();
+ const t = setTimeout(() => controller.abort(), 2000);
+ let res: Response;
+ try {
+ res = await fetch(url, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json, text/event-stream",
+ Authorization: `Bearer ${token}`,
+ },
+ body: JSON.stringify({
+ jsonrpc: "2.0",
+ id: 1,
+ method: "tools/list",
+ params: {},
+ }),
+ signal: controller.signal,
+ });
+ } finally {
+ clearTimeout(t);
+ }
+ if (res.status === 401 || res.status === 403) {
+ return { state: "stale_token", url, http_status: res.status, last_checked_at };
+ }
+ if (!res.ok) {
+ return {
+ state: "unreachable",
+ url,
+ error: `HTTP ${res.status}`,
+ last_checked_at,
+ };
+ }
+ // MCP can stream SSE for tools/list. Either format carries the JSON in a
+ // single frame, so a substring count of `"name"` is a decent
+ // tool-count proxy without paying for full SSE parsing here.
+ const text = await res.text();
+ const tools_count = countTools(text);
+ return { state: "connected", url, tools_count, last_checked_at };
+ } catch (err) {
+ const msg = err instanceof Error ? err.message : String(err);
+ return { state: "unreachable", url, error: msg, last_checked_at };
+ }
+}
+
+function countTools(payload: string): number | null {
+ // Tools come as `{"name":"...","description":"...","inputSchema":{...}}`.
+ // We don't fully parse SSE here — count occurrences of `"name":` inside a
+ // `"tools":[...]` array to avoid double-counting server/client name fields.
+ const idx = payload.indexOf('"tools"');
+ if (idx < 0) return null;
+ const slice = payload.slice(idx);
+ const matches = slice.match(/"name"\s*:/g);
+ if (!matches) return null;
+ // Subtract 1 for any spurious match outside the array — heuristic, good
+ // enough for UI display.
+ return Math.max(0, matches.length);
+}
+
+export async function disconnectMcp(key: string): Promise<void> {
+ try {
+ await openclaw(["mcp", "unset", key], { json: false });
+ } catch (err) {
+ // If the row was already gone, treat as success — UI calls this on a
+ // "Disconnect" button that should be idempotent.
+ if (err instanceof OpenClawError && err.exitCode !== 0) {
+ const msg = (err.stderr ?? "").toLowerCase();
+ if (msg.includes("not found") || msg.includes("unknown")) return;
+ }
+ throw err;
+ }
+}
+
+export async function setMcpBearer(
+ key: string,
+ url: string,
+ token: string,
+): Promise<void> {
+ // Project scoping is via the openclaw key namespace alone (project slug
+ // prefix). We deliberately do not write `codex.agents`: it only worked
+ // for the Codex app-server runtime and was silently ignored on other
+ // backends (DeepSeek, Claude, etc.), so its semantics were inconsistent.
+ // Per-project tokens + project-prefixed keys give us a uniform "soft
+ // isolation" model that's the same across every runtime.
+ const config = {
+ url,
+ transport: "streamable-http",
+ headers: { Authorization: `Bearer ${token}` },
+ };
+ await openclaw(["mcp", "set", key, JSON.stringify(config)], { json: false });
+}