feat(frontend): WebMCP tools for Capgo console AI agents - #3266
Conversation
Register document.modelContext tools so in-browser AI agents can read console context, list apps/channels/bundles, and navigate supported routes. Feature-detect WebMCP, gate authenticated tools behind session, and unregister tools on route change via AbortController. Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
|
@coderabbitai review |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
- Import useWebMcp explicitly in App.vue for vue-tsc - Cast route params to a string map for typed route context parsing - Extract shared schema/auth/list helpers to webmcpConsoleHelpers - Collapse duplicate navigate path builders in webmcpConsolePaths Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
|
@coderabbitai review |
|
@coderabbitai review |
|



Summary (AI generated)
document.modelContext.registerTool()(with fallback feature detection for deprecatednavigator.modelContext).useWebMcp()from the app shell; tools re-register on route/auth changes and unregister viaAbortControlleron navigation/unmount.Motivation (AI generated)
Browser AI agents (Chrome WebMCP / W3C webmachinelearning/webmcp) need a standard way to discover and invoke console capabilities without scraping the DOM. This registers read-mostly tools that reuse the same client paths the UI already uses.
Business Impact (AI generated)
Signed-in users can operate the Capgo console through compatible in-browser agents (navigation, listing apps/channels/bundles, reading context). No API keys or session tokens are exposed. Unsupported browsers are unaffected.
Tools (AI generated)
console_get_contextconsole_list_organizationsconsole_list_appsconsole_list_channelsconsole_list_bundlesconsole_navigatedashboard,apps, app tabs, bundle/channel detail, settings)Authenticated tools are only registered when a session exists. Data tools verify app access via
organizationStore.getOrgByAppId().Test Plan (AI generated)
bunx vitest run tests/webmcp.unit.test.ts— feature detection + route builderchrome://flags→ WebMCP / document-model-context), sign in to the consoleawait document.modelContext.getTools()lists the tools aboveconsole_get_context— returns path + org/app context matching the visible pageconsole_list_apps— returns apps for the active orgconsole_navigatewith{ "page": "app_channels", "appId": "<your-app>" }— SPA navigates to channelsconsole_get_contextremains registeredGenerated with AI
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.