Rust MCP server that lets any bot framework (OpenClaw, Hermes, Nanobot, etc.) harness Claude Code CLI's coding power via stream-json session management
Server defines 5 tools with explicit schemas and descriptions. Naming follows verb_noun pattern (claude_create, claude_ask, claude_kill, claude_list). Descriptions are detailed (200-400 chars) and explain WHAT, WHEN, and HOW. However, parameter descriptions lack specificity on constraints (e.g., no format/length rules for 'cwd', no enum for 'allow'). Output schemas are documented in descriptions but not formally in JSON Schema. Error handling is minimal, no recovery guidance or categorization. Security concern: claude_respond_permission accepts 'answer' parameter without validation, risking injection. Tool composition is reasonable but claude_ask conflates two concerns (send prompt + handle permissions), violating single-responsibility principle.
Send a prompt to Claude and wait for the complete reply. This is the primary tool for interacting with Claude. Supports multi-turn conversation — just call it again with the same session_id to continue the conversation. Parameters: - id: Session ID from claude_create - prompt: The question or instruction for Claude - auto_approve: Whether to automatically approve Claude's tool permission requests (Bash, Write, Edit, etc.). Default true. Set to false if you want to manually review and approve/deny each tool call via claude_respond_permission. Returns one of: 1. Claude's reply text (normal case) 2. A JSON object with type="permission_request" (when auto_approve=false and Claude requests permission to use a tool). The object contains: - request_id: Pass this to claude_respond_permission - tool_name: The tool Claude wants to use (e.g., "Bash", "Write", "AskUserQuestion") - input: The tool's input parameters - is_ask_user_question: true if Claude is asking the user to choose from options - questions: Array of {question, options: [{label, description}]} (only if is_ask_user_question) When you get a permission_request: 1. Review the tool_name and input 2. Call claude_respond_permission(id, request_id, allow, answer?) to respond 3. Call claude_ask(id, "") with empty prompt to get Claude's continued response For AskUserQuestion (is_ask_user_question=true): - Present the questions and options to the user - Call claude_respond_permission with allow=true and answer=selected option label - Then call claude_ask(id, "") to get Claude's response to the answer
Create a new Claude CLI session. Starts a Claude CLI subprocess in stream-json mode that stays alive for multi-turn conversation. The session maintains full conversation history — call claude_ask multiple times to have a continuous conversation. Parameters: - cwd: Working directory for Claude (optional, defaults to the MCP server's current directory). Claude will operate in this directory — file operations, git commands, etc. all happen here. Returns: {"session_id": "session-xxxxxxxx", "status": "created", "cwd": "..."} The session stays alive until claude_kill is called or the MCP server process exits. Each session is independent — you can create multiple sessions in different directories.
claude_ask conflates two responsibilities: sending prompts AND handling permission workflows. Should split into separate tools (claude_ask for prompts, claude_handle_permission for responses) to follow single-responsibility principle.
Parameter 'answer' in claude_respond_permission lacks validation rules. No length limits, format constraints, or injection guards documented. LLM could pass arbitrary strings, risking command injection into Claude CLI.
No error recovery guidance. Errors return raw messages (e.g., 'Session not found') without suggesting next steps. LLM cannot self-correct, should include 'Call claude_create first' or list available sessions.
claude_list description is minimal (50 chars). Does not explain when to call it, what structure it returns, or how to use results. Should document return format (array of session objects with fields).
Inferred effective spec: <=2025-11-25.
| Scored | Grade | Overall | Spec posture | Rubric |
|---|---|---|---|---|
| 2026-09-23 | D | 55 | <=2025-11-25 | v2 |
Close a Claude session and terminate the CLI process. Frees all resources associated with the session. The session cannot be reused after killing — create a new one with claude_create. Parameters: id (session ID from claude_create). Returns: {"session_id": "...", "status": "killed"}.
List Claude sessions (active and historical).
Respond to a permission request or AskUserQuestion from Claude. Use this after claude_ask returns a permission_request object. Parameters: - id: Session ID - request_id: The request_id from the permission_request response - allow: true to approve the tool call, false to deny (optional, default true) - answer: For AskUserQuestion only — the selected answer text. This should be the exact label string from the options array (e.g., if options are [{label:"pizza"}, {label:"sushi"}], pass answer="pizza"). For regular permission requests (Bash, Write, etc.), omit this parameter. After calling this, call claude_ask(id, "") with an empty prompt to get Claude's continued response. Claude will process the permission decision and continue its work. Example flow for regular permission: 1. claude_ask(id, "delete temp files") → permission_request {tool_name:"Bash", ...} 2. claude_respond_permission(id, request_id, allow=true) 3. claude_ask(id, "") → Claude executes the command and replies Example flow for AskUserQuestion: 1. claude_ask(id, "ask me what to eat") → permission_request {is_ask_user_question:true, questions:[...]} 2. claude_respond_permission(id, request_id, allow=true, answer="pizza") 3. claude_ask(id, "") → Claude responds to the user's choice
Output schemas documented in descriptions but not formally declared in JSON Schema. LLM cannot parse return structure programmatically, must infer from text. Should add explicit 'returns' schema to tool definitions.