CHP capability adapter — wraps Model Context Protocol (MCP) server tools as governed CHP capabilities
Project description
chp-adapter-mcp
The inbound MCP bridge for the Capability Host Protocol. Connects to an
external Model Context Protocol server,
discovers its tools, and registers each one as a governed CHP capability
(chp.adapters.mcp.<server>.<tool>) with full execution evidence.
This complements the TypeScript outbound bridges (@auxo/chp-runtime-mcp),
which expose CHP capabilities as MCP tools. Together they make CHP and MCP
interoperate in both directions:
- outbound (TS): CHP capability → MCP tool
- inbound (this package): MCP tool → CHP capability
Install
pip install chp-adapter-mcp
Usage
from chp_core import LocalCapabilityHost, register_adapter
from chp_adapter_mcp import MCPAdapter, MCPServerConfig
host = LocalCapabilityHost()
adapter = MCPAdapter(MCPServerConfig(
name="filesystem",
command="npx",
args=["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
))
register_adapter(host, adapter)
# Every tool the server exposes is now a CHP capability:
result = host.invoke("chp.adapters.mcp.filesystem.read_file", {"path": "/tmp/x"})
The MCP tool's own JSON Schema becomes the capability input_schema, so
chp-core validates arguments before the tool runs and emits a full evidence
chain (execution_started → mcp_tool_called → mcp_tool_result → execution_completed, or execution_failed).
Design notes
- Each
MCPAdapterowns one MCP server connection on a dedicated background thread + event loop (_ThreadedMCPSession), because the host runs handlers viaasyncio.run(a fresh loop per call) and an MCP session is loop-bound. - The session is abstracted behind a small protocol so it can be faked in tests without spawning a subprocess.
MCPAdapterrequires a server config, so register it manually withregister_adapter(host, MCPAdapter(config)). It is also declared under thechp.adaptersentry-point group for discovery/introspection.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chp_adapter_mcp-0.10.0-py3-none-any.whl.
File metadata
- Download URL: chp_adapter_mcp-0.10.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95b18f8485dfbe07f9d8c3c390bd42f541a5ff0737c2d5e02234548b83946012
|
|
| MD5 |
51f12c0a510a2871bf86a1bf50c6a9f9
|
|
| BLAKE2b-256 |
c4d2500e73040a3310bf6d2630f82449e785d76889c150b4db7577f30a45d832
|