Skip to main content
Glama
tanamurayuuki

Gemini URL Context & Search MCP Server

url_context_extract

Extract structured content from web URLs using Gemini AI, returning JSON with page text, summaries, and metadata for analysis or processing.

Instructions

Extract content from URLs using Gemini AI and return structured JSON with pages, answer, and metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
maxCharsPerPageNoMaximum characters per page (optional, defaults to 8000)
modelNoGemini model name to use (optional, defaults to gemini-2.0-flash-exp)
queryNoOptional query to guide content extraction and summary
urlsYesArray of URLs to extract content from

Implementation Reference

  • Core implementation of the tool logic: processes URLs, invokes GenAI adapter to extract context, constructs Page objects and ExtractContentResult.
    async execute(
      urls: Url[],
      query?: string,
      model?: ModelName,
      maxCharsPerPage: number = 8000
    ): Promise<ExtractContentResult> {
      const modelName = model || ModelName.create();
      
      const response = await this.genAI.generateUrlContextJson({
        urls: urls.map(url => url.toString()),
        query,
        model: modelName.toString(),
        maxCharsPerPage
      });
    
      const pages = response.pages.map(pageData => 
        Page.create(
          Url.create(pageData.url),
          pageData.title,
          pageData.text,
          pageData.images,
          maxCharsPerPage
        )
      );
    
      return ExtractContentResult.create(
        pages,
        response.answer,
        response.url_context_metadata
      );
    }
  • MCP CallToolRequest handler specifically for 'url_context_extract': validates params, creates domain URLs, invokes ExtractContentUseCase, serializes result to JSON.
    if (request.params.name === 'url_context_extract') {
      try {
        const { urls, query, model, maxCharsPerPage } = request.params.arguments as {
          urls: string[];
          query?: string;
          model?: string;
          maxCharsPerPage?: number;
        };
    
        if (!Array.isArray(urls) || urls.length === 0) {
          throw new McpError(
            ErrorCode.InvalidParams,
            'urls must be a non-empty array of strings'
          );
        }
    
        // Validate and create domain objects
        const urlObjects = urls.map(url => {
          try {
            return Url.create(url);
          } catch (error) {
            throw new McpError(
              ErrorCode.InvalidParams,
              `Invalid URL: ${url}. ${(error as Error).message}`
            );
          }
        });
    
        const modelName = model ? ModelName.create(model) : ModelName.create();
        const maxChars = maxCharsPerPage || 8000;
    
        // Execute use case
        const result = await this.useCase.execute(urlObjects, query, modelName, maxChars);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result.toJSON(), null, 2),
            },
          ],
        };
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to extract URL content: ${(error as Error).message}`
        );
      }
    }
  • Input schema definition for the 'url_context_extract' tool.
    inputSchema: {
      type: 'object',
      properties: {
        urls: {
          type: 'array',
          items: { type: 'string' },
          description: 'Array of URLs to extract content from',
        },
        query: {
          type: 'string',
          description: 'Optional query to guide content extraction and summary',
        },
        model: {
          type: 'string',
          description: 'Gemini model name to use (optional, defaults to gemini-2.0-flash-exp)',
        },
        maxCharsPerPage: {
          type: 'number',
          description: 'Maximum characters per page (optional, defaults to 8000)',
        },
      },
      required: ['urls'],
    },
  • src/index.ts:45-72 (registration)
    Tool registration in the ListToolsRequest handler, defining name, description, and input schema.
    {
      name: 'url_context_extract',
      description:
        'Extract content from URLs using Gemini AI and return structured JSON with pages, answer, and metadata',
      inputSchema: {
        type: 'object',
        properties: {
          urls: {
            type: 'array',
            items: { type: 'string' },
            description: 'Array of URLs to extract content from',
          },
          query: {
            type: 'string',
            description: 'Optional query to guide content extraction and summary',
          },
          model: {
            type: 'string',
            description: 'Gemini model name to use (optional, defaults to gemini-2.0-flash-exp)',
          },
          maxCharsPerPage: {
            type: 'number',
            description: 'Maximum characters per page (optional, defaults to 8000)',
          },
        },
        required: ['urls'],
      },
    },
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 of behavioral disclosure. It mentions using Gemini AI and returning structured JSON, but lacks details on rate limits, authentication needs, error handling, or what 'extract content' entails (e.g., web scraping, API calls). For a tool with no annotation coverage, this is a significant gap in transparency.

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, efficient sentence that front-loads the core purpose. It avoids unnecessary words and directly communicates the tool's function. However, it could be slightly more structured by separating key components (e.g., input, process, output) for clarity.

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 complexity (AI-powered extraction with 4 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't explain the output structure (what 'pages, answer, and metadata' contain), error cases, or behavioral traits like rate limits. For a tool with no structured support, the description should provide more context to be fully helpful.

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?

The schema description coverage is 100%, so the schema already documents all four parameters (urls, query, model, maxCharsPerPage) with descriptions. The tool description adds no additional parameter semantics beyond what's in the schema, such as examples or constraints. With high schema coverage, 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 clearly states the tool's purpose: 'Extract content from URLs using Gemini AI and return structured JSON with pages, answer, and metadata.' It specifies the verb (extract), resource (content from URLs), technology used (Gemini AI), and output format (structured JSON). However, it doesn't explicitly differentiate from the sibling tool 'google_search', which likely serves a different purpose (searching vs. extracting).

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 no guidance on when to use this tool versus alternatives. It doesn't mention the sibling tool 'google_search' or any other tools, nor does it specify prerequisites, exclusions, or typical use cases. The agent must infer usage from the purpose alone.

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/tanamurayuuki/MCP-URLcontext'

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