Serve MCP clients

tobira mcp serves chosen connections to an MCP client such as Claude Code, over stdio or over HTTP. This page is the flag reference. The MCP server guide covers setup for each client, the tools and the security model.

tobira mcp --expose local-pg
tobira mcp --expose local-pg,cache --allow-writes cache --max-rows 100
tobira mcp --expose local-pg --http 127.0.0.1:8765

tobira mcp

tobira mcp [--expose <a,b>] [--allow-writes <a>] [--max-rows <n>] [--send-rows always|never] [--http <host:port> [--insecure-bind] [--allowed-host <name>]]

Serves tobira’s tools (list_connections, list_namespaces, list_collections, describe, sample, query, explain, similar on vector databases, and execute when writes are allowed) and the tobira://<connection>/<namespace>/<collection>/schema resources. Only exposed connections are visible; any other name is answered as unknown. execute exists only when some exposed connection is in allow_writes, and is refused on any other connection and on a read-only one.

Every tool call and resource read is recorded in the history with source mcp and the client’s name/version (tobira history --mcp). Refusals read refused by policy: <statement>. Stdout carries only the protocol; logs go to the --debug log. Each flag replaces its mcp: config value, described on the MCP server page.

Flags

FlagDefaultMeaning
--expose <a,b>mcp.exposeConnections to serve. Nothing exposed is a usage error, as is a name that is not a connection.
--allow-writes <a>mcp.allow_writesExposed connections execute may write to; each must be exposed.
--max-rows <n>200Most rows in one tool result, 1 to 1000.
--send-rows <mode>alwaysnever withholds row data: results carry the columns and a count.
--http <host:port>stdioServe Streamable HTTP at http://<host:port>/mcp instead of stdio. An empty host (:8765) is 127.0.0.1, never every interface; port 0 picks a free one.
--insecure-bindoffAllow --http on a non-loopback address. Without it such an address exits 4 before anything listens.
--allowed-host <name>noneAnother Host header value to accept over HTTP, such as a name for this machine. A name alone matches the bound port; name:port matches exactly. Repeatable.

Over HTTP

tobira mcp --expose local-pg --http 127.0.0.1:8765
claude mcp add --transport http tobira http://127.0.0.1:8765/mcp --header "Authorization: Bearer <token>"

The address served is printed to stderr. Every request needs Authorization: Bearer <token>, where the token is mcp.token or, without it, a random one printed once to stderr at start. HTTP mode covers the token, the Host and Origin checks and the limits.

Exit codes

CodeMeaning
0The client hung up, or a signal stopped the server.
1Usage or config error, including nothing exposed or an mcp.token that does not resolve.
2The protocol streams failed, or the HTTP address could not be listened on.
4A non-loopback --http address without --insecure-bind.