Self-hosted · OpenAPI → MCP

Turn any REST API into authenticated MCP tools with OAuth handled for you.

Point torii-mcp at an OpenAPI/Swagger spec and every operation becomes a callable MCP tool. The proxy is its own OAuth 2.1 server and brokers each backend's login, so any MCP client connects transparently — and the upstream credential never leaks to the client.

mcp-proxy.yaml
backends:
  - name: petstore
    spec_url: https://api.example.com/openapi.json
    auth: {type: oauth2, ...}

→ tools live at /mcp/petstore, gated by OAuth.

What people use it for

Anywhere you want an AI assistant to call your existing APIs — safely, as the signed-in user.

Expose internal APIs to Claude

Give an assistant your internal REST API as tools, with each user acting under their own upstream credential.

Wrap a SaaS without writing an MCP server

Already have an OpenAPI spec? Point torii-mcp at it — no per-operation glue code.

Add OAuth to a legacy backend

A login-broker page fronts any custom username/password endpoint and hands MCP clients a standard OAuth flow.

Front an OAuth2 backend

Brokers the backend's own IdP (authorization code + PKCE) and refreshes the upstream token silently.

Multiple APIs, one proxy

Each backend is its own MCP endpoint and OAuth resource — add as many as you like in one config file.

Keep credentials in-house

Self-hosted, with per-user upstream credentials sealed at rest and never forwarded from the MCP client.

How it works

torii-mcp is the gateway between an MCP client and your REST API: it authenticates the client with OAuth, brokers the backend's own login, and proxies each tool call upstream as that user.

MCP client
Claude & friends

Connects to /mcp/<backend> and signs in with standard OAuth 2.1.

torii-mcp gateway
OAuth AS + proxy

Issues MCP tokens, brokers the backend login, seals the per-user credential, and maps OpenAPI operations to tools.

⇅ never forwards the client token
Upstream REST API
Your backend

Receives the real request with the user's brokered bearer or cookie.

1

Declare a backend

Add a backend to mcp-proxy.yaml with its OpenAPI spec_url and an auth strategy. The proxy compiles every operation into a tool at boot.

2

Client signs in

The MCP client discovers the OAuth server, registers via PKCE, and runs the flow. The proxy brokers the backend's login and seals a per-user upstream credential.

3

Tools call through

Each tool call is proxied upstream with the user's credential. For OAuth2 backends the upstream token refreshes silently, so long sessions just keep working.

Secure by design. The MCP client's token is validated but never sent upstream (no confused deputy). Upstream credentials are sealed with AES-256-GCM; MCP tokens are stored only as hashes.

Everything you'd expect — and you own it

No third party in the path of your traffic or your credentials.

OpenAPI → tools

Swagger 2.0 and OpenAPI 3.0/3.1 operations become MCP tools with generated input schemas.

OAuth 2.1 server

Dynamic client registration, PKCE, authorization-code + refresh-token grants, RFC 8414/9728 metadata.

Two auth strategies

login-broker for custom username/password endpoints, or standard OAuth2 with silent upstream refresh.

Per-user identity

Each user acts under their own brokered credential — not a shared service account.

No token passthrough

The MCP client token is never forwarded upstream; the upstream credential is a separate sealed secret.

Config-file driven

Backends live in one YAML file with ${VAR} secrets. No runtime API to attack.

Self-hosted & small

One static binary or a distroless image, an embedded database, no external services.

Hardened service

Installs as a locked-down systemd unit running as an unprivileged user; secrets sealed at rest.

Front your API in minutes

Install the proxy, declare a backend, and point your MCP client at it. The full guide lives in the docs.

# on your host sudo okpkg install torii-mcp