┌─────────────┐ MCP Protocol ┌──────────────────┐ MCP Protocol ┌────────────┐ XPC ┌─────────┐
│ Cursor │ ◄────────────────► │ xcodemcpwrapper │ ◄──────────────► │ mcpbridge │ ◄───────► │ Xcode │
│ (MCP Client)│ │ (This Project) │ │ (Bridge) │ │ (IDE) │
└─────────────┘ └──────────────────┘ └────────────┘ └─────────┘
- stdin → Wrapper receives MCP requests from client
- Wrapper forwards requests unchanged to mcpbridge
- mcpbridge → Communicates with Xcode via XPC
- stdout → mcpbridge returns responses
- Wrapper detects non-compliant responses (missing
structuredContent) - Wrapper extracts text from
contentarray, parses as JSON - Wrapper injects
structuredContentfield into response - stdout → Client receives compliant MCP response
create_bridge()- Spawns mcpbridge subprocessforward_stdin()- Forwards stdin to bridgeread_stdout()- Reads stdout line-by-linecleanup_bridge()- Handles process termination
process_response_line()- Main transformation entry pointneeds_transformation()- Detects non-compliant responsesextract_text_content()- Extracts text from content arrayinject_structured_content()- Adds structuredContent field
- Sets up stdin/stdout threads
- Runs the main event loop
- Handles cleanup on exit
# Input from mcpbridge (non-compliant)
{
"result": {
"content": [{"type": "text", "text": '{"status": "ok"}'}]
}
}
# Output from wrapper (MCP compliant)
{
"result": {
"content": [{"type": "text", "text": '{"status": "ok"}'}],
"structuredContent": {"status": "ok"}
}
}- Line-buffered I/O for minimal latency
- Average overhead: <0.01ms per transformation
- Memory usage: <10MB
For a full reference on the SQLite metrics database, in-memory collector, and audit log files, see Data Storage Reference.