Skip to main content

MCP tools

The MCP tool enables integration with external Model Context Protocol servers. Every tool exposed by a connected server becomes an individual agent tool named mcp_<server>_<tool>; the components are sanitized into valid identifiers, and a short hash suffix keeps names distinct (and within the 64-character API limit) when sanitization or truncation would collide.

If you prefer not to edit JSON manually, PicoClaw also provides an MCP configuration manager CLI:

  • picoclaw mcp add — add or update a server (supports --deferred / --no-deferred)
  • picoclaw mcp list — list all configured servers with status and deferred state
  • picoclaw mcp show <name> — show full details and the tool list for one server
  • picoclaw mcp test <name> — connectivity check for one server
  • picoclaw mcp remove <name> — remove a server entry
  • picoclaw mcp edit — open config.json in $EDITOR for advanced edits

These commands manage the same tools.mcp.servers section documented below. See MCP Server CLI for command syntax, examples, and behavior details.

The web dashboard also provides an MCP page with a Servers tab for adding, editing, and monitoring configured stdio/SSE/HTTP servers, a Catalog tab with one-click presets for popular servers, and a Settings tab for the global MCP integration and tool discovery options. Presets that require credentials prompt for them during installation.

Tool Discovery (Lazy Loading)​

When connecting to multiple MCP servers, exposing hundreds of tools simultaneously can exhaust the LLM's context window and increase API costs. The Discovery feature solves this by keeping MCP tools hidden by default.

Instead of loading all tools, the LLM is provided with a lightweight search tool (using BM25 keyword matching or Regex). When the LLM needs a specific capability, it searches the hidden library. Matching tools are then temporarily "unlocked" and injected into the context for a configured number of turns (ttl).

BM25 matching normalizes common English inflections (plurals, -ing, -ed) so a query such as searching repositories matches search repositories. Tokens containing digits or non-ASCII characters are left unchanged. Common English function words (a, the, of, to, is, ...) are ignored in both the tool index and the query, so a sentence such as how can I create an issue is matched on create and issue only.

Global Config​

ConfigTypeDefaultDescription
enabledboolfalseEnable MCP integration globally
discoveryobject{}Configuration for Tool Discovery (see below)
max_inline_text_charsint16384Head+tail budget for MCP text: beyond this, the model keeps the first 40% and the last 60% of the sanitized text (with an omission notice) and the full payload is saved as a workspace artifact
serversobject{}Map of server name to server config

Oversized MCP text results are bounded, not dropped: the model keeps the first 40% and the last 60% of the sanitized text around an [MCP RESULT TRUNCATED - N chars omitted out of T total] notice, while the full raw payload is saved to <workspace>/.artifacts/mcp/ and exposed via a [file:...] artifact path. When the text result is a JSON object shaped {"result": <text>, ...} with only known keys and a non-empty string result, it is unwrapped before the write: the artifact holds the wrapped text with real newlines plus a <mcp-result-metadata> block carrying siblings embedded in that text object, so read_file/search_files can page it instead of reading one escaped JSON line; anything unrecognized stays verbatim. The protocol-level structuredContent and _meta fields of CallToolResult are separate from the text content and are not included by this rewrite. If the artifact write fails, the bounded view stays inline and the payload is handed to the generic large-result spillover, which saves it under <workspace>/.artifacts/tool/ instead (using the same pageable text for an unwrapped payload).

Discovery Config (discovery)​

ConfigTypeDefaultDescription
enabledboolfalseGlobal default: if true, all MCP tools are hidden and loaded on-demand via search; if false, all tools are loaded into context and discovery is off. Individual servers can only opt out with deferred: false while this is true; a per-server deferred: true has no effect when this is false.
ttlint5Number of conversational turns a discovered tool remains unlocked
max_search_resultsint5Maximum number of tools returned per search query
use_bm25booltrueEnable the natural language/keyword search tool (tool_search_tool_bm25). Warning: consumes more resources than regex search
use_regexboolfalseEnable the regex pattern search tool (tool_search_tool_regex)

Note: If discovery.enabled is true, you MUST enable at least one search engine (use_bm25 or use_regex), otherwise the application will fail to start.

Per-Server Config​

ConfigTypeRequiredDescription
enabledboolyesEnable this MCP server
deferredboolnoPer-server override, effective only when discovery.enabled is true. true = tools are hidden and discoverable via search; false = tools are always visible in context. When omitted, the global discovery.enabled value applies. Ignored (tools always visible) when discovery.enabled is false, because the discovery search tools are not registered in that case.
typestringnoTransport type: stdio, sse, http (alias: streamable-http)
commandstringstdioExecutable command for stdio transport
argsarraynoCommand arguments for stdio transport
envobjectnoEnvironment variables for stdio process
env_filestringnoPath to environment file for stdio process
inherit_envboolnoPass the full PicoClaw process environment to this stdio server. Defaults to false.
supports_parallel_tool_callsboolnoAllow this server's tool calls to run concurrently when the model emits several in one response (up to agents.defaults.max_parallel_tool_calls). Defaults to false: calls run one by one. Per server, not global.
urlstringsse/httpEndpoint URL for sse/http transport
headersobjectnoHTTP headers for sse/http transport
oauthobjectnoBrowser OAuth for remote servers; run picoclaw mcp login <name> before connecting. Cannot be combined with an Authorization header.

