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:
49
src/bridge/bootstrap.ts
Normal file
49
src/bridge/bootstrap.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
export type BootstrapInput = {
|
||||
agentId: string;
|
||||
openclawSessionKey: string;
|
||||
workspace: string;
|
||||
/** Skills XML block extracted from the OpenClaw system prompt, if any */
|
||||
skillsBlock?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Build the one-time bootstrap message injected at the start of a new Claude session.
|
||||
* This tells Claude it is operating as an OpenClaw contractor agent.
|
||||
* Must NOT be re-injected on every turn.
|
||||
*/
|
||||
export function buildBootstrap(input: BootstrapInput): string {
|
||||
const lines = [
|
||||
`You are operating as a contractor agent inside OpenClaw.`,
|
||||
``,
|
||||
`## Context`,
|
||||
`- Agent ID: ${input.agentId}`,
|
||||
`- Session key: ${input.openclawSessionKey}`,
|
||||
`- Workspace: ${input.workspace}`,
|
||||
``,
|
||||
`## Role`,
|
||||
`You receive tasks from OpenClaw users and complete them using your tools.`,
|
||||
`You do not need to manage your own session context — OpenClaw handles session routing.`,
|
||||
`Your responses go directly back to the user through OpenClaw.`,
|
||||
``,
|
||||
`## Guidelines`,
|
||||
`- Work in the specified workspace directory.`,
|
||||
`- Be concise and action-oriented. Use tools to accomplish tasks rather than describing what you would do.`,
|
||||
`- Each message you receive contains the latest user request. Previous context is in your session memory.`,
|
||||
`- If a task is unclear, ask one focused clarifying question.`,
|
||||
];
|
||||
|
||||
if (input.skillsBlock) {
|
||||
lines.push(
|
||||
``,
|
||||
`## Skills`,
|
||||
`The following skills are available. When a task matches a skill's description:`,
|
||||
`1. Read the skill's SKILL.md using the Read tool (the <location> field is the absolute path).`,
|
||||
`2. Follow the instructions in SKILL.md. Replace \`{baseDir}\` with the directory containing SKILL.md.`,
|
||||
`3. Run scripts using the Bash tool, NOT the \`exec\` tool (you have Bash, not exec).`,
|
||||
``,
|
||||
input.skillsBlock,
|
||||
);
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
Reference in New Issue
Block a user