MCP Servers

The Model Context Protocol (MCP) lets P31 connect to external tools and data sources. Currently two MCP servers are bundled.

PHOS Forge

Command: node /path/to/phos-forge/mcp-server.mjs

26 tools for file management, cognitive state, deployment, research, and self-healing:

Google Workspace

Command: node /path/to/google-workspace-mcp/build/index.js

Calendar, contacts, and email integration. Enables queries like "What meetings do I have today?"

Adding Custom MCP Servers

MCP servers are configured in cmd/chat.go in the initMCP() function:

servers := []p31mcp.ServerDef{
  {
    Name:    "my-server",
    Command: "node",
    Args:    []string{"/path/to/server.mjs"},
    Env:     map[string]string{"KEY": "value"},
  },
}

Tool names are prefixed with server__ (e.g., my-server__my-tool) to route calls to the correct server.

Protocol: MCP uses JSON-RPC 2.0 over stdio. The client sends requests on stdin, the server responds on stdout. Stderr is free for logging. The server must process input line-by-line (not buffer until stdin closes).