MCP Server

Model Context Protocol server that exposes consensus-tools as tools, resources, and prompts for LLM agents.

Overview

@consensus-tools/mcp is a Model Context Protocol (MCP) server that gives Claude Code or any MCP-compatible client access to the full consensus-tools stack. It registers 29 tools across six categories, plus resources and prompts for guided interactions.

Installation

pnpm add @consensus-tools/mcp

Quick start

Claude Code integration

Add to your .claude/settings.local.json:

{
  "mcpServers": {
    "consensus-tools": {
      "command": "npx",
      "args": ["@consensus-tools/mcp"]
    }
  }
}

With environment configuration:

{
  "mcpServers": {
    "consensus-tools": {
      "command": "npx",
      "args": ["@consensus-tools/mcp"],
      "env": {
        "CONSENSUS_STORAGE_PATH": "/path/to/state.json",
        "CONSENSUS_AGENT_ID": "my-agent"
      }
    }
  }
}

Zero config by default

Without any environment variables, the MCP server stores state at ~/.local/share/consensus-tools/state.json and uses mcp-agent as the default agent identity.

Programmatic usage

import { createMcpServer, startMcpServer } from "@consensus-tools/mcp";
import {
  JobEngine, LedgerEngine, AgentRegistry,
  GuardEngine, HitlTracker, createStorage
} from "@consensus-tools/core";
import type { McpContext } from "@consensus-tools/mcp";

const storage = await createStorage(config);
const ctx: McpContext = {
  engine: new JobEngine(storage, ledger, config),
  agentRegistry: new AgentRegistry(storage),
  guardEngine: new GuardEngine({ storage }),
  hitlTracker: new HitlTracker({ storage }),
  storage,
  agentId: "my-agent",
};

// Option 1: start on stdio (typical for MCP)
await startMcpServer(ctx);

// Option 2: get the server instance for custom transport
const server = createMcpServer(ctx);

Environment variables

VariableDefaultDescription
CONSENSUS_STORAGE_PATH~/.local/share/consensus-tools/state.jsonPath to the JSON state file
CONSENSUS_AGENT_IDmcp-agentAgent identity for consensus operations

MCP tools (29 total)

The server registers tools across six categories:

Guard tools

Evaluate agent actions against policies before execution.

ToolDescription
guard.evaluateEvaluate an action against guard policies
guard.explainExplain why an action was blocked or allowed

Agent tools

Manage agent identities, scopes, and lifecycle.

ToolDescription
agent.createRegister a new agent
agent.listList all registered agents
agent.suspendSuspend an agent

Consensus tools

Full job lifecycle from posting through resolution.

ToolDescription
consensus_post_jobPost a new job with reward and policy
consensus_claimClaim an open job
consensus_submitSubmit artifacts to a claimed job
consensus_voteVote on a submission
consensus_resolveResolve a job according to its policy

HITL tools

Human-in-the-loop approval flows.

ToolDescription
human.request_approvalRequest human approval for an action
human.check_statusCheck the status of a pending approval

Board tools

Query board state and audit trails.

ToolDescription
board.statusGet overall board status
run.listList recent runs
audit.queryQuery the audit trail

Workflow tools

Create and execute DAG-based workflows.

ToolDescription
workflow.createCreate a new workflow definition
workflow.runExecute a workflow
cron.registerRegister a cron schedule for a workflow

Resources and prompts

Beyond tools, the MCP server also exposes resources (board state, job details) and prompts for guided interactions with LLM agents.

API reference

createMcpServer(ctx)

Creates an MCP Server instance with all tools, resources, and prompts registered. Returns the server without connecting a transport.

startMcpServer(ctx)

Creates the server and connects it via stdio transport. This is the standard entry point when running as an MCP server process.

McpContext

PropertyRequiredDescription
engineYesJobEngine
agentRegistryYesAgentRegistry
guardEngineYesGuardEngine
hitlTrackerYesHitlTracker
storageYesIStorage
agentIdYesDefault agent identity
workflowRunnerNoWorkflowRunner for workflow tools
cronSchedulerNoCronScheduler for cron tools
  • OpenClaw -- Alternative agent adapter via the OpenClaw plugin system
  • SDK Node -- REST API server (MCP uses the same engines directly)
  • Local Board -- Local dev server to pair with MCP during development