Skip to content

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.

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.json under mcpServers
  • Codex: ~/.codex/config.toml under mcp_servers

Registration is idempotent — safe to run multiple times.

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:

  1. Restart your MCP host session (Claude/Codex).
  2. Confirm the server is listed (codex mcp list or host equivalent).
  3. Run kj_config (and optionally a short kj_plan) before long tasks.

If auto-registration doesn’t work or you need custom paths:

Add to ~/.claude.json:

{
"mcpServers": {
"karajan-mcp": {
"type": "stdio",
"command": "karajan-mcp"
}
}
}

Karajan Code exposes 23 MCP tools:

ToolRequired paramsDescription
kj_runtaskRun the full coder → sonar → reviewer pipeline
kj_discovertaskPre-execution gap detection with 5 modes (gaps, momtest, wendel, classify, jtbd)
kj_codetaskRun coder-only mode (skip review)
kj_reviewtaskRun reviewer-only mode on the current diff
kj_plantaskGenerate an implementation plan with heartbeat/stall telemetry
kj_resumesessionIdResume a paused, stopped, or failed session
kj_preflighthumanResponseHuman confirms agent config before kj_run/kj_code executes
kj_agentsList or set AI agent per pipeline role (session/project/global scope)
kj_statusLive parsed status of current run (stage, agent, iteration, errors)
kj_reportRead session reports with cost breakdown
kj_scanRun SonarQube scan on the current project
kj_initInitialize config, review rules, SonarQube, and BecarIA scaffolding (--scaffold-becaria)
kj_doctorCheck system dependencies and agent CLIs
kj_configShow current configuration
kj_rolesList pipeline roles or show role templates
kj_triagetaskClassify task complexity and activate roles
kj_researchertaskInvestigate codebase context
kj_architecttaskDesign solution architecture
kj_boardactionStart/stop/status HU Board dashboard
kj_huactionManage user stories (create, update, list, get) in the local HU Board
kj_suggestobservationSend an observation to Solomon without interrupting the pipeline
kj_skillsList, install, or remove domain-specific skills for pipeline roles

See the MCP Tools Reference for complete parameter documentation.

kj_run is the primary tool. It orchestrates the full pipeline and returns structured results.

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"
}
}
{
"tool": "kj_run",
"params": {
"task": "Fix the SQL injection vulnerability in search",
"coder": "claude",
"reviewer": "codex",
"mode": "paranoid",
"methodology": "tdd",
"maxIterations": 5,
"autoCommit": true
}
}
{
"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.

{
"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.

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 completed

Progress 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.

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.

{
"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
}
}

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"
}
}
{
"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.

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)
{
"tool": "kj_report",
"params": { "list": true }
}
{
"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.

Karajan Code works well alongside other MCP servers:

MCPHow it complements Karajan
Planning GameTask management — fetch tasks, update status, track sprints (MCP server)
GitHubPR creation, issue management, CI/CD checks
Chrome DevToolsVisual verification of UI changes after coding
SonarQubeDirect access to quality reports (Karajan has built-in SonarQube, but the MCP adds direct query access)
  1. Agent fetches the highest priority task from Planning Game MCP
  2. Agent sends the task to kj_run
  3. Karajan orchestrates coder → sonar → reviewer
  4. Agent updates the card status to “To Validate” in Planning Game
  5. Agent creates a PR via GitHub MCP

All within a single conversation, fully automated.

ProblemSolution
MCP server not foundRun npm install -g karajan-code to trigger auto-registration
Tools not appearingRestart your AI agent after installation
Connection refusedCheck that karajan-mcp binary is in your PATH
SonarQube errorsRun kj_doctor to diagnose, or use noSonar: true
Session stuckUse kj_report --list to find the session, then kj_resume