Transport Behavior​

  • If type is omitted, transport is auto-detected:
    • url is set → sse
    • command is set → stdio
  • http and sse both use url + optional headers. streamable-http is accepted as an alias for http.
  • Remote requests are bound to the configured origin. A redirect must keep the same host and port; an http to https upgrade on the same host is allowed, and anything else fails the connection instead of being followed. Configured headers are never replayed to another origin.
  • Headers generated by the client for the protocol (Accept, Content-Type, Mcp-Session-Id, and the OAuth authorization) take precedence over entries of the same name in headers. Every other configured header is applied to each request.
  • env, env_file, and inherit_env are only applied to stdio servers.
  • By default, stdio servers inherit only PATH, HOME, USER, LANG, LC_ALL, TERM, SHELL, TMPDIR, and XDG_* (plus basic Windows process variables on Windows). env_file adds variables, and env overrides both the file and inherited values. Set inherit_env: true only if the server needs the entire parent environment.
  • oauth: {} enables browser login with dynamic client registration. Optional fields are client_id, issuer, scopes, and callback_port. See MCP Server CLI.

Configuration Examples​

1) Stdio MCP server​

{
"tools": {
"mcp": {
"enabled": true,
"servers": {
"filesystem": {
"enabled": true,
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/tmp"
]
}
}
}
}
}

2) Remote SSE/HTTP MCP server​

{
"tools": {
"mcp": {
"enabled": true,
"servers": {
"remote-mcp": {
"enabled": true,
"type": "sse",
"url": "https://example.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_TOKEN"
}
}
}
}
}
}

3) Massive MCP setup with Tool Discovery enabled​

In this example, the LLM will only see the tool_search_tool_bm25. It will search and unlock Github or Postgres tools dynamically only when requested by the user.

{
"tools": {
"mcp": {
"enabled": true,
"discovery": {
"enabled": true,
"ttl": 5,
"max_search_results": 5,
"use_bm25": true,
"use_regex": false
},
"servers": {
"github": {
"enabled": true,
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-github"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_TOKEN"
}
},
"postgres": {
"enabled": true,
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://user:password@localhost/dbname"
]
},
"slack": {
"enabled": true,
"type": "slack",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-slack"
],
"env": {
"SLACK_BOT_TOKEN": "YOUR_SLACK_BOT_TOKEN",
"SLACK_TEAM_ID": "YOUR_SLACK_TEAM_ID"
}
}
}
}
}
}

4) Mixed setup: per-server deferred override​

Discovery is enabled globally, but filesystem is pinned as always-visible while context7 follows the global default (deferred). aws explicitly opts in to deferred mode even though it is the same as the global default.

{
"tools": {
"mcp": {
"enabled": true,
"discovery": {
"enabled": true,
"ttl": 5,
"max_search_results": 5,
"use_bm25": true
},
"servers": {
"filesystem": {
"enabled": true,
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/workspace"],
"deferred": false
},
"context7": {
"enabled": true,
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"]
},
"aws": {
"enabled": true,
"command": "npx",
"args": ["-y", "aws-mcp-server"],
"deferred": true
}
}
}
}
}

Note: A per-server deferred value only takes effect when discovery.enabled is true. It can pin a server's tools as always-visible ("deferred": false) or hidden ("deferred": true), but it cannot enable discovery on its own: with discovery.enabled: false the search tools are not registered, so "deferred": true is ignored and the server's tools stay visible.

5) Browser automation with Playwright​

Playwright MCP exposes a real Chromium browser as MCP tools. This example attaches to a headless Chromium already listening on loopback; omit --cdp-endpoint to let Playwright launch and manage its own browser. Install the server with npm install -g @playwright/mcp and use the absolute path printed by command -v playwright-mcp.

{
"tools": {
"mcp": {
"enabled": true,
"servers": {
"playwright": {
"enabled": true,
"type": "stdio",
"command": "/usr/local/bin/playwright-mcp",
"args": [
"--cdp-endpoint",
"http://127.0.0.1:9222",
"--headless",
"--isolated",
"--user-agent",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.0.0 Safari/537.36",
"--timeout-navigation",
"45000",
"--idle-timeout",
"300000",
"--output-dir",
"/root/.picoclaw/workspace/browser"
],
"deferred": false
}
}
}
}
}

deferred is optional and only matters when tool discovery is enabled. Keep supports_parallel_tool_calls at its default false because browser actions are stateful. See Browser automation for the Chromium CDP setup, the full flag reference, the browser workflow, security notes, and troubleshooting.