Skip to main content
Glama
nanameru

URL-Context-MCP MCP

by nanameru

analyze_urls

Analyze and summarize content from up to 20 URLs using Google Gemini's URL Context capability, with optional custom instructions and model selection.

Instructions

Analyze and summarize the content of given URLs using Google Gemini URL Context. Provide an optional instruction and model.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlsYesOne URL string or an array of URLs (max 20)
instructionNoOptional instruction or task description
modelNoGemini model id (e.g., gemini-2.5-flash)
use_google_searchNoEnable grounding with Google Search (adds google_search tool alongside URL context)

Implementation Reference

  • Core handler function that calls the Gemini API with URL context tools to analyze the provided URLs, constructs the prompt, handles responses, and appends source metadata.
    async function callGeminiUrlContext(params: AnalyzeUrlsParams): Promise<string> {
      const apiKey = process.env.GOOGLE_API_KEY;
      if (!apiKey) {
        throw new Error("GOOGLE_API_KEY is not set");
      }
    
      const model = params.model ?? "gemini-2.5-flash";
      const endpoint = `https://generativelanguage.googleapis.com/v1beta/models/${encodeURIComponent(model)}:generateContent`;
    
      const promptText = `Guidelines:\n- Strictly use URL Context to retrieve ONLY the provided URLs\n- Do NOT perform web search or include external sources beyond these URLs\n- If a URL cannot be retrieved, note it explicitly\n\nTask:${params.instruction ? `\n${params.instruction}` : `\nProvide a concise, well-structured summary, key facts, and citations`}\n\nAnalyze these URLs:\n${params.urls.join("\n")}`;
    
      const tools: any[] = [{ url_context: {} }];
      if (params.useGoogleSearch) {
        tools.push({ google_search: {} });
      }
    
      const body = {
        contents: [
          {
            parts: [{ text: promptText }],
          },
        ],
        tools,
      } as const;
    
      const response = await fetch(endpoint + `?key=${encodeURIComponent(apiKey)}`, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify(body),
      });
    
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`Gemini API error ${response.status}: ${text}`);
      }
    
      const json = (await response.json()) as any;
      // Try to get the primary text output
      const candidate = json?.candidates?.[0];
      const textOut = candidate?.content?.parts?.map((p: any) => p?.text).filter(Boolean).join("\n");
      // Collect URL context metadata for transparency if present
      const urlMeta: Array<{ retrieved_url?: string; url_retrieval_status?: string }> |
        undefined = candidate?.url_context_metadata?.url_metadata;
      const sourcesSection = Array.isArray(urlMeta) && urlMeta.length > 0
        ? "\n\nSources (URL Context):\n" +
          urlMeta
            .map((m) => `- ${m.retrieved_url ?? "(unknown)"} [${m.url_retrieval_status ?? ""}]`)
            .join("\n")
        : "";
    
      if (textOut) {
        return textOut + sourcesSection;
      }
      // Fallback: return raw JSON if text not found
      return JSON.stringify(json, null, 2);
    }
  • src/index.ts:169-203 (registration)
    Tool registration definition including name, description, and detailed inputSchema for listTools response.
      name: "analyze_urls",
      description:
        "Analyze and summarize the content of given URLs using Google Gemini URL Context. Provide an optional instruction and model.",
      inputSchema: {
        type: "object",
        properties: {
          urls: {
            description: "One URL string or an array of URLs (max 20)",
            oneOf: [
              { type: "string" },
              {
                type: "array",
                items: { type: "string" },
                minItems: 1,
                maxItems: 20,
              },
            ],
          },
          instruction: {
            type: "string",
            description: "Optional instruction or task description",
          },
          model: {
            type: "string",
            description: "Gemini model id (e.g., gemini-2.5-flash)",
          },
          use_google_search: {
            type: "boolean",
            description:
              "Enable grounding with Google Search (adds google_search tool alongside URL context)",
          },
        },
        required: ["urls"],
      },
    },
  • TypeScript type definition for the parameters accepted by the analyze_urls tool handler.
    type AnalyzeUrlsParams = {
      urls: string[];
      instruction?: string;
      model?: string;
      useGoogleSearch?: boolean;
    };
  • Dispatcher handler within the CallToolRequestSchema that validates inputs, normalizes the urls array, and invokes the core analyze_urls handler.
    if (name === "analyze_urls") {
      const {
        urls: rawUrls,
        instruction,
        model,
        use_google_search,
      } = (args ?? {}) as {
        urls?: string | string[];
        instruction?: string;
        model?: string;
        use_google_search?: boolean;
      };
      const urls = Array.isArray(rawUrls)
        ? rawUrls
        : typeof rawUrls === "string"
        ? [rawUrls]
        : [];
      if (urls.length === 0) {
        throw new Error("'urls' must be provided as a string or a non-empty array");
      }
      if (urls.length > 20) {
        throw new Error("Maximum of 20 URLs supported");
      }
      const text = await callGeminiUrlContext({
        urls,
        instruction,
        model,
        useGoogleSearch: Boolean(use_google_search),
      });
      return { content: [{ type: "text", text }] };
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the tool 'analyzes and summarizes' but doesn't describe what that entails (e.g., what format the summary takes, whether it extracts specific information types, or any limitations like rate limits, authentication needs, or content restrictions). The description is minimal and lacks operational context.

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, efficient sentence that states the core purpose and mentions key optional parameters. Every word earns its place with no redundancy or fluff, making it appropriately front-loaded and concise.

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 tool has 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (summary format, structure, or content), any behavioral constraints, or how it differs from the sibling 'google_search' tool. For a content analysis tool with multiple parameters, this leaves significant gaps for an AI 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 description coverage is 100%, so the schema already documents all four parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema (e.g., it doesn't explain how 'instruction' affects analysis or what 'use_google_search' practically does). Baseline 3 is appropriate when the schema does the heavy lifting.

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 action ('analyze and summarize') and resource ('content of given URLs'), and mentions the technology used ('Google Gemini URL Context'). It distinguishes from the sibling 'google_search' tool by focusing on URL content analysis rather than web search. However, it doesn't explicitly contrast with the sibling tool's functionality.

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 like 'google_search'. It mentions the sibling tool name in the context of a parameter ('use_google_search'), but offers no explicit when/when-not instructions or comparison between the tools.

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/nanameru/url-context-mcp'

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