Skip to main content
Glama

claude

Destructive

Runs a Claude Code session synchronously from an MCP client, with session resume, git worktree isolation, model and tool controls, and optional structured JSON output.

Instructions

Run a Claude Code (claude -p) session synchronously (or as a native MCP Task when the client advertises io.modelcontextprotocol/tasks). This server applies NO timeout of its own, but legacy MCP clients typically cut a tool call around 300s -- use claude_async + claude_wait for long runs or parallel fan-out on non-Tasks clients.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "prompt": "<prompt>"
    },
    "name": "claude"
  }
}

Input Schema

NameRequiredDescriptionDefault
cwdNoWorking directory for the Claude Code session. If relative, resolved against the server's cwd. On resume, defaults to the original session's cwd/worktree when omitted.
bareNoMinimal headless mode skipping hooks, plugins, CLAUDE.md discovery, and OAuth/keychain reads (passes --bare; requires API key or provider credentials).
agentNoNamed agent for this session (passes --agent).
modelNoOptional model alias or full model name (e.g. 'opus', 'sonnet', 'haiku', 'fable', or a full model identifier). Call claude_models to list available models, resolved IDs, and supported effort levels.
toolsNoBuilt-in tools to expose: "" or [] for none, "default" for the default set, or comma-separated/array tool names (e.g. ["Read","Edit","Bash"]).
agentsNoCustom agents definition (JSON object or file path; passes --agents).
effortNoReasoning effort level for this session.
promptYesThe user prompt for the Claude Code session.
add_dirNoAdditional directories Claude can access (passes repeatable --add-dir).
settingsNoExtra settings to load (JSON object or file path; passes --settings). Prefer file paths over inline credentials.
worktreeNoCreate an isolated git worktree and branch (claude-swarm/<task_id>) based on HEAD so parallel tasks never conflict. Note: branches from HEAD and excludes uncommitted or untracked working-tree changes -- commit them first if the task needs them. Merge the branch back before expiry.
max_turnsNoMaximum number of agentic turns for this invocation (passes --max-turns).
mcp_configNoMCP server configurations to load (array of JSON objects or file paths/JSON strings; passes repeatable --mcp-config).
session_idNoOptional session ID (or session name) from a previous Claude call. When set, resumes that conversation via --resume instead of starting fresh.
json_schemaNoOptional JSON Schema (object or string) passed to --json-schema so Claude Code returns structuredContent.structured_output via its StructuredOutput tool. Callers should verify structured_output is present, as Claude CLI can still exit 0 without it on short-circuited CLI commands or prose fallbacks.
fork_sessionNoWhen resuming via session_id, create a new session ID instead of mutating the original session (passes --fork-session).
allowed_toolsNoTool allow rules (e.g. ["Bash(git *)", "Edit"]; passes --allowed-tools).
system_promptNoReplace the default system prompt (passes --system-prompt).
fallback_modelNoOptional fallback model(s) (comma-separated) when the primary model is busy or unavailable (passes --fallback-model).
max_budget_usdNoMaximum API spend in USD for this invocation (passes --max-budget-usd).
permission_modeNoPermission mode for tool approval (acceptEdits, auto, bypassPermissions, manual, dontAsk, plan).
setting_sourcesNoComma-separated setting sources to load (e.g. "user,project,local", or "" to exclude all user/project/local settings).
disallowed_toolsNoTool deny rules (e.g. ["Bash(rm *)"]; passes --disallowed-tools).
strict_mcp_configNoOnly use MCP servers from mcp_config, ignoring all other MCP configs (passes --strict-mcp-config). Explicit false overrides server default.
append_system_promptNoAppend text to the default system prompt (passes --append-system-prompt).
disable_slash_commandsNoDisable all skills and slash commands (passes --disable-slash-commands). Explicit false overrides server default.
no_session_persistenceNoDo not save the session transcript to disk; cannot be resumed later (passes --no-session-persistence). Explicit false overrides server default.
dangerously_skip_permissionsNoBypass all permission checks (passes --dangerously-skip-permissions). Explicit false overrides server default.

Output Schema

NameRequiredDescriptionDefault
textYes
modelNo
usageNo
effortNo
statusYes
failureNo
exit_codeNo
num_turnsNo
session_idNo
stop_reasonNo
tool_errorsNo
worktree_pathNo
partial_outputNo
result_subtypeNo
permission_modeNo
terminal_reasonNo
worktree_branchNo
duration_secondsNo
structured_outputNo
permission_denialsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already flag destructiveHint=true and openWorldHint=true, so the description doesn't need to restate that this writes/executes. What it does add is non-obvious operational behavior: no server-side timeout, a ~300s client cutoff on legacy MCP clients, and native MCP Task mode. It stops short of describing cost or the fact that arbitrary file/command side effects occur.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, zero filler: the first defines the execution model, the second gives the timeout constraint and the escape hatch. The most decision-relevant fact (300s client cutoff) is front-loaded where an agent will see it.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 28-parameter, destructive, open-world tool with an output schema, the description covers the execution model, the timeout trap, and sibling routing — the pieces an agent can't infer from structured fields. Minor gap: no mention of cost/latency implications or that output must be verified for session resumption, though json_schema's own description covers the structured-output caveat.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% across 28 parameters, so the schema already documents cwd, worktree, session_id, json_schema, and the rest thoroughly. The description adds no parameter-level meaning beyond that, which is acceptable but not additive — baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource — 'Run a Claude Code (`claude -p`) session synchronously' — and immediately scopes it against the async siblings. An agent can distinguish it from claude_async without reading any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly routes the agent: use this tool for sync runs, but 'use claude_async + claude_wait for long runs or parallel fan-out on non-Tasks clients.' It names the alternative and the exact condition that selects it, plus the exception (clients advertising io.modelcontextprotocol/tasks).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.