Skip to main content
Glama

documents

Extract structured data from a URL or text by specifying what to find in plain language. Uses LLM analysis to convert unstructured content into structured information.

Instructions

Extract structured data from a URL or text content using LLM analysis. Cost: 3 credits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlNoURL to scrape and extract from
contentNoPre-scraped text to extract from
extraction_promptNoWhat to extract, in plain language

Implementation Reference

  • Schema definition for the 'documents' tool. Defines name, description ('Extract structured data from a URL or text content using LLM analysis. Cost: 3 credits.'), and inputSchema with optional 'url', 'content', and 'extraction_prompt' parameters.
    {
      name: "documents",
      description: "Extract structured data from a URL or text content using LLM analysis. Cost: 3 credits.",
      inputSchema: {
        url: z.string().optional().describe("URL to scrape and extract from"),
        content: z.string().optional().describe("Pre-scraped text to extract from"),
        extraction_prompt: z.string().optional().describe("What to extract, in plain language"),
      },
    },
  • Handler for the 'documents' tool (and all other tools). Registered via loop using server.registerTool; the handler is an async callback that delegates to callSuprsonic(cap.name, args), where cap.name is 'documents'.
    async (args: any): Promise<CallToolResult> => {
      return callSuprsonic(cap.name, args as Record<string, unknown>);
    },
  • src/index.ts:247-259 (registration)
    Registration of the 'documents' tool. All capabilities (including 'documents') are registered in a for-of loop via server.registerTool(cap.name, {description, inputSchema}, async handler).
    for (const cap of CAPABILITIES) {
      // Cast inputSchema to avoid TS2589 (excessively deep type instantiation from Zod chains)
      server.registerTool(
        cap.name,
        {
          description: cap.description,
          inputSchema: cap.inputSchema as any,
        },
        async (args: any): Promise<CallToolResult> => {
          return callSuprsonic(cap.name, args as Record<string, unknown>);
        },
      );
    }
  • The callSuprsonic helper function that all tool handlers delegate to. Makes an HTTP POST to the Suprsonic REST API with the capability name and params, then parses the response.
    async function callSuprsonic(capability: string, params: Record<string, unknown>): Promise<CallToolResult> {
      if (!API_KEY) {
        return {
          content: [{ type: "text", text: "Error: SUPRSONIC_API_KEY environment variable is not set. Get your key at https://suprsonic.ai/app/apis" }],
          isError: true,
        };
      }
    
      try {
        const resp = await fetch(`${BASE_URL}/v1/agent`, {
          method: "POST",
          headers: {
            "Authorization": `Bearer ${API_KEY}`,
            "Content-Type": "application/json",
          },
          body: JSON.stringify({ capability, params }),
        });
    
        const result = await resp.json() as any;
    
        // Handle non-envelope responses (401, 429, etc. return {"detail": ...})
        if (result.detail && result.success === undefined) {
          const msg = typeof result.detail === "object" ? (result.detail.title || result.detail.detail || JSON.stringify(result.detail)) : String(result.detail);
          return {
            content: [{ type: "text", text: `Error (HTTP ${resp.status}): ${msg}` }],
            isError: true,
          };
        }
    
        if (!result.success) {
          const errMsg = result.error?.detail || result.error?.title || "Request failed";
          return {
            content: [{ type: "text", text: `Error: ${errMsg}` }],
            isError: true,
          };
        }
    
        const text = JSON.stringify(result.data, null, 2);
        const meta = result.metadata
          ? `\n\n[Provider: ${(result.metadata as any).provider_used || "unknown"}, ${(result.metadata as any).response_time_ms || 0}ms, ${result.credits_used || 0} credits]`
          : "";
    
        return {
          content: [{ type: "text", text: text + meta }],
        };
      } catch (err) {
        return {
          content: [{ type: "text", text: `Network error: ${err instanceof Error ? err.message : String(err)}` }],
          isError: true,
        };
      }
    }
Behavior2/5

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

No annotations provided, so description carries full burden. Mentions cost of 3 credits but discloses no side effects, limitations, or operational details (e.g., whether it makes network calls, uses cache, or is idempotent). Minimal transparency.

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?

Single sentence with cost note, highly concise. Front-loaded with purpose. Every word earns its place.

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?

Tool has 3 parameters and no output schema; description lacks details on output format, parameter usage advice, and behavioral context. Incomplete for an extraction tool that could benefit from explaining what 'structured data' means or how to choose between url and content.

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 baseline is 3. Description hints at 'url or text content' but does not elaborate on parameters beyond schema. No contradiction, but adds no extra meaning.

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

Purpose5/5

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

Description clearly states verb (extract), resource (structured data from URL or text), and method (LLM analysis). It distinguishes from siblings like 'scrape' which extracts raw HTML, and 'search' for web search, by specifying structured data extraction via LLM.

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 guidance on when to use this tool vs alternatives like 'scrape' or 'search'. No prerequisites or exclusions mentioned. Implies usage for structured data extraction, but lacks explicit direction.

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/O-mega-Enterprise/suprsonic-mcp'

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