Skip to main content
Glama

invoice-parse

Extract structured line items, totals, and dates from invoice PDFs or images using a document URL.

Instructions

Extract structured line items, totals, and dates from an invoice or receipt. Cost: 3 credits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_urlYesURL to invoice PDF or image

Implementation Reference

  • Input schema definition for the 'invoice-parse' tool. Defines the tool's name, description, and input parameters (document_url).
    {
      name: "invoice-parse",
      description: "Extract structured line items, totals, and dates from an invoice or receipt. Cost: 3 credits.",
      inputSchema: {
        document_url: z.string().describe("URL to invoice PDF or image"),
      },
    },
  • src/index.ts:240-259 (registration)
    Server setup and tool registration. All capabilities (including invoice-parse) are dynamically registered as MCP tools using server.registerTool(). The handler calls the Suprsonic REST API with the capability name.
    function createServer(): McpServer {
      const server = new McpServer(
        { name: "suprsonic", version: "0.1.0" },
        { capabilities: { logging: {} } },
      );
    
      // Register each capability as an MCP tool
      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>);
          },
        );
      }
  • Generic HTTP handler that executes all tools including invoice-parse. It calls the Suprsonic REST API at /v1/agent with the capability name ('invoice-parse') and its parameters, then returns the result.
    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 are provided, and the description only mentions a cost. It fails to disclose whether the tool is read-only, if data is stored, or any authentication requirements. For a tool with no annotations, the description should cover these behavioral aspects.

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 extremely concise: two sentences that directly state the tool's action and a cost disclaimer. Every word is functional with no redundancy.

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

Completeness3/5

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

Given the low complexity (one parameter, no output schema, no annotations), the description provides a basic understanding. However, it lacks detail on return format, supported file types beyond 'PDF or image', and error behavior, making it merely adequate.

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 coverage is 100% with a clear description for 'document_url'. The tool description adds no additional semantic value for the parameter beyond what the schema already provides, meeting the baseline for high coverage.

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 uses a specific verb 'Extract' and clearly identifies the resource (invoices or receipts) and the data extracted (line items, totals, dates). It distinguishes from siblings by being focused solely on document parsing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use for extracting data from invoices/receipts and mentions a cost constraint, but does not explicitly state when to use this tool versus alternatives (e.g., 'documents' or 'search'). No guidance on exclusions.

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