← Back to all products

Agent Tool Schema Design Patterns

$39

Field guide and runnable examples for designing reliable tool/function schemas for LLM agents (MCP, OpenAI, Anthropic): descriptions, constraints, flat inputs, error contracts, annotations, and idempotency.

📁 11 files🏷 v1.0.0 (updated 2026-08-02)
Production-ready
✓ Instant download✓ Lifetime updates✓ MIT licensed✓ MIT license✓ Secure checkout (Stripe)

📋 What's Inside 11 files

  • GUIDE.md
  • LICENSE
  • README.md
  • examples/annotations.ts
  • examples/described.ts
  • examples/flat-vs-nested.ts
  • examples/idempotent.ts
  • package.json
  • src/result.ts
  • src/validate.ts
  • manifest.json

📁 File Structure 11 files

agent-tool-schema-patterns/
├── GUIDE.md
├── LICENSE
├── README.md
├── examples/
│ ├── annotations.ts
│ ├── described.ts
│ ├── flat-vs-nested.ts
│ ├── idempotent.ts
├── package.json
├── src/
│ ├── result.ts
│ ├── validate.ts
├── manifest.json

📖 Documentation Preview README excerpt

Agent Tool Schema Design Patterns

A field guide + runnable examples for designing reliable tool/function schemas

for LLM agents (MCP tools, OpenAI function calling, Anthropic tool use). Good

schemas are the single biggest lever on whether an agent calls your tool correctly.

Why schemas make or break agent tools

An agent only "sees" your tool through its name, description, and JSON schema.

If the schema is loose, the model hallucinates arguments, passes the wrong types,

or invents fields. If it's tight and well-described, the model calls it right the

first time. This pack distills the patterns that consistently reduce tool-call

failure rates.

The patterns

1. Describe every field for a model, not a human. Each parameter's description

should say what it is and how to choose a value. See examples/described.ts.

2. Constrain hard. Use enums, min/max, formats, and literal for fixed values

(e.g. quantity: literal(1)). Narrow types eliminate whole classes of bad calls.

3. Prefer flat inputs. Deeply nested objects raise error rates; flatten where

you can. See examples/flat-vs-nested.ts.

4. Return structured content + a stable error contract. Always return machine

codes ({ error: { code, message } }), never free-text errors. src/result.ts.

5. Annotate side effects. Mark read-only tools readOnlyHint: true and

side-effecting tools explicitly, so clients can gate them. examples/annotations.ts.

6. Make dangerous tools idempotent. Accept an idempotency key; identical calls

must not double-act. examples/idempotent.ts.

7. Validate at the boundary. Parse inputs with zod (or JSON Schema) before

your logic runs; reject smuggled fields. src/validate.ts.

Requirements

  • Node.js 18+
  • TypeScript 5+ (examples use zod; the principles apply to any schema language)
  • Quick start

    
    

    npm install

    npx tsx examples/described.ts # print a well-described schema as JSON Schema

    
    
    

    File tree

    
    

    src/

    result.ts # ok()/fail() helpers — structured content + stable error codes

    validate.ts # parse-at-the-boundary + reject-smuggled-fields helper

    examples/

    described.ts # good vs bad field descriptions (same tool)

    flat-vs-nested.ts # why flat inputs beat nested ones

    annotations.ts # readOnly / side-effect / idempotent annotations

    idempotent.ts # an idempotent side-effecting tool

    GUIDE.md # the full write-up with rationale + before/after metrics

    
    
    

    License

    MIT.


    ... preview truncated, see full README in product download.

    📄 Code Sample .ts preview

    examples/annotations.ts/** * annotations.ts — tool annotations that tell clients how safe a tool is. * * Clients (and humans) use these to decide what to auto-run vs confirm. Be honest: * marking a mutating tool read-only to avoid a confirmation prompt breaks trust. */ export const readOnlyTool = { // No side effects; safe to call freely (search, lookups, previews). readOnlyHint: true, openWorldHint: false, // does not reach external systems beyond your own data }; export const sideEffectingTool = { // Mutates state or reaches an external system (create, send, charge). readOnlyHint: false, destructiveHint: false, // set true if it deletes/overwrites irreversibly idempotentHint: true, // true only if repeated identical calls are safe openWorldHint: true, // talks to an external system (payment API, email, etc.) }; export const destructiveTool = { readOnlyHint: false, destructiveHint: true, // e.g. delete_resource — clients should always confirm idempotentHint: false, openWorldHint: true, };

    📅 Changelog

    v1.0.0 — Initial release. Last updated 2026-08-02.

    Purchases include lifetime updates. Check the product page for the latest version.

    📄 Product Preview

    Try the interactive reader and demo tools below, or get the full product with all content unlocked.

    📖 Interactive Reader (Free Preview)⚙ Try Demo Tools📦 Download Free Sample

    ❓ Frequently Asked Questions

    What license is this under?

    How do I download after purchase?

    Do I get updates?

    What if it doesn't work for me?

    Can I get a refund?

    Is there support?

    Buy Now — $39 Back to Products