Skip to main content
Glama

get-context

Extracts website context for generating accurate Playwright test cases by analyzing web page structure and elements.

Instructions

Get the website context which would be used to write the testcase

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that implements the 'get-context' tool logic. It retrieves the current state, processes messages (DOM, Text, Interaction, Image), formats them into content blocks (text or image), limits to 20k characters, updates the state by removing processed messages, and returns the content with note on remaining if any.
    async () => {
      posthogServer.capture({
        distinctId: getUserId(),
        event: 'get_context',
      });
    
      const state = getState();
    
      if (state.messages.length === 0) {
        return {
          content: [
            {
              type: "text",
              text: `No messages available`
            }
          ]
        };
      }
    
      const content: any = [];
    
      let totalLength = 0;
      let messagesProcessed = 0;
    
      while (messagesProcessed < state.messages.length && totalLength < 20000) {
        const message = state.messages[messagesProcessed];
        let currentContent = message.content
        if (message.type === 'DOM') {
          currentContent = `DOM: ${message.content}`;
        } else if (message.type === 'Text') {
          currentContent = `Text: ${message.content}`;
        } else if (message.type === 'Interaction') {
          const interaction = JSON.parse(message.content);
          delete interaction.eventId;
          delete interaction.dom;
          delete interaction.elementUUID;
          if (interaction.selectors) {
            interaction.selectors = interaction.selectors.slice(0, 10);
          }
    
          currentContent = JSON.stringify(interaction);
        } else if (message.type === 'Image') {
          currentContent = message.content;
        }
    
        totalLength += currentContent.length;
    
        const item: any = {}
        const isImage = message.type === 'Image';
        if (isImage) {
          item.type = "image";
          item.data = message.content;
          item.mimeType = "image/png";
        } else {
          item.type = "text";
          item.text = currentContent;
        }
        content.push(item);
        messagesProcessed++;
      }
    
      // Remove processed messages
      state.messages.splice(0, messagesProcessed);
      updateState(page, state);
    
      const remainingCount = state.messages.length;
      if (remainingCount > 0) {
        content.push({
          type: "text",
          text: `Remaining ${remainingCount} messages, please fetch those in next requests.\n`
        });
      }
    
      return {
        content
      };
    }
  • Registers the 'get-context' MCP tool with name, description, and empty input schema (no parameters). The handler is provided inline.
    server.tool(
      "get-context",
      "Get the website context which would be used to write the testcase",
      {},
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool retrieves website context for testcase writing, but doesn't disclose behavioral traits like whether it's read-only, requires browser initialization, has side effects, or what format the context is returned in. This leaves significant gaps for an agent to understand how to use it effectively.

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

Conciseness5/5

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

The description is a single, clear sentence that efficiently conveys the core purpose without any wasted words. It's front-loaded with the main action and context, making it easy for an agent to parse quickly.

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?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'website context' entails (e.g., metadata, state, or specific data), how it relates to sibling tools, or what the return value looks like. For a tool in a browser automation context with siblings like get-full-dom, more detail is needed to guide proper usage.

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

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, focusing instead on the tool's purpose. This meets the baseline for tools with no parameters, as it doesn't add unnecessary details.

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 tool's purpose: 'Get the website context which would be used to write the testcase.' It specifies the verb ('Get') and resource ('website context'), and indicates its use for testcase writing. However, it doesn't explicitly differentiate from sibling tools like get-full-dom or get-screenshot, which might provide related but different website information.

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 provides minimal guidance by implying usage in testcase writing contexts, but it lacks explicit when-to-use instructions, alternatives, or exclusions compared to sibling tools. There's no mention of prerequisites, such as whether init-browser must be called first, or how this differs from get-full-dom for DOM retrieval.

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/Ashish-Bansal/playwright-mcp'

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