Multi-agent collaborative reasoning that's auditable. Thoughtbox is a Docker-based MCP server where AI agents coordinate through shared workspaces ā claiming problems, proposing solutions, reviewing each other's work, and reaching consensus. Every step is recorded as a structured thought in a persistent reasoning ledger that can be visualized, exported, and analyzed.
Local-First: Runs entirely on your machine. All data stays at ~/.thoughtbox/ ā nothing leaves your network.
Observatory UI showing a reasoning session with 14 thoughts and a branch exploration (purple nodes 13-14) forking from thought 5.
Thoughtbox exposes exactly two MCP tools using the Code Mode pattern:
thoughtbox_searchā Write JavaScript to query the operation/prompt/resource catalog. The LLM has full programmatic filtering power over the catalog.thoughtbox_executeā Write JavaScript using thetbSDK to chain operations. Access thoughts, sessions, knowledge, notebooks, hub, observability, and protocol tools through a unified namespace.
Workflow: search to discover available operations, then execute code against them. Use console.log() for debugging ā output is captured in response logs.
This replaces per-operation tool registration with a two-tool surface that scales without context window bloat.
The Hub is the coordination layer. Agents register with role-specific profiles, join shared workspaces, and work through a structured problem-solving workflow ā all via thoughtbox_execute.
The workflow: register ā create workspace ā create problem ā claim ā work ā propose solution ā peer review ā merge ā consensus
Workspace primitives:
- Problem ā A unit of work with dependencies, sub-problems, and status tracking (open ā in-progress ā resolved ā closed)
- Proposal ā A proposed solution with a source branch reference and review workflow
- Consensus ā A decision marker tied to a thought reference for traceability
- Channel ā A message stream scoped to a problem for discussion
Agent Profiles: MANAGER, ARCHITECT, DEBUGGER, SECURITY, RESEARCHER, REVIEWER ā each provides domain-specific mental models and behavioral priming.
28 operations across identity, workspace management, problems, proposals, consensus, channels, and status reporting.
Every thought is a node in a graph ā numbered, timestamped, linked to its predecessors, and persisted across sessions. This creates an auditable trail of how conclusions were reached.
Agents can think forward, plan backward, branch into parallel explorations, revise earlier conclusions, and request autonomous critique via MCP sampling. Each pattern is a first-class operation:
| Pattern | Description | Use Case |
|---|---|---|
| Forward | Sequential 1ā2ā3āN progression | Exploration, discovery, open-ended analysis |
| Backward | Start at goal (N), work back to start (1) | Planning, system design, working from known goals |
| Branching | Fork into parallel explorations (A, B, C...) | Comparing alternatives, A/B scenarios |
| Revision | Update earlier thoughts with new information | Error correction, refined understanding |
| Critique | Autonomous LLM review via MCP sampling | Self-checking, quality gates |
Each thought carries a semantic thoughtType (reasoning, decision_frame, action_report, belief_snapshot, assumption_update, context_snapshot, progress) that classifies what kind of thought it is, orthogonal to the process pattern used.
See the Patterns Cookbook for comprehensive examples.
The Observatory is a built-in web UI at http://localhost:1729 for watching reasoning unfold live.
- Live Graph ā thoughts appear as nodes in real-time via WebSocket
- Branch Navigation ā branches collapse into clickable stubs; drill in and back out
- Detail Panel ā click any node to view full thought content
- Multi-Session ā switch between active reasoning sessions
- Deep Analysis ā analyze sessions for reasoning patterns, cognitive load, and decision points
The full observability stack includes OpenTelemetry tracing, Prometheus metrics, and Grafana dashboards.
Knowledge Graph ā Persistent memory across sessions. Capture insights, concepts, workflows, and decisions as typed entities with typed relations (BUILDS_ON, CONTRADICTS, SUPERSEDES, etc.) and visibility controls (public, agent-private, team-private).
Notebooks ā Interactive literate programming combining documentation with executable JavaScript/TypeScript in isolated environments.
Thoughtbox is currently optimized for Claude Code. We are actively working on supporting additional MCP clients. Due to variation in capability support across the MCP ecosystem ā server features (prompts, resources, tools), client features (roots, sampling, elicitation), and behaviors like
listChangednotifications ā we implement custom adaptations for many clients.
If you're using a client other than Claude Code and encounter issues, please open an issue describing your client and the problem.
Thoughtbox runs as a Docker-based MCP server. It requires Docker and Docker Compose.
git clone https://github.com/Kastalien-Research/thoughtbox.git
cd thoughtbox
docker compose up --buildThis starts Thoughtbox and the full observability stack. The MCP server listens on port 1731 and the Observatory UI is available at http://localhost:1729.
Since Thoughtbox uses HTTP transport, configure your MCP client to connect via URL.
Add to your ~/.claude/settings.json or project .claude/settings.json:
{
"mcpServers": {
"thoughtbox": {
"url": "http://localhost:1731/mcp"
}
}
}To connect through the observability sidecar (adds OpenTelemetry tracing):
{
"mcpServers": {
"thoughtbox": {
"url": "http://localhost:4000/mcp"
}
}
}Add to your MCP settings or .vscode/mcp.json:
{
"servers": {
"thoughtbox": {
"url": "http://localhost:1731/mcp"
}
}
}Thought 1: "Users report slow checkout. Let's analyze..."
Thought 2: "Data shows 45s average, target is 10s..."
Thought 3: "Root causes: 3 API calls, no caching..."
Thought 4: "Options: Redis cache, query optimization, parallel calls..."
Thought 5: "Recommendation: Implement Redis cache for product data"
Thought 8: [GOAL] "System handles 10k req/s with <100ms latency"
Thought 7: "Before that: monitoring and alerting operational"
Thought 6: "Before that: resilience patterns implemented"
Thought 5: "Before that: caching layer with invalidation"
...
Thought 1: [START] "Current state: 1k req/s, 500ms latency"
Thought 4: "Need to choose database architecture..."
Branch A (thought 5): branchId="sql-path"
"PostgreSQL: ACID compliance, mature tooling, relational integrity"
Branch B (thought 5): branchId="nosql-path"
"MongoDB: Flexible schema, horizontal scaling, document model"
Thought 6: [SYNTHESIS] "Use PostgreSQL for transactions, MongoDB for analytics"
| Variable | Description | Default |
|---|---|---|
DISABLE_THOUGHT_LOGGING |
Suppress thought logging to stderr | false |
THOUGHTBOX_DATA_DIR |
Base directory for persistent storage | ~/.thoughtbox |
THOUGHTBOX_PROJECT |
Project scope for session isolation | _default |
THOUGHTBOX_TRANSPORT |
Transport type (stdio or http) |
http |
THOUGHTBOX_STORAGE |
Storage backend (fs, memory, or supabase) |
fs |
THOUGHTBOX_OBSERVATORY_ENABLED |
Enable Observatory web UI | false |
THOUGHTBOX_OBSERVATORY_PORT |
Observatory UI port | 1729 |
THOUGHTBOX_OBSERVATORY_CORS |
CORS origins for Observatory (comma-separated) | (none) |
THOUGHTBOX_AGENT_ID |
Pre-assigned Hub agent ID | (none) |
THOUGHTBOX_AGENT_NAME |
Pre-assigned Hub agent name | (none) |
THOUGHTBOX_EVENTS_ENABLED |
Enable event emission | false |
THOUGHTBOX_EVENTS_DEST |
Event destination | stderr |
SUPABASE_URL |
Supabase project URL (required for supabase storage) |
(none) |
SUPABASE_SERVICE_ROLE_KEY |
Supabase service role key (required for supabase storage) |
(none) |
PORT |
HTTP server port | 1731 |
HOST |
HTTP server bind address | 0.0.0.0 |
NODE_ENV |
Node environment | (none) |
PROMETHEUS_URL |
Prometheus endpoint (Docker) | http://prometheus:9090 |
GRAFANA_URL |
Grafana endpoint (Docker) | http://grafana:3000 |
For local development (requires Node.js 22+):
pnpm install
pnpm build
pnpm dev # Development with hot reloadnpx vitest run # Unit tests
pnpm test # Full suite (build + vitest)
pnpm test:agentic # Agentic tests ā full suite (build + run)
pnpm test:agentic:tool # Agentic tests ā tool-level only
pnpm test:agentic:quick # Agentic tests ā quick (no build)
pnpm test:behavioral # Behavioral contract testsdocker compose up --build starts the full stack:
| Service | Port | Description |
|---|---|---|
| thoughtbox | 1731 (MCP), 1729 (Observatory) | Core MCP server + Observatory UI |
| mcp-sidecar | 4000 | Observability proxy with OpenTelemetry |
| otel-collector | 4318 (HTTP), 8889 (metrics) | OpenTelemetry Collector |
| prometheus | 9090 | Metrics storage + alerting |
| grafana | 3001 | Dashboards and visualization |
Persistent data is stored in named volumes: thoughtbox-data, prometheus-data, grafana-data.
src/
āāā index.ts # Entry point (Streamable HTTP transport)
āāā server-factory.ts # MCP server factory with tool registration
āāā thought-handler.ts # Core thought recording logic
āāā types.ts # Shared type definitions
āāā database.types.ts # Supabase generated types
āāā code-mode/ # Code Mode tool surface
ā āāā search-tool.ts # thoughtbox_search ā catalog query via JS
ā āāā execute-tool.ts # thoughtbox_execute ā operation chaining via tb SDK
ā āāā search-index.ts # Frozen catalog of operations/prompts/resources
ā āāā sdk-types.ts # TypeScript definitions for the tb SDK
āāā thought/ # Thought operations and tool definitions
āāā init/ # Init workflow and state management
ā āāā tool-handler.ts # Init tool operations
ā āāā state-manager.ts # Session state persistence
āāā sessions/ # Session management
āāā sampling/ # Autonomous critique via MCP sampling
ā āāā handler.ts # SamplingHandler for LLM critique requests
āāā persistence/ # Storage layer
ā āāā storage.ts # InMemoryStorage with LinkedThoughtStore
ā āāā filesystem-storage.ts # FileSystemStorage with atomic writes
ā āāā supabase-storage.ts # SupabaseStorage for deployed/cloud usage
āāā observatory/ # Real-time visualization
ā āāā ui/ # Self-contained HTML/CSS/JS
ā āāā ws-server.ts # WebSocket server for live updates
āāā hub/ # Multi-agent collaboration
ā āāā identity.ts # Agent registration
ā āāā workspace.ts # Workspace management
ā āāā problems.ts # Problem tracking with dependencies
ā āāā proposals.ts # Solution proposals with reviews
ā āāā consensus.ts # Decision recording
ā āāā channels.ts # Problem-scoped messaging
ā āāā hub-handler.ts # Hub operation dispatcher
ā āāā operations.ts # 28-operation catalog
āāā channel/ # Hub event channels and SSE streaming
āāā multi-agent/ # Agent attribution, content hashing, conflict detection
āāā protocol/ # Ulysses and Theseus protocol tools
āāā knowledge/ # Knowledge graph memory
āāā auth/ # API key authentication
āāā audit/ # Audit manifest generation
āāā evaluation/ # LangSmith evaluation and online monitoring
āāā notebook/ # Literate programming engine
āāā events/ # Event emission system
āāā observability/ # Prometheus/Grafana integration
āāā prompts/ # MCP prompt definitions
āāā references/ # Anchor parsing and resolution
āāā revision/ # Revision indexing
āāā operations-tool/ # Operations tool handler
āāā resources/ # Documentation and patterns cookbook
Thoughtbox supports three storage backends:
- InMemoryStorage: Volatile storage for testing, uses
LinkedThoughtStorefor O(1) thought lookups - FileSystemStorage: Persistent storage with atomic writes and project isolation (default)
- SupabaseStorage: Cloud-native storage backed by Supabase Postgres for deployed instances
Data is stored at ~/.thoughtbox/ by default (FileSystemStorage):
~/.thoughtbox/
āāā config.json # Global configuration
āāā projects/
āāā {project}/
āāā sessions/
āāā {date}/
āāā {session-id}/
āāā manifest.json
āāā {thought-number}.json
We welcome contributions! See CONTRIBUTING.md for:
- Development setup
- Commit conventions (optimized for
thick_readcode comprehension) - Testing with vitest and agentic scripts
- Pull request process
MIT License ā free to use, modify, and distribute.
