Skip to main content
Glama

Save Talonic Schema

talonic_save_schema

Save a custom schema to your Talonic workspace for reuse across multiple document extractions, ensuring consistent data extraction without redefining fields each time.

Instructions

Save a schema definition to the user's Talonic workspace so it can be reused across future extractions. Returns the saved schema with its newly assigned id and short_id.

USE WHEN:

  • The user asks to save a schema, store a template, or reuse the schema across docs.

  • You have iterated on a schema with the user and they confirmed it should be saved.

  • The user wants to standardise extraction across many documents of the same type.

DO NOT USE WHEN:

  • The user just wants to extract once with an inline schema (call talonic_extract directly with the schema inline).

  • The user has not confirmed the schema design (avoid creating clutter in their workspace).

DEFINITION FORMATS:

  • JSON Schema (most reliable): { type: "object", properties: { vendor_name: { type: "string" } } }

  • Flat key-type map: { vendor_name: "string", invoice_total: "number" } -- API normalises server-side. If you get a "no fields" error from the API, fall back to JSON Schema.

TIP: After saving, call talonic_extract with schema_id set to the returned id (UUID or SCH- short id) for consistent results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesHuman-readable name for the schema, e.g. 'Standard Invoice'.
definitionYesSchema definition. Most reliable: full JSON Schema {type:'object', properties:{...}}. Also accepted: a flat key-type map {field_name:'string', amount:'number'} which the API normalises.
descriptionNoOptional description of what this schema extracts and when to use it.

Implementation Reference

  • The handler function `handleSaveSchema` that executes the tool logic. It calls `talonic.schemas.create` with the provided name, definition, and optional description, returning the result as JSON.
    export async function handleSaveSchema(
      talonic: Talonic,
      args: { name: string; definition: Record<string, unknown>; description?: string },
    ): Promise<ToolResult> {
      try {
        const result = await talonic.schemas.create({
          name: args.name,
          definition: args.definition,
          ...(args.description !== undefined ? { description: args.description } : {}),
        })
        return jsonOk(result)
      } catch (err) {
        return toolError(err)
      }
    }
  • The function `registerSaveSchema` that registers the tool with name "talonic_save_schema" on the MCP server, including its input schema (zod) and description.
    export function registerSaveSchema(server: McpServer, talonic: Talonic): void {
      server.registerTool(
        "talonic_save_schema",
        {
          title: "Save Talonic Schema",
          description: DESCRIPTION,
          inputSchema,
        },
        async (args) => handleSaveSchema(talonic, args),
      )
    }
  • Input schema definition using zod: `name` (string, required), `definition` (record<string, unknown>, required), and `description` (optional string).
    const inputSchema = {
      name: z.string().min(1).describe("Human-readable name for the schema, e.g. 'Standard Invoice'."),
      definition: z
        .record(z.string(), z.unknown())
        .describe(
          "Schema definition. Most reliable: full JSON Schema {type:'object', properties:{...}}. Also accepted: a flat key-type map {field_name:'string', amount:'number'} which the API normalises.",
        ),
      description: z
        .string()
        .optional()
        .describe("Optional description of what this schema extracts and when to use it."),
    }
  • `ToolSuccessResult` type used as the return envelope for successful handler execution.
    export interface ToolSuccessResult {
      content: Array<{ type: "text"; text: string }>
      [key: string]: unknown
    }
  • `ToolErrorResult` type used as the return envelope for errors (sets isError: true).
    export interface ToolErrorResult {
      content: Array<{ type: "text"; text: string }>
      isError: true
      [key: string]: unknown
    }
Behavior4/5

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

No annotations are provided, so the description carries full burden. It discloses that the tool saves to workspace, returns id and short_id, normalizes flat maps into JSON Schema, and provides a fallback tip. It does not mention permissions or duplicate handling, but overall sufficiently discloses key behaviors.

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 well-structured with clear headings (USE WHEN, DO NOT USE WHEN, DEFINITION FORMATS, TIP). It is slightly lengthy but every section adds value; could be slightly more concise but still effective.

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

Completeness4/5

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

Despite no output schema, the description explains what is returned (id and short_id). It covers usage scenarios, format guidance, and integration tip with talonic_extract. Missing details on error handling or duplicate names, but adequate for the tool's complexity.

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?

Schema description coverage is 100% (all parameters documented). The description adds extra context about accepted definition formats (JSON Schema vs flat map) and normalization behavior, plus a fallback tip for 'no fields' errors, going beyond the schema descriptions.

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?

The description clearly states the tool saves a schema definition to the user's Talonic workspace for reuse across extractions, and returns the saved schema with id and short_id. It explicitly distinguishes from sibling tools like talonic_extract by providing usage guidelines.

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

Usage Guidelines5/5

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

Includes explicit 'USE WHEN' and 'DO NOT USE WHEN' sections that tell the agent when to save a schema vs when to call talonic_extract directly with inline schema, and cautions against saving without user confirmation.

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/talonicdev/talonic-mcp'

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