MCP Server
The most powerful way to use Karajan Code is as an MCP server inside your AI agent. Instead of switching between terminals and copy-pasting outputs, your agent sends tasks directly to kj_run and receives structured results — all within the conversation.
Auto-registration
Section titled “Auto-registration”After npm install -g karajan-code, the MCP server automatically registers in Claude Code and Codex. No manual setup required.
The postinstall hook writes the server configuration to:
- Claude Code:
~/.claude.jsonundermcpServers - Codex:
~/.codex/config.tomlundermcp_servers
Registration is idempotent — safe to run multiple times.
After updates: Transport closed
Section titled “After updates: Transport closed”If you upgrade Karajan Code while your MCP host session is still open, the current karajan-mcp process may exit and the host can show Transport closed.
This is expected: Karajan MCP exits stale processes after version changes so the host can restart with fresh code.
Quick recovery:
- Restart your MCP host session (Claude/Codex).
- Confirm the server is listed (
codex mcp listor host equivalent). - Run
kj_config(and optionally a shortkj_plan) before long tasks.
Manual configuration
Section titled “Manual configuration”If auto-registration doesn’t work or you need custom paths:
Add to ~/.claude.json:
{ "mcpServers": { "karajan-mcp": { "type": "stdio", "command": "karajan-mcp" } }}Add to ~/.codex/config.toml:
[mcp_servers."karajan-mcp"]command = "karajan-mcp"Start the server via stdio:
karajan-mcpOr with an explicit path:
node /path/to/karajan-code/src/mcp/server.jsAvailable tools
Section titled “Available tools”Karajan Code exposes 23 MCP tools:
| Tool | Required params | Description |
|---|---|---|
kj_run | task | Run the full coder → sonar → reviewer pipeline |
kj_discover | task | Pre-execution gap detection with 5 modes (gaps, momtest, wendel, classify, jtbd) |
kj_code | task | Run coder-only mode (skip review) |
kj_review | task | Run reviewer-only mode on the current diff |
kj_plan | task | Generate an implementation plan with heartbeat/stall telemetry |
kj_resume | sessionId | Resume a paused, stopped, or failed session |
kj_preflight | humanResponse | Human confirms agent config before kj_run/kj_code executes |
kj_agents | — | List or set AI agent per pipeline role (session/project/global scope) |
kj_status | — | Live parsed status of current run (stage, agent, iteration, errors) |
kj_report | — | Read session reports with cost breakdown |
kj_scan | — | Run SonarQube scan on the current project |
kj_init | — | Initialize config, review rules, SonarQube, and BecarIA scaffolding (--scaffold-becaria) |
kj_doctor | — | Check system dependencies and agent CLIs |
kj_config | — | Show current configuration |
kj_roles | — | List pipeline roles or show role templates |
kj_triage | task | Classify task complexity and activate roles |
kj_researcher | task | Investigate codebase context |
kj_architect | task | Design solution architecture |
kj_board | action | Start/stop/status HU Board dashboard |
kj_hu | action | Manage user stories (create, update, list, get) in the local HU Board |
kj_suggest | observation | Send an observation to Solomon without interrupting the pipeline |
kj_skills | — | List, install, or remove domain-specific skills for pipeline roles |
See the MCP Tools Reference for complete parameter documentation.
Using kj_run
Section titled “Using kj_run”kj_run is the primary tool. It orchestrates the full pipeline and returns structured results.
Basic usage
Section titled “Basic usage”From your AI agent, simply ask:
“Use kj_run to add input validation to the signup form”
The agent calls:
{ "tool": "kj_run", "params": { "task": "Add input validation to the signup form" }}With options
Section titled “With options”{ "tool": "kj_run", "params": { "task": "Fix the SQL injection vulnerability in search", "coder": "claude", "reviewer": "codex", "mode": "paranoid", "methodology": "tdd", "maxIterations": 5, "autoCommit": true }}With BecarIA Gateway
Section titled “With BecarIA Gateway”{ "tool": "kj_run", "params": { "task": "Add input validation to the signup form", "enableBecaria": true }}When enableBecaria is true, Karajan creates an early draft PR after the first coder iteration and all agents (Coder, Reviewer, Sonar, Solomon, Tester, Security, Planner) post their results as PR comments/reviews. Configurable dispatch events trigger GitHub Actions workflows at each pipeline stage.
With Planning Game integration
Section titled “With Planning Game integration”{ "tool": "kj_run", "params": { "task": "Implement user authentication", "pgTask": "PRJ-TSK-0042", "pgProject": "MyProject" }}The tool fetches the full card context (description, acceptance criteria) from Planning Game.
Real-time progress
Section titled “Real-time progress”During execution, Karajan sends real-time progress notifications via MCP logging. Your agent sees updates as each stage completes:
[1] coder:start — Writing code and tests...[1] coder:end — Code generation complete[1] sonar:start — Running SonarQube analysis...[1] sonar:end — Quality gate passed[1] reviewer:start — Reviewing code...[1] reviewer:end — APPROVED[1] session:end — Pipeline completedProgress stages include: session:start, iteration:start, planner:start/end, coder:start/end, refactorer:start/end, tdd:result, sonar:start/end, reviewer:start/end, iteration:end, solomon:escalate, question, session:end, pipeline:tracker.
Cumulative pipeline tracker
Section titled “Cumulative pipeline tracker”In addition to individual stage events, Karajan emits a pipeline:tracker event after every stage transition with the full cumulative state:
{ "type": "pipeline:tracker", "detail": { "stages": [ { "name": "triage", "status": "done", "summary": "medium" }, { "name": "coder", "status": "running", "summary": "claude/sonnet" }, { "name": "sonar", "status": "pending" }, { "name": "reviewer", "status": "pending" } ] }}This lets MCP hosts render a single progress widget showing all stages at a glance, instead of interpreting individual events.
For single-agent tools (kj_code, kj_review, kj_plan), tracker start/end logs are also emitted via sendLoggingMessage.
Response format
Section titled “Response format”Successful run
Section titled “Successful run”{ "ok": true, "sessionId": "s_2026-02-28T20-47-24-270Z", "approved": true, "review": { "status": "approved", "summary": "Code meets all standards", "issues": [], "suggestions": ["Consider extracting validation to a helper"] }, "git": { "committed": true, "commits": ["abc123"], "branch": "feat/signup-validation", "pushed": false }}Paused session
Section titled “Paused session”When fail-fast detection triggers or clarification is needed:
{ "ok": false, "paused": true, "sessionId": "s_2026-02-28T20-47-24-270Z", "question": "The reviewer rejected the same issue twice. Should we proceed?", "context": "reviewer_fail_fast"}Resume with kj_resume:
{ "tool": "kj_resume", "params": { "sessionId": "s_2026-02-28T20-47-24-270Z", "answer": "Yes, proceed with the current approach" }}Error response
Section titled “Error response”{ "ok": false, "error": "SonarQube is not reachable", "tool": "kj_run", "category": "sonar_unavailable", "suggestion": "Try: docker start sonarqube, or use noSonar: true"}Error categories: sonar_unavailable, auth_error, config_error, agent_missing, timeout, git_error.
Session management
Section titled “Session management”Sessions persist to disk at $KJ_HOME/sessions/{sessionId}/. This enables:
- Pause/resume across agent conversations
- Cost tracking per session with
kj_report - Auto-cleanup of sessions older than
session.expiry_days(default: 30)
Listing sessions
Section titled “Listing sessions”{ "tool": "kj_report", "params": { "list": true }}Cost breakdown
Section titled “Cost breakdown”{ "tool": "kj_report", "params": { "sessionId": "s_2026-02-28T20-47-24-270Z", "trace": true, "currency": "usd" }}Returns a stage-by-stage breakdown with timing, tokens, and costs.
Companion MCPs
Section titled “Companion MCPs”Karajan Code works well alongside other MCP servers:
| MCP | How it complements Karajan |
|---|---|
| Planning Game | Task management — fetch tasks, update status, track sprints (MCP server) |
| GitHub | PR creation, issue management, CI/CD checks |
| Chrome DevTools | Visual verification of UI changes after coding |
| SonarQube | Direct access to quality reports (Karajan has built-in SonarQube, but the MCP adds direct query access) |
Workflow example with Planning Game
Section titled “Workflow example with Planning Game”- Agent fetches the highest priority task from Planning Game MCP
- Agent sends the task to
kj_run - Karajan orchestrates coder → sonar → reviewer
- Agent updates the card status to “To Validate” in Planning Game
- Agent creates a PR via GitHub MCP
All within a single conversation, fully automated.
Troubleshooting
Section titled “Troubleshooting”| Problem | Solution |
|---|---|
| MCP server not found | Run npm install -g karajan-code to trigger auto-registration |
| Tools not appearing | Restart your AI agent after installation |
| Connection refused | Check that karajan-mcp binary is in your PATH |
| SonarQube errors | Run kj_doctor to diagnose, or use noSonar: true |
| Session stuck | Use kj_report --list to find the session, then kj_resume |