Quick Start
1
Load a spec and start the agent
Every operation in the spec becomes a tool the agent can call directly.
2
Install httpx
httpx is needed at call time.PyYAML (already a dependency).How It Works
get_tools() returns one callable OpenAPIOperation per spec operation. When the agent calls one, it builds the request, attaches auth headers, sends it with httpx, and returns the parsed JSON.
Loading a Spec
Provide the spec exactly one of three ways — otherwise aValueError is raised.
Configuration Options
All constructor arguments are keyword-only.
Exactly one of
spec_dict, spec_str, spec_url is required.
Methods
OpenAPIOperation
Each tool returned byget_tools() is an OpenAPIOperation.
Attributes:
name, description, method, path, base_url, parameters, body_schema, body_param, input_schema, auth, header_provider, timeout.
Auth Shapes
Theauth dict is keyed by type.
Safety Behaviour
The toolset refuses unsafe requests and never fetches arbitrary URLs while parsing.
Framework-injected kwargs are stripped on all paths — free-form, declared, and composed — so durable-execution metadata never leaks into a strict API.
Body Shapes
EveryrequestBody schema falls into one of three modes, decided in this order.
Framework-injected kwargs are dropped in every mode.
Common Patterns
Restrict the tool surface to read-only operations:allOf — no special configuration:
name and age are advertised to the model and forwarded to the API — a composed spec works with no extra wiring.
Force a base URL when the spec has a relative servers: entry:
OpenAPI Toolset vs MCP
Both expose external tools to an agent; reach for the toolset when the API already has a spec.
A workaround existed (
MCP("npx -y @ivotoby/openapi-mcp-server ...")); the toolset removes the extra process and the npx dependency, and adds first-class tool_filter and tool_name_prefix.
Best Practices
Always use https when sending auth
Always use https when sending auth
The toolset refuses to attach credentials to an
http:// endpoint. If the
spec declares a cleartext server, pass an https:// base_url explicitly.
A same-host scheme downgrade — a spec supplying http:// for an origin you
configured as https:// — is refused too, so a token never travels in the
clear.Filter to the operations the agent actually needs
Filter to the operations the agent actually needs
A large spec can generate dozens of tools. Use
tool_filter to keep only
read-only or task-relevant operations so the model isn’t overwhelmed.Prefix tools when combining specs
Prefix tools when combining specs
Two specs may both define
get_users. Set a distinct tool_name_prefix
per toolset so names stay unique on one agent.Trust the origin pin when pointing at a spec you don't control
Trust the origin pin when pointing at a spec you don't control
When you point the toolset at a spec URL you do not control, the spec — not
just the model — can try to relocate a call. The toolset pins every
credentialed request to your configured origin’s host and scheme, so an
absolute path in the spec cannot silently send your token somewhere else.
Nothing to do — this is on by default; the tool returns a refusal message
the model can see.
Preview requests in tests with build_request
Preview requests in tests with build_request
build_request(**args) binds arguments to URL, headers and body without
any HTTP call — assert the assembled request in a unit test.Related
MCP
Front external tools as an MCP server
Tools
Build and register agent tools
Toolsets
Group related tools together
Tool Config
Configure how tools run

