Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nicobailon/pi-mcp-adapter/llms.txt
Use this file to discover all available pages before exploring further.
MCP_DIRECT_TOOLS
TheMCP_DIRECT_TOOLS environment variable overrides directTools configuration from mcp.json. This is useful for:
- Testing direct tool registration without modifying config files
- Temporarily exposing tools for a single session
- Debugging tool registration issues
- Scripting Pi with specific tool sets
Syntax
Set the variable before starting Pi:Format Options
Trailing Slashes
Trailing slashes are stripped automatically:github server.
Special Value: __none__
To disable all direct tools (including those configured in mcp.json):
How MCP_DIRECT_TOOLS Works
The adapter readsMCP_DIRECT_TOOLS at startup and resolves it against the metadata cache:
- Parse the environment variable into server/tool pairs
- Load metadata cache (
~/.pi/agent/mcp-cache.json) - Filter tools based on the parsed list
- Register matching tools as individual Pi tools
Cache Dependency
Direct tools register from the metadata cache, not live connections. This means:- No server connections needed at startup (fast boot)
- Tools must be cached before they can be direct
- First-time setups require a cache bootstrap
What if the cache doesn't exist?
What if the cache doesn't exist?
From
index.ts:1261-1298, if direct tools are configured but not cached, the adapter:- Connects to the server in the background
- Populates the cache
- Notifies you that tools will be available after restart
/mcp reconnect <server> then restart Pi.Example: Bootstrap a New Server
Environment Variable Interpolation in Config
Theenv field in server definitions supports ${VAR} interpolation:
${GITHUB_TOKEN} when spawning the server process.
Multiple Variables
Fallback Values
The adapter does not support fallback syntax like${VAR:-default}. If the variable is unset, it remains as the literal string ${VAR}.
Always ensure required variables are set before starting Pi.
Bearer Token Variables
For HTTP servers with bearer authentication, usebearerTokenEnv instead of env:
Authorization: Bearer <token> header for HTTP requests.
Tool Prefix Environment Variable
Not implemented. ThetoolPrefix setting is only configurable via mcp.json:
Debugging Environment
Enable Server Debug Output
Setdebug: true in server config to see stderr:
Node Debug Flags
To debug the adapter itself, pass Node flags to Pi:Common Patterns
Per-Environment Configuration
Use environment variables to switch between dev/staging/prod:Dev
Production
Secrets Management
Load secrets from a file:CI/CD Integration
Set environment variables in CI for automated sessions:GitHub Actions
Precedence Summary
For direct tools, precedence is:MCP_DIRECT_TOOLSenvironment variable (if set and not__none__)- Per-server
directToolsin config - Global
settings.directToolsin config - Default:
false(proxy only)
bearerTokenorenvvalues in config (literal or interpolated)- Environment variables (if referenced with
${VAR})
- Project config
.pi/mcp.json - Global config
~/.pi/agent/mcp.json - Defaults (
toolPrefix: "server",idleTimeout: 10)
Troubleshooting
MCP_DIRECT_TOOLS Not Working
Symptom: SettingMCP_DIRECT_TOOLS but tools don’t appear.
Causes:
-
Cache doesn’t exist: See “Cache Dependency” above. Run
/mcp reconnect <server>and restart Pi. -
Typo in server name: Server names are case-sensitive and must match
mcpServerskeys exactly. -
Tool name mismatch: Use the original MCP tool name, not the prefixed Pi tool name.
-
Variable not exported: Use
export, not just assignment:
Environment Variable Not Interpolated
Symptom: Server fails to connect, logs show${VAR} instead of the value.
Solution: Export the variable before starting Pi:
Conflicting Direct Tools
Symptom: Warning message about duplicate or colliding tool names. Cause: Two servers expose tools with the same prefixed name, or a tool collides with a Pi builtin. Fromindex.ts:138-146, builtin names are protected: read, bash, edit, write, grep, find, ls, mcp.
Solution:
- Use
toolPrefix: "server"instead of"none"to namespace tools - Explicitly list tools instead of
trueto avoid conflicts: