Skip to content

The Claude connector

Two commands, and Claude can call your API. Install the SDK and the MCP server oryva wrote, in a virtual environment:

python3 -m venv .venv && . .venv/bin/activate
pip install out/ledger/python out/ledger/mcp

Then add the server to Claude Code, with your API's credential:

claude mcp add ledger -e LEDGER_API_KEY=your-key -- ledger-mcp

Ask Claude to list your customers, and it calls customers_list. MCP is the protocol Claude and other agents use to call tools. Without an oryva key, the server is free for APIs of up to 50 operations.

The server

The mcp target is a Python package that wraps the Python SDK. It has one tool per API method, named <resource>_<method>, such as customers_list. Its README lists every tool.

The package and its command take the Python SDK's distribution name with -mcp added, here ledger-mcp. The server speaks MCP over stdio. It reads credentials from the same environment variables as the SDK, such as LEDGER_API_KEY, and LEDGER_BASE_URL points it at another host.

Each tool tells the agent whether it only reads, whether it destroys data, and whether it is safe to repeat. oryva works that out from the HTTP method, and x-oryva-agent in the spec overrides it. The spec's agent hints go into the tool's description.

Claude Desktop and other clients

Clients that start servers from a JSON config take an entry under mcpServers. If the client doesn't find ledger-mcp on PATH, give its full path:

{
  "mcpServers": {
    "ledger": {
      "command": "ledger-mcp",
      "env": { "LEDGER_API_KEY": "your-key" }
    }
  }
}

To serve many people, each with their own account and nothing to install, run the server in hosted mode. They add it in Claude by URL, as a custom connector.

Any API size

One tool per method suits a small API. On a large one, the tool definitions fill the agent's context before it does any work: Stripe's 604 methods would take more than 800,000 tokens.

So oryva estimates the size of the definitions when it generates the server. Past a budget of 10,000 tokens, the server offers three tools that reach every method instead:

  • search finds methods by words in their names, summaries and descriptions.
  • describe returns one method's description, agent hints and input schema, and whether it is read-only, destructive or idempotent.
  • call runs one method with its arguments. A destructive method runs only with confirm: true. Without it, call says what would happen and how to confirm.

Set the budget in oryva.yml. tool_budget: 0 always serves the three tools:

targets:
  mcp: { out: sdks/mcp, tool_budget: 0 }

The server's README says which kind it is. Hosted mode and the Slack app work with either.

What tools return

Tool results are JSON.

  • A list tool returns one page and a next_page object. Pass its entries as arguments to get the next page.
  • A stream tool reads up to max_events events, 10 by default, then closes the stream.
  • A binary response is saved to a file in LEDGER_MCP_OUTPUT_DIR, a temporary directory by default. The tool returns the file's path and size.

Check the tools

Agents trip over tools with short descriptions, destructive tools that aren't marked, and tool lists that eat the context. oryva eval finds those problems in any MCP server, and can run real tasks with Claude to measure the pass rate.

A task file says how to start the server and what to ask:

server:
  command: ledger-mcp
  env:
    LEDGER_API_KEY: ${LEDGER_API_KEY:-test}
tasks:
  - id: find-customer
    prompt: Find the customer whose email is c3@example.com and tell me their ID.
    expect:
      tools_called: [customers_list]
      max_tool_errors: 0

Lint the tools. This needs no Anthropic API key:

oryva eval tasks.yaml --lint-only
Lint: 17 tools, 21 findings (0 errors)
  warn   customers_create                  description-short           description is 18 characters, under 40: "Create a customer."
  ...
Context cost: 7021 characters, about 1755 tokens

Without --lint-only, oryva eval also runs the tasks against whatever API the server is set up to call. It reports the pass rate, tokens, tool errors and recoveries, and needs ANTHROPIC_API_KEY. The command line reference describes the task file.