Parent: #41 | Split: stdio transport + auto-discovery
Problem
This is part 1 of #41 (MCP Driver). It covers the stdio transport — connecting to local MCP servers via subprocess — and the auto-discovery mechanism that converts MCP tools/list results into kernel Capability objects.
Proposed Change
1. MCPDriver core + stdio transport
class MCPDriver:
"""Driver that connects to an MCP server and executes tool calls."""
async def execute(self, operation: str, params: dict, constraints: dict) -> Any:
"""Map operation → tools/call, apply constraints, return result."""
- stdio transport: Connect to local MCP servers via
mcp.client.stdio.stdio_client.
- Factory method:
MCPDriver.from_stdio(command, args).
- Async context manager for connection lifecycle.
2. Auto-discovery
MCPDriver.discover() -> list[Capability]: Call tools/list, convert each MCP tool to a Capability.
capability_id = tool name, description from MCP tool, safety_class = READ (overridable).
3. Response handling
- Convert MCP
CallToolResult content blocks to dicts for the firewall.
- Handle
isError by raising DriverError.
Acceptance Criteria
Affected Files
src/agent_kernel/drivers/mcp.py (new)
src/agent_kernel/drivers/__init__.py (export)
tests/test_drivers.py (integration tests)
pyproject.toml (optional dep)
Parent: #41 | Split: stdio transport + auto-discovery
Problem
This is part 1 of #41 (MCP Driver). It covers the stdio transport — connecting to local MCP servers via subprocess — and the auto-discovery mechanism that converts MCP
tools/listresults into kernelCapabilityobjects.Proposed Change
1. MCPDriver core + stdio transport
mcp.client.stdio.stdio_client.MCPDriver.from_stdio(command, args).2. Auto-discovery
MCPDriver.discover() -> list[Capability]: Calltools/list, convert each MCP tool to aCapability.capability_id= tool name,descriptionfrom MCP tool,safety_class=READ(overridable).3. Response handling
CallToolResultcontent blocks to dicts for the firewall.isErrorby raisingDriverError.Acceptance Criteria
MCPDriver.from_stdio()connects to a local MCP server processdiscover()converts MCP tools toCapabilityobjects with correct metadataexecute()calls MCP tools and returns results through the firewall pipelineDriverErrorwith descriptive messagemcp>=1.0added as optional dependencyImportErrorwhenmcppackage not installedAffected Files
src/agent_kernel/drivers/mcp.py(new)src/agent_kernel/drivers/__init__.py(export)tests/test_drivers.py(integration tests)pyproject.toml(optional dep)