Skip to main content
Glama

get-context-info

Retrieve detailed information for a browser instance using its context ID. Inspect browser state, attributes, and properties to aid debugging or monitoring in real-time.

Instructions

Gets detailed information about a specific browser instance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextIdYesID of the browser to inspect

Implementation Reference

  • Registration of the 'get-context-info' tool via server.tool(), defining its schema (contextId: z.string()) and binding it to the handler function.
    // Get browser info tool
    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
          };
        }
      }
    );
  • Handler function that retrieves browser context info using contextManager.getContext(), gets shared browser info, and returns a JSON response with id, type, displayName, metadata, timestamps, isActive, currentUrl, and shared browser details.
    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 tool: requires a 'contextId' string parameter used to identify which browser context to inspect.
    {
      contextId: z.string().describe('ID of the browser to inspect')
    },
  • ContextManager.getContext() method used by the handler to look up a context instance by ID, updating lastUsedAt timestamp and database on access.
    getContext(contextId: string): ContextInstance | null {
      const contextInstance = this.contexts.get(contextId);
      if (contextInstance) {
        contextInstance.lastUsedAt = new Date();
        // Update database timestamp
        const db = getScreenshotDB();
        db.updateBrowserLastUsed(contextId); // TODO: rename to updateContextLastUsed
      }
      return contextInstance || null;
    }
  • ContextManager.getSharedBrowserInfo() method used by the handler to retrieve shared browser details (type, createdAt, contextCount, cdpEndpoint).
    getSharedBrowserInfo(): SharedBrowserInstance | null {
      return this.sharedBrowser;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It discloses no behavioral traits such as what happens with invalid contextId, whether it is read-only, or what 'detailed information' entails. This is insufficient for safe agent usage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that conveys the core purpose without extraneous words. However, it could benefit from slightly more detail without becoming verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simplicity of the tool (1 parameter, no output schema), the description is adequate but incomplete. It fails to explain what constitutes 'detailed information' or any side effects, which would be important for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% for the single parameter 'contextId', and its schema description is adequate ('ID of the browser to inspect'). The tool description adds no additional meaning beyond the schema, meeting the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'gets' and the resource 'detailed information about a specific browser instance'. It distinguishes from siblings such as 'list-browsers' which lists all instances, but does not differentiate from 'get-context-stats'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No usage guidelines are provided; the description does not indicate when to use this tool versus alternatives like 'get-context-stats' or 'list-browsers', nor does it mention prerequisites or context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ESnark/blowback'

If you have feedback or need assistance with the MCP directory API, please join our Discord server