The Model Context Protocol (MCP), created by Anthropic, is an open standard that allows local applications and AI assistants to securely interface with local system tools. CostAffective operates as an MCP server using a stdio transport channel.
Stdio Bidirectional JSON-RPC Streams
When you run costaffective serve, the host editor (such as Cursor or Claude Code) starts CostAffective as a background subprocess. The host and server communicate by writing JSON-RPC 2.0 payloads to stdin and reading responses from stdout.
// Client -> Server Handshake Invitation
{
"jsonrpc": "2.0",
"id": "1",
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": { "name": "claude-code", "version": "1.0.0" }
}
}
Tool Registry & Call Processing
During initialization, CostAffective registers its available tools: search_code, find_symbol, find_references, find_callers, and get_repository_summary. When the assistant needs repository context, it executes a tool call: tools/call with parameters matching the JSON schema.
Security & Isolation
Because communication occurs over stdio streams, the server operates with several security advantages:
- No Network Ports: Avoids firewall warnings and prevents remote network access.
- Client Lifecycle Control: The process exits automatically when the host editor closes, preventing background memory leaks.
- Host-Controlled Permissions: The server runs with the user's local permissions, preventing privilege escalation.