# MCP servers

Connect MCP servers and let ShiritaiBot use their tools.

ShiritaiBot can act as an MCP (Model Context Protocol) client: it connects to MCP servers and gives their tools to the agent.

## What's supported

* **stdio**: starts a process on your computer, such as an MCP server run with `npx`.
* **Streamable HTTP**: connects to a remote MCP address, with JSON or SSE responses.

Tools are supported, and the list refreshes automatically when a server's tools change. The older two-endpoint HTTP+SSE transport, resources and prompts aren't supported yet.

## Add a server

Add a server in **Settings → Tools and permissions → MCP** with its transport and its command or address. You can also write it straight into `config.toml`:

```toml config.toml
[[mcp_servers]]
id = "files"
enabled = true
transport = "stdio"
command = ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/home/me/docs"]
risk = "sensitive"                                       # default risk level for this server
tool_risks = { read_text_file = "safe", list_directory = "safe" }
disabled_tools = ["move_file"]

[[mcp_servers]]
id = "remote"
enabled = true
transport = "http"
url = "https://example.com/mcp"
headers = { Authorization = "Bearer xxx" }               # encrypted when saved
```

* `command` is a list of arguments and starts directly, without a shell.
* Header values, and environment variables whose names contain KEY, TOKEN, SECRET, PASSWORD and similar words, are encrypted when saved. You can also write `env:NAME` to read an environment variable.

## Tools and permissions

Each MCP tool is registered as `mcp_<server>_<tool>`. Like every other tool, it follows [Permissions](https://shiritaibot.dev/en/docs/auth) and is only available in Agent mode.

Risk levels come only from your settings: `tool_risks` sets single tools, and the rest use the server's `risk`, which defaults to Sensitive. A server's own read-only hint is only shown in the WebUI and never lowers the level.

## Connection status

* At startup, all enabled servers connect in parallel. One failing doesn't affect the others or the program.
* Saving settings only restarts servers whose settings changed.
* If a local server process exits unexpectedly, it reconnects once on the next tool call.
* The WebUI shows each server's status and tools, and you can reconnect by hand.

> MCP server processes run under the same system account as ShiritaiBot, just like code running on your computer. Only connect servers you trust.
