Native MCP Client Support
apfel now natively speaks the Model Context Protocol. Attach tool servers with --mcp:
apfel --mcp ./mcp/calculator/server.py "What is 15 times 27?"
# tool: multiply({"a": 15, "b": 27}) = 405
# 15 times 27 is 405.What's new
--mcp <path>flag - attach MCP tool servers (repeatable). Works in all three modes: CLI, server, chat.- Auto-discovery - tools are discovered via MCP
tools/listat startup - Auto-execution - tool calls are detected, executed via the MCP server, and results fed back to the model
- Zero overhead - no
--mcp= exactly as before, no extra tokens, no code path changes - Server mode -
apfel --serve --mcp ./calc.pyauto-injects tools when clients don't send their own - Ships with calculator MCP -
mcp/calculator/server.pygives the model math abilities
Architecture
Sources/Core/MCPProtocol.swift- JSON-RPC 2.0 protocol handling (pure Swift, unit-testable)Sources/MCPClient.swift- MCPConnection (subprocess management) + MCPManager (actor)- 13 new MCP protocol unit tests
- 118 total unit tests + 87 integration tests pass
Examples
# CLI - one command, answer out
apfel --mcp ./mcp/calculator/server.py "What is 2 to the power of 10?"
# tool: power({"base": 2, "exponent": 10}) = 1024
# 2 to the power of 10 is 1024.
# Server - tools auto-available
apfel --serve --mcp ./mcp/calculator/server.py
# Multiple servers
apfel --mcp ./calc.py --mcp ./weather.py "What is sqrt(2025)?"
# No --mcp = zero changes
apfel "Hello"See docs/mcp-calculator.md for full documentation.