MCP
Felix speaks the Model Context Protocol in both directions. The
terminal client and the hosted API can connect MCP servers and give their tools to the model. The
terminal client can serve its workspace tools to another MCP client, and the API serves Felix
itself as tools at /v1/mcp.
| Surface | Uses MCP servers | Serves over MCP |
|---|---|---|
| Terminal client | Stdio and HTTP servers from ~/.felix/mcp.json and a trusted workspace’s .felix/mcp.json, with OAuth sign-in |
--serve-mcp: workspace tools over stdio |
| Hosted API | HTTPS servers from the FELIX_MCP_SERVERS secret, behind approvals |
/v1/mcp: runs, threads and approvals over Streamable HTTP |
Servers in the terminal client
Section titled “Servers in the terminal client”The terminal client reads MCP servers from ~/.felix/mcp.json, or
$FELIX_HOME/mcp.json when FELIX_HOME is set, and from the workspace’s .felix/mcp.json only
once you trust the workspace. Starting a configured program is a capability, and a cloned
repository must not be able to grant itself one. A server named in both files is the personal one,
with a warning. A missing file means no servers.
{ "servers": { "docs": { "url": "https://example.com/mcp", "headers": { "authorization": "Bearer ${DOCS_TOKEN}" } }, "files": { "command": "npx", "args": ["-y", "some-mcp-server"], "env": { "API_KEY": "${SOME_KEY}" }, "timeoutSeconds": 120 } }}A server is either a program Felix starts and talks to over stdio, or a URL it reaches over Streamable HTTP. One entry cannot be both.
| Field | Server | Meaning |
|---|---|---|
command |
Stdio | The program to start. Required for a stdio server. |
args |
Stdio | Its arguments. |
env |
Stdio | Environment variables for it. |
cwd |
Stdio | The directory to start it in. |
url |
HTTP | The server’s endpoint, http:// or https://. Required for an HTTP server. |
headers |
HTTP | Headers sent with each request, such as authorization. |
oauth |
HTTP | true, or { "scope", "callbackPort" }, to sign in with OAuth. See below. |
description |
Both | One line, up to 500 characters, telling the model what the server is for. Unset, the first line of the instructions the server sends is used. |
exposure |
Both | direct or deferred. See Deferred tools. |
toolExposure |
Both | direct or deferred per tool name or * pattern, over exposure. |
timeoutSeconds |
Both | How long one tool call may take, 1 to 3600. Default 60. Progress the server reports starts it again, up to ten times this in all. |
trustReadOnlyHint |
Both | true takes the server’s read-only marks at their word. Default false. See below. |
Server names are 1 to 32 characters: letters, digits, _, . and -, starting with a letter or
digit. Any other field is refused.
- Variables:
${NAME}in anenvorheadersvalue is replaced from the client’s own environment, so tokens stay out of the file. A variable that is not set skips that server. - Environment: a stdio server gets only a small safe default environment plus its own
env. Your provider credentials are never passed to it. It runs in its own process group, so closing it, or the client exiting, also ends what it started (the real server behindnpxoruvx). Its stderr is never shown as it comes; the last 2,000 characters are added to the reason it failed to start or disconnected. - Startup: each server is connected when the client starts, with 30 seconds to connect and
list its tools. A server that fails is skipped;
pnpm chatprintsMCP: <name>: <reason>on stderr and carries on without it.
OAuth sign-in
Section titled “OAuth sign-in”An HTTP server with "oauth": true signs in with OAuth: server discovery, dynamic client
registration, PKCE and token refresh. scope asks for a scope; callbackPort (1024 to 65535)
moves the sign-in callback off its default port, 8976.
{ "servers": { "tracker": { "url": "https://tracker.example/mcp", "oauth": true } } }Sign in once:
pnpm chat --mcp-login trackerIt prints the authorization URL, tries to open your browser, and waits up to five minutes for the
redirect on http://127.0.0.1:8976/callback. A callback whose state does not match is refused.
When sign-in completes it lists the server’s tools to confirm, then prints how many there are. A
name that is not an HTTP server with oauth in mcp.json is refused.
The client registration and tokens are kept in ~/.felix/mcp-auth/<name>.json, readable only by
you. Normal startup uses and refreshes them but never opens a browser: a server that needs a new
sign-in is skipped, and its warning names the --mcp-login command to run.
Tools from servers
Section titled “Tools from servers”Each server tool reaches the model as mcp__<server>__<tool>. Characters other than letters,
digits and _ become _, so search-docs on server docs.site is mcp__docs_site__search_docs.
A name longer than 64 characters, or one already taken, is shortened and ends in _ and an
8-character hash. The description says which server the tool came from.
- Arguments are checked against the tool’s schema before the call when Felix can compile it, and by the server otherwise.
- Results become text. PNG, JPEG, GIF and WebP images, inline or embedded as resources, are
passed to the model as images; other media and resource links become placeholders such as
[image: image/png]. A result is cut to 20 KB, keeping its start and end. A result the server marks as an error fails the call with its text. - Scripts receive the server’s JSON value when it supplies
structuredContent, including when the server also supplies a display summary. A structured result larger than 20,480 serialized characters raises an error in the script. - Cancellation: stopping a run cancels the call in flight.
- Progress: progress the server reports shows as the call’s progress.
- Reconnecting: a stdio server that exits is started again by the next call, at most once every five seconds. When an HTTP server no longer knows the session (it restarted), Felix opens a new one and sends the call again once, since the server never ran it. Listing tools is retried once after a timeout, rate limit, server error or network error; a tool call is not.
--tools can keep or drop MCP tools like any other, by name or prefix:
--tools read_file,mcp__docs__*, or --exclude-tools mcp__docs__* to drop one server’s tools. Neither adds a server.
In the full-screen client, every MCP call waits on the same prompt as a write,
call MCP tool <name>, answered with y or n, unless --yes. A server can mark a tool
read-only, and Felix still asks. pnpm chat has nowhere to ask, so there MCP calls run without asking. Child agents from
--delegate never get MCP tools.
Read-only marks
Section titled “Read-only marks”A server marks its own tools read-only, so the mark is ignored unless the server’s entry sets
"trustReadOnlyHint": true. Set it only for a server you trust to mark them truthfully. Then its
read-only tools run in plan mode, are reported read-only to a server conversation (--server),
and the model is told an interrupted call to one is safe to repeat. Without it, those tools are
refused in plan mode like any other, and an interrupted call is closed as having an unknown
outcome.
Deferred tools and tool_search
Section titled “Deferred tools and tool_search”A server with many tools fills every request with their definitions. Set "exposure": "deferred"
on it and its tools are left out of requests; a tool_search tool is offered instead, and the model
uses it to find a tool by what it does. What it finds is offered from the model’s next step on, along
that conversation branch (a rewind to before the search leaves it unloaded). toolExposure sets
direct or deferred per tool, by the tool’s name as the server gives it or a * pattern; an exact
name wins over patterns, and among patterns the first that matches:
{ "servers": { "github": { "url": "https://api.githubcopilot.com/mcp/", "exposure": "deferred", "toolExposure": { "search_code": "direct", "get_*": "direct" } } }}Exposure is direct by default. A call to a deferred tool that no search has loaded is refused,
with a note to search first. --tools and --exclude-tools apply to tool_search as to any tool.
Servers in the hosted API
Section titled “Servers in the hosted API”The API Worker connects remote servers listed in the FELIX_MCP_SERVERS secret, once for each
run request. Their tools are added beside the hosted tools.
{ "servers": { "tickets": { "url": "https://tickets.example/mcp", "headers": { "authorization": "Bearer ${TICKETS_TOKEN}" }, "timeoutSeconds": 60 } }}| Field | Meaning |
|---|---|
url |
The server’s endpoint. Required, and HTTPS only. |
headers |
Headers sent with each request. |
timeoutSeconds |
How long one tool call may take, 1 to 600. Default 60. |
oauth |
true, or { "scope", "clientId", "clientSecret" }: each person signs in to the server themselves. See below. |
connection |
google sends each person’s own Google connection, for Google’s own MCP servers only. See below. |
approval |
false lets calls run without a person’s approval. Default: approval needed. |
trustReadOnlyHint |
true takes the server’s read-only marks at their word: those tools run in plan mode, and a run resumed after a restart runs an interrupted call to one again. Default false: the call is closed as having an unknown outcome. |
exposure |
deferred leaves the server’s tools out of each request until tool_search finds them, as in the terminal client (see Deferred tools); direct declares them every turn. Unset: deferred for a server with more than 10 tools, direct otherwise. run_script can call deferred tools either way. |
toolExposure |
direct or deferred per tool name or * pattern, over the server’s exposure. |
Server names are 1 to 32 characters: letters, digits, _ and -, starting with a letter or digit.
${NAME} in a header value reads another Worker secret, so tokens stay out of the JSON; set
TICKETS_TOKEN as its own secret. Tool names follow the same mcp__<server>__<tool> rule as in the
terminal client.
A result from an MCP server longer than 20 KB (or 2000 lines) is cut to its first lines; other
tools’ are cut at 50 KB. With the OUTPUTS bucket the whole text is kept and the model can read on
with read_output.
- Approvals: every call to a server’s tools waits for a decision through the approvals routes
(an
approval_requiredframe), with a five-minute deadline, unless the server sets"approval": false. A server’s read-only hint does not change this. - No approval store, no gated tools: without thread storage there is nowhere to record an approval, so tools that need one are not offered at all.
- Delegation: child agents never get MCP tools.
- Connecting: each server has 15 seconds to connect and list its tools. A server that fails, or whose header secret is not set, is skipped for that request. A session the server forgets during a run is replaced, and the call that found it is sent again once.
- Malformed list: if
FELIX_MCP_SERVERSis not valid JSON or breaks a rule above, conversations are left unconfigured (model_not_configured) rather than running without the servers.
Servers people sign in to
Section titled “Servers people sign in to”A server takes its credentials from headers, the same for everyone, unless it is marked oauth
or connection. Then its tools act as the person the conversation belongs to, and a run on a
conversation that belongs to no one (the operator token’s) goes without it.
{ "servers": { "tracker": { "url": "https://mcp.tracker.example/mcp", "oauth": true }, "drive": { "url": "https://drivemcp.googleapis.com/mcp/v1", "connection": "google" } }}oauth: each person signs in on the Connections page (Manage → Connections). Felix finds where from the server’s own metadata, and registers itself there unlessclientId(andclientSecret, which can be${NAME}) names a client you made. Its redirect address is<origin><prefix>/v1/connections/mcp/<server>/callback.scopeasks for particular scopes; unset, the ones the server lists. It needs sign-in and thread storage, a server that publishes OAuth metadata, and one that registers clients if you give noclientId.connection: sends the person’s Google connection, with the scopes inFELIX_GOOGLE_CONNECT_SCOPES. Only hosts such asdrivemcp.googleapis.comare accepted. Google decides which clients and accounts its servers take.- Not signed in: the run goes on without the server’s tools, and the agent can tell the person to sign in.
- Approvals: calls need a person’s approval even with
"approval": false, except to tools the server marks read-only whentrustReadOnlyHintis set. - Tokens are sealed per person and server address, refreshed before they expire, sent only to
the server’s own origin, and never follow a redirect. Changing a server’s
urlmeans signing in again. WithFELIX_STORES=postgres, run the schema migrations first.
Serving Felix over MCP
Section titled “Serving Felix over MCP”The /v1/mcp endpoint
Section titled “The /v1/mcp endpoint”The API serves Felix to other agents at /v1/mcp over Streamable HTTP. Each request is served on
its own; there is no MCP session to keep. It takes the deployment’s API token as a bearer token,
like the REST API.
| Tool | Arguments | Result |
|---|---|---|
felix_run |
prompt, optional thread_id, optional agent |
Runs the prompt on that thread, or on a new one (as agent, when given). Returns { thread_id, status, reply, outcome, approvals? }, where outcome is complete, limit, failed or stopped. |
felix_list_threads |
optional cursor |
One page of threads. |
felix_read_thread |
thread_id |
One thread with its messages. |
felix_list_approvals |
optional status (pending, approved, denied; default pending), thread_id |
Approvals by status. |
felix_decide_approval |
approval_id, decision (approved or denied), optional note, edited_args |
Decides a pending tool call; edited_args replaces its arguments when approving. |
felix_run was named felix_chat before; a call to felix_chat still runs it, though the tool
list shows only felix_run.
The tools call the API’s own routes in-process, so threads, approvals and their limits behave as
they do over HTTP. When a run in felix_run reaches a gated tool, the call waits for its
decision; another caller can decide it with felix_decide_approval meanwhile. Arguments are
validated twice, by the MCP server and by each tool, and a tool that fails returns an error result
with the reason. The read tools are marked read-only.
Any MCP client that speaks Streamable HTTP can connect. For example, as a server in the terminal
client’s mcp.json:
{ "servers": { "felix": { "url": "https://…/v1/mcp", "headers": { "authorization": "Bearer ${HOSTED_FELIX_TOKEN}" } } }}HOSTED_FELIX_TOKEN stands for any environment variable you choose that holds the deployment’s
API token (FELIX_API_TOKEN); it is not a Felix setting.
| Status | Code | When |
|---|---|---|
| 401 | unauthorized |
The bearer token is missing or wrong. |
| 503 | mcp_not_configured |
Conversations are not configured, or the Worker has no thread storage. |
--serve-mcp in the terminal client
Section titled “--serve-mcp in the terminal client”--serve-mcp serves one workspace’s tools to another MCP client over stdio:
pnpm chat --serve-mcp --workspace /path/to/project| Tools | Offered |
|---|---|
list_files, read_file, find_files, grep_files |
By default. Marked read-only. |
write_file, edit_file |
By default; not with --read-only. |
run_command |
By default; not with --read-only. It is not a sandbox. |
--tools and --exclude-tools narrow the list as they do in a session.
Each tool keeps its own validation and limits, and paths stay inside the workspace: a path that leaves it is refused as an error result. There is no confirmation prompt in this mode, so the calling client decides what to allow. Nothing else is served: no model, sessions, skills or configured MCP servers. The protocol owns stdout.
In another agent’s MCP configuration:
{ "command": "pnpm", "args": ["--dir", "/path/to/felix", "chat", "--serve-mcp", "--workspace", "/path/to/project"]}What fails closed
Section titled “What fails closed”| Situation | What happens |
|---|---|
mcp.json is malformed or has an unknown field |
The terminal client stops and names the file and the problem. |
| An untrusted workspace contains MCP configuration | It is ignored; only the personal file is read. |
A ${NAME} variable or header secret is not set |
That server is skipped. |
| An OAuth server needs a new sign-in | It is skipped at startup; no browser opens until --mcp-login. |
The OAuth callback’s state does not match |
The sign-in is refused. |
| A hosted server URL is not HTTPS | The server list is refused and conversations are left unconfigured. |
| A hosted server has no approval store to gate it | Its gated tools are not offered. |
| A server marks a tool read-only | Felix still asks (terminal) or still requires approval (hosted), and without trustReadOnlyHint the mark is ignored. |
/v1/mcp without the right token, or without a configured model and thread storage |
401 or 503; no tool runs. |
--serve-mcp --read-only |
Only the four read tools are served. |
© Felix. All rights reserved.