feat: implement MCP proxy for OpenClaw tool access in contractor agent

Complete the MCP tool call chain:
- contractor-agent bridge exposes /mcp/execute endpoint for tool callbacks
- openclaw-mcp-server.mjs proxies OpenClaw tool defs to Claude as MCP tools
- sdk-adapter passes --mcp-config on first turn with all OpenClaw tools
- tool-test plugin registers contractor_echo in globalThis tool handler map
- agent-config-writer auto-sets tools.profile=full so OpenClaw sends tool defs
- Fix --mcp-config arg ordering: prompt must come before <configs...> flag

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
h z
2026-04-11 13:05:03 +01:00
parent f7c5875eeb
commit 76a7931f97
24 changed files with 12935 additions and 256 deletions

View File

@@ -372,6 +372,25 @@ export type ContractorBridgeModelRequest = {
Exact fields depend on how OpenClaw provider/model requests are exposed in runtime.
## Implementation notes from probe testing
See BRIDGE_MODEL_FINDINGS.md for full details. Key constraints that affect implementation:
- The sidecar MUST support SSE streaming (`stream: true` always sent by OpenClaw). Non-streaming
responses cause OpenClaw to drop assistant history from subsequent turns.
- OpenClaw sends the full system prompt (~28K chars) rebuilt on every turn. The input filter
must strip this and extract only the latest user message.
- User message format from OpenClaw: `[Day YYYY-MM-DD HH:MM TZ] message text`
- Claude session continuation uses UUID from `@anthropic-ai/claude-agent-sdk` `message.session_id`.
Resume via `options: { resume: sessionId }`.
- Custom model is registered via `openclaw.json` provider config, not a plugin SDK call.
The install script must write the provider entry and set `baseUrl` to the sidecar port.
## Revised milestone order
Milestone 3 (bridge model) is moved before Milestone 2 (CLI) because the bridge sidecar is the
load-bearing component. Everything else depends on confirming it works end-to-end.
## Suggested implementation order
## Milestone 1, project skeleton