Registering tool...
``` -------------------------------- ### Initialize in Astro Source: https://docs.mcp-b.ai/how-to/frameworks Import via script tag or load the IIFE directly in the layout head. ```astro ``` ```astro ``` -------------------------------- ### Initialize BrowserMcpServer Constructor Source: https://docs.mcp-b.ai/packages/webmcp-ts-sdk/reference Defines the signature for creating a new BrowserMcpServer instance. ```ts new BrowserMcpServer(serverInfo: Implementation, options?: BrowserMcpServerOptions) ``` -------------------------------- ### Selector Ranking Examples Source: https://docs.mcp-b.ai/packages/smart-dom-reader/reference Examples of CSS selectors categorized by their stability score for reliable element identification. ```css #unique-id ``` ```css [data-testid="submit"] ``` ```css [role="button"][aria-label="Submit"] ``` ```css input[name="email"] ``` ```css .form-container .submit-btn ``` -------------------------------- ### initializeWebModelContext(options?) Source: https://docs.mcp-b.ai/packages/global/reference Initializes the global adapter and replaces document.modelContext with a BrowserMcpServer instance. This function is idempotent and safe for SSR environments. ```APIDOC ## initializeWebModelContext(options?) ### Description Initializes the global adapter, replacing `document.modelContext` with a `BrowserMcpServer` instance. It is idempotent and performs a no-op in non-browser environments. ### Parameters - **options** (object) - Optional - Configuration object for the transport layer, including `tabServer` settings like `allowedOrigins`. ``` -------------------------------- ### Discover WebMCP tools Source: https://docs.mcp-b.ai/how-to/use-devtools-mcp List tools available on a webpage that has @mcp-b/global installed. ```text Navigate to https://webmcp.sh and list the available tools ``` -------------------------------- ### Initialize HTML for WebMCP Source: https://docs.mcp-b.ai/tutorials/first-tool Create the base HTML structure and load the WebMCP polyfill via a script tag. ```htmlLoading...
``` -------------------------------- ### Get tool descriptors Source: https://docs.mcp-b.ai/packages/webmcp-ts-sdk/reference Retrieves WebMCP producer tool descriptors for registered tools. ```ts const tools = await server.getTools(); const searchTool = tools.find((tool) => tool.name === 'search'); if (!searchTool) throw new Error('search is not available'); ``` -------------------------------- ### CLI Help Output Source: https://docs.mcp-b.ai/packages/webmcp-local-relay/reference Displays the available command-line options and flags for the relay. ```text webmcp-local-relay [options] --host, -H Bind host for local websocket relay (default: 127.0.0.1) --port, -p Preferred root port for the local relay cluster (default: 9333) --widget-origin Allowed host page origin(s), comma-separated (default: *) --allowed-origin Alias for --widget-origin --ws-origin Alias for --widget-origin --label Human-readable relay label reported during discovery --workspace Optional workspace name reported during discovery --relay-id Stable relay identifier reported during discovery --help, -h Show help ``` -------------------------------- ### Complete index.html for WebMCP Tool Source: https://docs.mcp-b.ai/tutorials/first-tool A full HTML boilerplate including the WebMCP polyfill and a basic tool registration script. ```htmlLoading...
``` -------------------------------- ### Initialize in Vanilla JS Source: https://docs.mcp-b.ai/how-to/frameworks Import via module bundler or include the IIFE script directly in HTML. ```typescript import '@mcp-b/global'; ``` ```html ``` -------------------------------- ### Import useWebMCPPrompt hook Source: https://docs.mcp-b.ai/packages/react-webmcp/reference Import the hook for registering MCP prompts. ```ts import { useWebMCPPrompt } from '@mcp-b/react-webmcp'; ``` -------------------------------- ### Troubleshoot Common Test Issues Source: https://docs.mcp-b.ai/how-to/test-native-and-polyfill Commands to resolve environment conflicts or installation issues during test execution. ```bash lsof -ti:4173 | xargs kill ``` ```bash pnpm --filter mcp-e2e-tests exec playwright install chromium ``` -------------------------------- ### useWebMCPContext(name, description, getValue) Source: https://docs.mcp-b.ai/packages/react-webmcp/reference A convenience wrapper for creating read-only context tools that automatically set appropriate hints. ```APIDOC ## useWebMCPContext(name, description, getValue) ### Description Registers a read-only context tool. This is a shorthand for useWebMCP with pre-configured hints (readOnly, idempotent). ### Parameters - **name** (string) - Required - Tool identifier - **description** (string) - Required - Description for AI assistants - **getValue** (function) - Required - Function returning the current context value: () => T ``` -------------------------------- ### Get Feedback Source: https://docs.mcp-b.ai/llms.txt Retrieves user feedback from your documentation, including page ratings and code snippet feedback. ```APIDOC ## Get Feedback ### Description Retrieves user feedback from your documentation, including page ratings and code snippet feedback. ### Method GET ### Endpoint /api/analytics/feedback ### Parameters #### Query Parameters - **start_date** (string) - Optional - The start date for filtering feedback. - **end_date** (string) - Optional - The end date for filtering feedback. ``` -------------------------------- ### Enable experimental browser features via CLI Source: https://docs.mcp-b.ai/how-to/debug-and-troubleshoot Launches Chrome with the necessary experimental flags to support native WebMCP features. ```bash google-chrome --enable-experimental-web-platform-features http://localhost:3000 ``` -------------------------------- ### Cleanup the WebMCP polyfill Source: https://docs.mcp-b.ai/packages/webmcp-polyfill/reference Restores previous document.modelContext and navigator.modelContextTesting property descriptors and resets the polyfill install state. ```ts import { cleanupWebMCPPolyfill } from '@mcp-b/webmcp-polyfill'; cleanupWebMCPPolyfill(); ``` -------------------------------- ### Register Chrome Extension Tools Source: https://docs.mcp-b.ai/packages/extension-tools/reference Demonstrates how to initialize an McpServer and register specific Chrome API tool classes in a background script. ```typescript import { TabsApiTools, BookmarksApiTools, StorageApiTools } from '@mcp-b/extension-tools'; import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; const server = new McpServer({ name: 'chrome-extension-server', version: '1.0.0', }); const tabsTools = new TabsApiTools(server, { listActiveTabs: true, createTab: true, closeTabs: true, }); tabsTools.register(); const bookmarksTools = new BookmarksApiTools(server, { getBookmarks: true, createBookmark: true, }); bookmarksTools.register(); ``` -------------------------------- ### Register Tool with npm Source: https://docs.mcp-b.ai/llms.txt Install the `@mcp-b/global` package via npm and then register a tool using `navigator.modelContext.registerTool()` in your TypeScript code. ```bash npm install @mcp-b/global ``` ```typescript import '@mcp-b/global'; navigator.modelContext.registerTool({ name: 'get_weather', description: 'Get weather for a city', inputSchema: { type: 'object', properties: { city: { type: 'string' } }, required: ['city'] }, handler: async ({ city }) => ({ content: [{ type: 'text', text: `Weather in ${city}: 72F, sunny` }] }) }); ``` -------------------------------- ### Get Assistant Conversations Source: https://docs.mcp-b.ai/llms.txt Retrieves AI assistant conversation history including queries, responses, cited sources, and categories. ```APIDOC ## Get Assistant Conversations ### Description Retrieves AI assistant conversation history including queries, responses, cited sources, and categories. ### Method GET ### Endpoint /api/analytics/assistant-conversations ### Parameters #### Query Parameters - **start_date** (string) - Optional - The start date for filtering conversations. - **end_date** (string) - Optional - The end date for filtering conversations. ``` -------------------------------- ### Initialize WebMCP and Render App Source: https://docs.mcp-b.ai/tutorials/first-react-tool The entry point for the application where the WebMCP polyfill is initialized before the React root is rendered. ```tsx import { initializeWebMCPPolyfill } from '@mcp-b/webmcp-polyfill'; import { StrictMode } from 'react'; import { createRoot } from 'react-dom/client'; import { App } from './App'; initializeWebMCPPolyfill(); createRoot(document.getElementById('root')!).render(Tool "say_hello" registered.
Executions: {helloTool.state.executionCount}
Last result:{' '} {helloTool.state.lastResult ? JSON.stringify(helloTool.state.lastResult) : 'none'}
{helloTool.state.error && (Error: {helloTool.state.error.message}
)}Executions: {counterTool.state.executionCount}