Turn harness internal tools into a standard MCP server — compatible with Claude Code, Codex, OpenCode, and more.
Project description
harness_to_mcp: exposes harness internal tools as an MCP server by hijacking LLM API.
What it does
- starts one MCP HTTP server and one hijack API server on the same port
- starts one harness process per MCP session
- extracts the harness tool list from intercepted LLM requests
- forwards MCP
tools/callinto the harness tool loop and maps the tool result back to MCP - stops the harness process when the MCP session is closed
Supported harnesses
harness_to_mcp opencodevia OpenAI chat completionsharness_to_mcp codexvia OpenAI responses APIharness_to_mcp claudevia Anthropic messages API
Exposed endpoints
- MCP:
POST /mcp,POST /harness_to_mcp/mcp(The two MCP paths are equivalent) - Models:
GET /harness_to_mcp/v1/models - OpenAI Chat Completions:
POST /harness_to_mcp/v1/chat/completions - OpenAI Responses:
POST /harness_to_mcp/v1/responses - Anthropic Messages:
POST /harness_to_mcp/v1/messages
Sequence
sequenceDiagram
participant C as MCP Client
participant M as harness_to_mcp<br/>MCP Server
participant H as harness_to_mcp<br/>Hijack API Server
participant R as Harness
C->>M: initialize
M->>R: launch harness session
R->>H: send hijacked LLM API request
H-->>M: extract tool list from request
M-->>C: tools/list
C->>M: tools/call
M-->>H: resolve waiting request as tool call
H-->>R: return tool call payload
R->>R: execute internal tool
R->>H: send next request with tool result
H-->>M: match tool_call_id and deliver tool result
M-->>C: MCP tool response
Install
pip install harness_to_mcp
Run the server
harness_to_mcp
This mode starts only the server. It listens on MCP plus all hijack API routes, but does not launch any harness by itself.
Launch a harness directly
harness_to_mcp claude/codex/opencode
Each helper command starts its own colocated server and one harness instance together. If the harness exits later, the server process keeps running.
Python API
from harness_to_mcp import HarnessToMcp
with HarnessToMcp(port=9330) as server:
print(server.mcp_url)
print(server.hijack_base_url)
print(server.anthropic_base_url)
Notes
- the LLM API layer is split into reusable adapters for chat completions, responses, and messages
- the harness layer is split into reusable launchers for
opencode,codex, andclaude - plain server mode never auto-launches a harness
- intercepted waiting requests stay alive with periodic heartbeat bytes while MCP is deciding the next tool call
- if the harness does not reconnect to the hijack API within 30 seconds, MCP requests fail with a hijack-not-connected error
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 Distribution
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 harness_to_mcp-0.1.0.tar.gz.
File metadata
- Download URL: harness_to_mcp-0.1.0.tar.gz
- Upload date:
- Size: 21.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e055c691e30501f4e0b1f27a39e3e90b1b238c5f4c6983515a4dfe962322ddf9
|
|
| MD5 |
76bb25859e409978feca349ffd43e383
|
|
| BLAKE2b-256 |
4aa7ad8cda0e3f163f0706ebd6e6a97379e6391718bcdff7660abc949445055e
|
File details
Details for the file harness_to_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: harness_to_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bf00c2606fd72510a585c6dfb83146904f18017e3fe3ee835165bff17f5c626
|
|
| MD5 |
ee51be20550b34b8cb4a52e0a4d74d2f
|
|
| BLAKE2b-256 |
492ea12eeccddaea9111b0f208f17c43ad0770f90cc5cb3bcd58c86001ebd78a
|