2026-07-08 15:23:34 +08:00
# How to Configure MCP Tools in nanobot
2026-10-10 11:48:50 +08:00
This guide adds an MCP server to nanobot so the agent can use external tools through the Model Context Protocol.
2026-07-08 15:23:34 +08:00
## What you will build
- a working nanobot agent
2026-07-14 13:59:47 +08:00
- one MCP integration configured through Apps or `~/.nanobot/config.json`
2026-07-08 15:23:34 +08:00
- a restricted set of MCP tools exposed to the model
## When to use this
2026-10-10 11:48:50 +08:00
Use MCP when the capability you need already exists as an MCP server, or when you want external tools to be managed outside nanobot core.
2026-07-08 15:23:34 +08:00
## Install
```bash
python -m pip install nanobot-ai
nanobot onboard --wizard
nanobot agent -m "Hello!"
```
2026-10-10 11:48:50 +08:00
Install the MCP server runtime separately. Many examples use `npx` , `uvx` , or a remote HTTP endpoint.
2026-07-08 15:23:34 +08:00
## Minimal working example
2026-07-14 13:59:47 +08:00
For local interactive setup:
1. Run `nanobot webui` and open **Apps** .
2026-10-10 11:48:50 +08:00
2. Choose a known MCP server preset, or add a custom stdio, HTTP, or SSE server. For a custom OAuth server, choose **OAuth** under **Authentication** , save it, and click **Connect** . Presets such as Xmind, Notion, and Linear go straight to **Connect** . Approve access in the browser window. HTTPS and localhost WebUIs return automatically. From a remote plain-HTTP WebUI, copy the complete localhost callback URL from the browser address bar and paste it into nanobot.
2026-07-14 13:59:47 +08:00
3. Limit the enabled tools when the server exposes more than the task needs.
4. Save and restart when prompted.
2026-08-10 23:44:37 +08:00
5. Mention the connected MCP server with `@` in the next message and ask for a small test action.
2026-07-14 13:59:47 +08:00
For manual or deployment-managed config, add this to `~/.nanobot/config.json` :
2026-07-08 15:23:34 +08:00
```json
{
"tools" : {
"mcpServers" : {
"filesystem" : {
"command" : "npx" ,
"args" : [ "-y" , "@modelcontextprotocol/server-filesystem" , "/path/to/dir" ],
"enabledTools" : [ "read_file" ]
}
}
}
}
```
Restart nanobot and ask a question that requires the MCP tool.
## Production notes
- Prefer `enabledTools` over exposing every tool by default.
- Use `toolTimeout` for slow MCP operations.
- Use HTTP MCP only for endpoints you trust.
2026-10-10 11:48:50 +08:00
- For deployment-managed OAuth servers, set `auth` to `oauth` and complete the browser connection from **Apps → MCP** .
2026-07-08 15:23:34 +08:00
- Keep MCP server commands stable and versioned in deployment docs or scripts.
## Security notes
- Stdio MCP starts a local process; review the command before enabling it.
2026-10-10 11:48:50 +08:00
- HTTP/SSE MCP uses nanobot's SSRF guard, including OAuth discovery, registration, token exchange, and redirects.
2026-08-10 23:44:37 +08:00
- OAuth credentials live in the nanobot data directory, not in `config.json` .
2026-07-08 15:23:34 +08:00
- Allow private HTTP MCP hosts only with narrow `tools.ssrfWhitelist` CIDRs.
2026-10-10 11:48:50 +08:00
- Do not place secrets in command arguments when environment variables or headers can be used.
2026-07-08 15:23:34 +08:00
## Troubleshooting
- Run the MCP command outside nanobot first.
- Start `nanobot gateway --verbose` and inspect tool registration logs.
2026-10-10 11:48:50 +08:00
- If an HTTP MCP URL is blocked, check whether it points to loopback or a private address that needs explicit allowlisting.
2026-07-08 15:23:34 +08:00
## Related nanobot docs
- [MCP tools for AI agents ](./mcp-tools-for-ai-agents.md )
- [Configuration: MCP ](../configuration.md#mcp-model-context-protocol )
- [Security ](../configuration.md#security )