Skip to content
safran

Type to search. Enter opens the first result.

    Registering the MCP server

    The Safran MCP server gives a coding agent 23 read-only tools over your profile: the company profile, tickets and what surrounds them, code search, live pull requests and the history of finished work. Two more tools write, and they exist only when the profile enables writes. 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.yaml

    Open 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: read-only, no write tool is served (the profile has `writes.enabled: false` (the default)).
    ✔ Safran MCP server for acme listening on http://127.0.0.1:54995/mcp
      health: http://127.0.0.1:54995/healthz   auth: none (loopback only)
      writes: off
    
    Register it in Claude Code:
      claude mcp add --transport http safran http://127.0.0.1:54995/mcp
    
    Ctrl-C stops the server.

    Everything in that output is written to stderr; stdout stays empty. The first line says whether write tools are served, and why not; the stdio server prints the same line. 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/mcp

    The 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

    stdioHTTP
    Who starts the serverClaude Code, once per sessionYou, once
    Sessions servedOneAny number on the machine
    Profile, .env and index openedAt every session startOnce
    Picks up a changed profile or .envAt the next sessionWhen you restart the server (and reconnect the client, so it reads the new tool list)
    Network exposureNoneA 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:

    WhatWhere 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
    TokensThe 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 profileImported 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 writes: section of the profileApplied when the profile was named explicitly or --allow-writes was passed, and --no-writes was not. A safran.yaml that merely happens to be in the current directory does not get to turn writes on.

    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, and so is the decision which tools exist. After changing either, restart the server; a client that was connected keeps its old tool list until it reconnects. get_server_info tells an agent when the profile file changed after the start.

    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.info and console.debug are 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 by default

    With a profile that does not enable writes, which is the default, 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 or a pull request. The server's instructions then tell the agent that Safran is read-only here and to give you the text to post yourself.

    When the profile opts in (writes.enabled: true and the kinds listed in writes.allow), two more tools are registered: preview_write and commit_write. They can add a comment to a ticket, create a child ticket, comment on a pull request and reply in a review thread, and nothing else; every write is a preview, your explicit yes, then one commit, recorded in a local audit log. --no-writes serves no write tool whatever the profile says. The write tools page has the contract and the writes guide the risks.

    No tool ever 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

    1. /mcp in Claude Code lists safran as connected.
    2. Ask for the profile: "call get_company_profile". The answer starts with Company: acme and ends with a Writes: line and a Code index: line.
    3. Ask for the server's own state: "call get_server_info". It lists the tools of this connection, says whether writes are on, and warns about tokens that expire soon.
    4. 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 --verbose added. A profile error is printed with its path and hint; fix it and check with safran profile check.
    • The profile path must be absolute when the command is not started through bin/safran from your own directory. The plugin's form (bun --cwd=…) resolves relative paths inside the checkout.
    • bun must be on the PATH of the process that starts the server. A desktop launcher often has a shorter PATH than your shell.
    • For HTTP: is the server still running, and is the port the one that was registered? --port 0 picks 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 set
    → You cannot fix this from here. Tell the user, who runs the Safran server: …
    [code: AUTH_MISSING]

    The → line tells the agent it cannot fix this and should tell you; the last line is the error's machine tag, which every failed tool call ends with. 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. When the profile declares token_expires for the connector, get_server_info says whether the token has expired. safran doctor shows which variables are set; to test a token itself, read a ticket from a terminal: safran ticket PAY-1423.

    A tool is missing

    The agent says it has no preview_write, or a skill reports that a tool it needs is not there.

    • The write tools exist only when the profile enables writes and the server was allowed to apply that. The first stderr line of the server, and safran writes status, say why they are off.
    • A profile change needs a server restart, and a connected client keeps its old tool list until it reconnects (/mcp in Claude Code). get_server_info lists the tools the connection really has.

    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.yaml

    The 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.