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;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.0.0

TDQS

C2.9/5.0
Behavior2/5

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

No annotations are provided, so the description carries full responsibility for disclosing behavioral traits. It only says 'gets detailed information,' which is the bare operation; it does not clarify what information is included, whether the call is read-only, or what errors or edge cases may occur.

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 short sentence with no filler, and the key action is front-loaded. It is concise, though slightly vague by using 'detailed information' without elaboration.

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

Completeness2/5

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

With no output schema, the description should convey what kind of detailed information the agent will receive, but it does not. It also leaves ambiguity with the sibling get-context-stats, making the definition incomplete for an agent deciding which tool to invoke.

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 description coverage is 100%, and the single required parameter contextId is already described as 'ID of the browser to inspect.' The description adds no additional semantic meaning beyond the schema, so the baseline score of 3 is appropriate.

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 states a clear verb ('gets') and resource ('detailed information about a specific browser instance'), so the core action is understandable. However, it does not distinguish this from get-context-stats, which sounds closely related, so it misses the full sibling-differentiation bar.

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?

The description gives no guidance on when to use this tool instead of alternatives like get-context-stats, list-browsers, or get-context-info-related tools. There are no conditions, exclusions, or references to sibling tools.

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