Registering the MCP server
The Safran MCP server gives a coding agent thirteen read-only tools over your profile: the company profile, tickets, code search and the history of finished work. The plugin starts it for you. This page is for the other cases: a project where you want the tools without the skills, a server shared by several sessions, or a client other than Claude Code.
stdio: one server per session
Claude Code starts the server as a child process and talks to it over stdin and stdout:
claude mcp add --transport stdio safran -- <safran checkout>/bin/safran mcp --profile /absolute/path/to/safran.yaml<safran checkout> is the absolute path of your Safran checkout. With the checkout in /work/safran and acme's profile in /work/acme/safran.yaml:
claude mcp add --transport stdio safran -- /work/safran/bin/safran mcp --profile /work/acme/safran.yamlOpen Claude Code and run /mcp: safran should be listed as connected. Its tools are named mcp__safran__<tool>, for example mcp__safran__get_company_profile.
When the server is started another way in a directory that has one of those two files, it says so on stderr at start, and safran doctor reports the same.
HTTP: one server, several sessions
Run the server yourself and point clients at it:
$ safran mcp --http --port 0 --profile /work/acme/safran.yaml
✔ Safran MCP server for acme listening on http://127.0.0.1:52358/mcp
health: http://127.0.0.1:52358/healthz auth: none (loopback only)
Register it in Claude Code:
claude mcp add --transport http safran http://127.0.0.1:52358/mcp
Ctrl-C stops the server.Everything in that banner is written to stderr; stdout stays empty. The command prints the exact line to register the server, with the port it really bound (--port 0 picks a free one; the default is 3939). In another terminal:
claude mcp add --transport http safran http://127.0.0.1:3939/mcpThe server binds to loopback, has no authentication unless you configure a token, and stops on Ctrl-C. Options, the bearer token and the security model are on HTTP mode.
Which one
| stdio | HTTP | |
|---|---|---|
| Who starts the server | Claude Code, once per session | You, once |
| Sessions served | One | Any number on the machine |
Profile, .env and index opened | At every session start | Once |
Picks up a changed profile or .env | At the next session | When you restart the server |
| Network exposure | None | A loopback port (or more, with a token) |
Start with stdio. Move to HTTP when several sessions run at once and you want one process holding the code index, or when the client is not started from a shell that has your tokens.
How the server finds the profile and the tokens
The mcp command resolves its inputs like every other safran command:
| What | Where it comes from |
|---|---|
| Profile | --profile <file>, else $SAFRAN_PROFILE, else ./safran.yaml in the directory the command was started from |
| Data directory (clones, index, link store) | --data-dir <dir>, else data/ next to the profile |
| Tokens | The environment of the process, plus the .env file next to the profile. A variable already set in the environment wins over the file. |
Modules under plugins: in the profile | Imported when the profile was named explicitly (--profile or $SAFRAN_PROFILE) or --allow-plugins was passed. A safran.yaml that merely happens to be in the current directory does not get to run code. |
The profile is validated and the connectors are built when the server starts; no network call is made then. A token is read the first time a connector needs it, and the code index is opened the first time a code tool is called. So a server with a missing token or without an index still starts and still answers get_company_profile.
The environment and the profile are read once. After changing either, restart the server.
stdio hygiene
Over stdio, stdout carries protocol frames and nothing else. One stray line there corrupts the stream for the client.
- The server's log (warnings and errors by default, debug lines with
--verbose) goes to stderr. - While serving,
console.log,console.infoandconsole.debugare pointed at stderr, so a connector plugin that prints cannot break the session. - The session ends when the client closes stdin. From a terminal, Ctrl-C does the same.
- Flags that belong to HTTP (
--port,--host,--token-env,--path,--allow-host) are refused without--http.
Run from a terminal, safran mcp therefore prints nothing and waits: it is waiting for a client on stdin.
The server is read-only
Every tool is annotated readOnlyHint: true, destructiveHint: false, idempotentHint: true. There is no tool that creates, edits, comments on or transitions a ticket, and none that writes to a repository. The server does not run safran sync or safran links refresh either: it answers from the index and the link store as they are, and tells the agent to ask you when they are empty or old. The tools are listed in the MCP reference.
Verify
/mcpin Claude Code listssafranas connected.- Ask for the profile: "call get_company_profile". The answer starts with
Company: acmeand ends with aCode index:line. - Ask for a ticket you know: "show PAY-1423". This is the first call that needs a token.
From a terminal, without Claude Code, the HTTP server can be checked with its health endpoint (curl http://127.0.0.1:3939/healthz answers ok), and safran status shows what the tools will see: profile, connectors, index and link store.
Troubleshooting
The server is not listed, or fails to connect
- Run the registered command yourself, with
--verboseadded. A profile error is printed with its path and hint; fix it and check withsafran profile check. - The profile path must be absolute when the command is not started through
bin/safranfrom your own directory. The plugin's form (bun --cwd=…) resolves relative paths inside the checkout. bunmust be on thePATHof the process that starts the server. A desktop launcher often has a shorterPATHthan your shell.- For HTTP: is the server still running, and is the port the one that was registered?
--port 0picks a new one at every start; use a fixed port for a registration that should survive restarts.
Tools appear twice
The plugin is enabled and the server is also registered on its own. The same tool then exists as mcp__plugin_safran_safran__<tool> and as mcp__safran__<tool>. Remove one (claude mcp remove safran, or disable the plugin).
AUTH_MISSING on the first ticket call
Environment variable JIRA_TOKEN is not setThe message is followed by a → line that tells the agent it cannot fix this and should tell you. The profile names a variable that the server's process does not have. Export it in the shell that starts Claude Code (stdio) or the server (HTTP), or put it in the .env next to the profile, then restart. safran doctor lists every variable the profile refers to and whether it is set, without printing values.
AUTH_FAILED
The variable is set but the tracker or code host refused it: an expired token, a wrong e-mail for a Jira API token, a token without read scope. safran doctor shows which variables are set; to test a token itself, read a ticket from a terminal: safran ticket PAY-1423.
The index is not ready, empty or old
get_company_profile reports the index on its last line. 0 repos or NOT AVAILABLE means the code tools cannot answer yet:
safran sync --profile /work/acme/safran.yamlThe server can stay up while you sync: the index is a database that one process can read while another writes, and a running server sees what the sync committed. If a code tool answers INDEX_NOT_READY with "The code index is locked by another Safran process", wait for the other command to finish and repeat the call.
find_past_work reads a separate store, filled by safran links refresh. When that store is empty the tool says so instead of answering "nothing was done".
The embedder is not reachable
search_code embeds the query, so it needs the embedder from the profile (for acme, Ollama with bge-m3) to be running. search_code with mode: "lexical", grep_code, read_file and the ticket tools work without it.