MCPClient.from_openapi(...) to connect directly to an API described by OpenAPI. Harnest loads the spec and constructs a local FastMCP bridge when the MCP connection opens. There is no client-generation command or provisioning step.
Declare a client
Place the specification atmcp/_specs/crm.yaml and declare its connection:
mcp/crm.py
_specs directory is excluded from Python capability discovery and copied into the compiled agent. Resolving the path beside __file__ keeps it valid after deployment. A relative string path resolves against the runtime working directory.
Each from_openapi call creates one standard MCP client for one spec. Declare separate clients for separate APIs. To combine multiple specs into one remotely hosted MCP server, use harnest_fused.
Runtime dependency
Add the optional extra to the agent’s existing dependency list:pyproject.toml
harnest env sync . to update the managed environment and its lock. If you manage your own interpreter, install harnest[openapi] alongside your framework’s MCP adapter.
Load a URL
base_url overrides the first top-level OpenAPI server URL. Supply it when a local spec has a relative server, lacks a server, or uses server variables. A relative server in a remote spec resolves against that spec’s URL.
Remote specs are fetched when a connection starts, including reconnects. Source changes can therefore change the available tools. Use a bundled local file when deployments must use a fixed specification. Spec downloads do not follow redirects or receive the API headers. Download protected specs separately and pass a local path.
Credentials and policies
headers supports the same ${VARIABLE} references as other MCP connections. Values resolve when the connection opens and are sent only to the API. The spec’s securitySchemes do not automatically provision credentials or perform OAuth consent.
The standard stdio client options apply, including tools, prefix, permission, tool_permissions, and timeout_seconds. Omit tools to expose all operations. See MCP Client for runtime permissions and trusted-code access.
Inspect and compile
fused-cli nor a separately installed converter CLI.
For use outside a discovered agent, create the same client in Python and open it with async with client.connect(). The returned read client supports discovery and reads such as list_tools() and read_resource(...). Inside a running agent, invoke tools through context.mcp("crm").call_tool(...), or use the standard ADK or LangGraph tool adapter.
Supported specifications
The bridge supports OpenAPI 3.0 and 3.1 in JSON or YAML through FastMCP 2.x. Bundle external$ref files or URLs into one document first; internal #/... references are retained. Input documents are limited to 16 MiB. Source and operation validation happens when the connection starts.
Swagger 2.0, OpenAPI 3.2, and automatic OAuth flows are not supported by this bridge. The separate harnest_fused package can use fused-cli for explicit setup and Fused-managed execution.