Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MCP Interface

Tinytown exposes a full Model Context Protocol (MCP) interface, allowing AI tools like Claude Desktop, Cursor, and other MCP clients to directly orchestrate agent towns.

Quick Start

Claude Desktop Integration

Add to ~/.config/claude/claude_desktop_config.json:

{
  "mcpServers": {
    "tinytown": {
      "command": "townhall",
      "args": ["mcp-stdio", "--town", "/path/to/your/project"]
    }
  }
}

Restart Claude Desktop. You can now ask Claude to manage your agent town!

HTTP/SSE Mode

For browser-based MCP clients:

townhall mcp-http --port 8788
# MCP endpoint: http://localhost:8788

Available Tools

MCP tools provide programmatic access to all Tinytown operations:

Read-Only Tools (town.read scope)

ToolDescription
town.get_statusGet town status including all agents
agent.listList all agents with current status
backlog.listList all tasks in the backlog

Write Tools (town.write scope)

ToolDescription
task.assignAssign a task to an agent
task.completeMark a task as completed
message.sendSend a message to an agent
backlog.addAdd a task to the backlog
backlog.claimClaim a backlog task for an agent
backlog.assign_allAssign all backlog tasks to an agent

Agent Management Tools (agent.manage scope)

ToolDescription
agent.spawnSpawn a new agent
agent.killKill (stop) an agent gracefully
agent.restartRestart a stopped agent
recovery.recover_agentsRecover orphaned agents
recovery.reclaim_tasksReclaim tasks from dead agents

Resources

MCP resources provide read-only data access:

Resource URIDescription
tinytown://town/currentCurrent town state
tinytown://agentsList of all agents
tinytown://agents/{name}Specific agent details
tinytown://backlogCurrent backlog
tinytown://tasks/{id}Specific task details

Prompts

MCP prompts provide templated interactions:

PromptDescription
conductor.startup_contextContext for conductor startup
agent.role_hintRole hints for agents

Example Conversation

With MCP configured, you can have natural conversations with Claude:

You: “Spawn two backend agents and assign them bug fixes”

Claude: I’ll create two backend agents and assign tasks to them. [Uses agent.spawn tool twice, then task.assign tool] Done! I’ve spawned backend-1 and backend-2 and assigned bug fix tasks to each.

You: “What’s the status of the town?”

Claude: [Uses town.get_status tool] Your town has 2 agents running:

  • backend-1: Working, 3 tasks completed
  • backend-2: Working, 2 tasks completed

Tool Response Format

All tools return JSON with consistent structure:

{
  "success": true,
  "data": {
    "agent_id": "abc123...",
    "name": "worker-1",
    "cli": "claude"
  }
}

On error:

{
  "success": false,
  "error": "Agent 'worker-99' not found"
}

Transports

TransportCommandBest For
stdiotownhall mcp-stdioClaude Desktop, IDE extensions
HTTP/SSEtownhall mcp-httpBrowser clients, remote access

stdio Transport

Used by most desktop applications. The MCP server reads JSON-RPC from stdin and writes to stdout.

HTTP/SSE Transport

Uses Server-Sent Events for server-to-client messages and HTTP POST for client-to-server messages.

# Start on custom port
townhall mcp-http --bind 0.0.0.0 --port 8788