get-context-info
Retrieve detailed information about a specific browser instance by providing its context ID, enabling inspection of browser state and configuration.
Instructions
Gets detailed information about a specific browser instance
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contextId | Yes | ID of the browser to inspect |
Implementation Reference
- Handler function that retrieves detailed information about a specific browser context. Fetches the browser object, current URL, activity status, and shared browser details, then returns formatted JSON response.async ({ contextId }) => { try { const browser = contextManager.getContext(contextId); if (!browser) { return { content: [ { type: 'text', text: `Browser not found: ${contextId}` } ], isError: true }; } // Get shared browser info for CDP endpoint const sharedBrowserInfo = contextManager.getSharedBrowserInfo(); const browserInfo = { id: browser.id, type: browser.type, displayName: browser.displayName, metadata: browser.metadata, createdAt: browser.createdAt, lastUsedAt: browser.lastUsedAt, isActive: contextManager.hasContext(contextId), currentUrl: browser.page.url(), sharedBrowser: sharedBrowserInfo ? { type: sharedBrowserInfo.type, createdAt: sharedBrowserInfo.createdAt, contextCount: sharedBrowserInfo.contextCount, cdpEndpoint: sharedBrowserInfo.cdpEndpoint } : null }; return { content: [ { type: 'text', text: JSON.stringify(browserInfo, null, 2) } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); Logger.error(`Failed to get browser info for ${contextId}:`, error); return { content: [ { type: 'text', text: `Failed to get browser info: ${errorMessage}` } ], isError: true }; } }
- Input schema for the 'get-context-info' tool, requiring a contextId string parameter.{ contextId: z.string().describe('ID of the browser to inspect') },
- src/tools/browser-manager-tools.ts:220-284 (registration)Registration of the 'get-context-info' tool using server.tool(), including name, description, input schema, and handler function.server.tool( 'get-context-info', 'Gets detailed information about a specific browser instance', { contextId: z.string().describe('ID of the browser to inspect') }, async ({ contextId }) => { try { const browser = contextManager.getContext(contextId); if (!browser) { return { content: [ { type: 'text', text: `Browser not found: ${contextId}` } ], isError: true }; } // Get shared browser info for CDP endpoint const sharedBrowserInfo = contextManager.getSharedBrowserInfo(); const browserInfo = { id: browser.id, type: browser.type, displayName: browser.displayName, metadata: browser.metadata, createdAt: browser.createdAt, lastUsedAt: browser.lastUsedAt, isActive: contextManager.hasContext(contextId), currentUrl: browser.page.url(), sharedBrowser: sharedBrowserInfo ? { type: sharedBrowserInfo.type, createdAt: sharedBrowserInfo.createdAt, contextCount: sharedBrowserInfo.contextCount, cdpEndpoint: sharedBrowserInfo.cdpEndpoint } : null }; return { content: [ { type: 'text', text: JSON.stringify(browserInfo, null, 2) } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); Logger.error(`Failed to get browser info for ${contextId}:`, error); return { content: [ { type: 'text', text: `Failed to get browser info: ${errorMessage}` } ], isError: true }; } } );
- src/index.ts:81-83 (registration)Invocation of registerBrowserManagerTools which registers the 'get-context-info' tool among others to the MCP server.// Register new context manager tools const contextManager = registerBrowserManagerTools(server);