MCP Configuration
Book supports the Model Context Protocol (MCP) as an MCP client. MCP servers expose tools that Book discovers and registers alongside its built-in tools, making them available to the agent loop without any code changes.
This page covers configuring MCP servers. For the client architecture internals (McpClientFacade, namespacing, tool adaptation), see Embedding Book via MCP (Phase 4).
~/.bk/mcp.json โ Server Configuration
MCP servers are declared in one or both of the following files:
| File | Scope | Priority |
|---|---|---|
|
Global โ applies to all projects |
Lower |
|
Project-local โ overrides global for this directory |
Higher |
Format
{
"mcpServers": {
"<server-name>": {
"command": "<executable>",
"args": ["<arg1>", "<arg2>"],
"env": {
"ENV_VAR": "value"
}
}
}
}
| Field | Type | Required | Description |
|---|---|---|---|
|
|
โ |
Executable to spawn (e.g. |
|
|
No (default |
Command-line arguments. |
|
|
No (default |
Extra environment variables for the subprocess. |
Example
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "<your-token>" }
}
}
}
Merge Semantics
When both files exist, Book merges them with the following rules:
-
If the same
namekey appears in both files, the project-local entry wins. -
Servers unique to either file are retained (not dropped).
-
Malformed JSON in either file is silently skipped;
[]is returned for that file.
This lets you maintain a global set of always-available servers (e.g. filesystem, github) and override individual entries per-project (e.g. a project-specific postgres server).
--mode mcp โ Standalone Startup
Pass --mode mcp to load MCP servers at startup regardless of whether ACP mode is active.
# TUI with MCP servers loaded
bk --mode mcp
# Headless prompt with MCP servers loaded
bk --mode mcp --prompt "list files in /tmp"
# Explicitly add TUI (same as default when --mode acp is absent)
bk --mode tui --mode mcp
Behaviour
-
Book merges
~/.bk/mcp.jsonand<cwd>/.bk/mcp.json. -
Each server subprocess is spawned,
initialize+tools/listare exchanged (10 s timeout each), and discovered tools are registered alongside the built-in tools. -
Servers that fail to respond within the timeout are skipped โ Book starts normally with the remaining servers.
-
MCP tools become immediately available to the agent loop for the lifetime of the process.
ACP + MCP interaction
When --mode acp is also present, --mode mcp is silently ignored at startup:
bk --mode acp --mode mcp # mcp.json is NOT consulted at startup
In ACP mode, MCP server configuration is supplied per-session by the IDE client via the session/new _meta (see below). This prevents a mismatch between the IDE’s project context and a static global mcp.json read at process start time.
Per-Session MCP via ACP session/new
In ACP server mode (bk --mode acp / bk serve), MCP servers are wired per-session rather than at process startup.
The IDE client includes an mcpServers array in the session/new request _meta:
{
"jsonrpc": "2.0",
"method": "session/new",
"params": {
"cwd": "/path/to/project",
"_meta": {
"mcpServers": [
{
"name": "filesystem",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"]
}
]
}
}
}
Each session’s MCP tools are independent โ one session can have filesystem loaded while another has github. Tools are deregistered when the session ends.
MCP Tool Naming
All MCP-sourced tools are registered with the prefix mcp_<server-name>_<tool-name>:
| MCP server name | MCP tool name | Registered as |
|---|---|---|
|
|
|
|
|
|
The prefix prevents collisions between built-in tools (e.g. read_file) and MCP tools with identical names from different servers. If two MCP servers declare a tool with the same name, the prefix ensures they remain distinct โ no deduplication occurs, both are registered.
Disconnecting
MCP connections are process-scoped. When book exits, all active subprocess clients are closed and all MCP tools are deregistered automatically. There is no explicit disconnect flag.
Troubleshooting
MCP server not appearing as a tool
-
Check the server name in
mcp.jsonโ it must be a valid identifier (no spaces). -
Run with
--prompt "list tools"to see the full registered tool list at startup. -
Check the logs under
~/.bk/agent/logs/forFailed to parse MCP config fileorconnect timeoutentries.
mcp.json changes not reflected
mcp.json is read once at startup (or once per session/new in ACP mode). Restart book to pick up changes.