This guide explains how to set up the Cognitive Space MCP server for use with Claude Code.
The MCP (Model Context Protocol) server exposes cognitive space operations as native tools for Claude Code, eliminating the need for cumbersome curl commands with complex JSON escaping.
create_space- Create a new cognitive spacecreate_node- Add a thought node to a spacedelete_node- Remove a node from a spacelist_spaces- List all cognitive spacesget_space- Get full details of a space
- All cognitive spaces are exposed as
cognitive-space:///<spaceId>resources - Claude Code can list and read spaces directly
The MCP server now starts automatically with the dev server:
npm run devThis runs both:
- Next.js dev server (port 3000) - cyan output
- MCP server (stdio) - magenta output
Alternative: Run them separately:
npm run dev:next # Just Next.js
npm run dev:mcp # Just MCP serverThe MCP server is already configured for this project:
Files:
.mcp.json- MCP server definition.claude/settings.local.json- Permissions and auto-enable
Configuration:
// .mcp.json
{
"mcpServers": {
"cognitive-spaces": {
"command": "npm",
"args": ["run", "mcp"],
"env": {
"MODELER_URL": "http://localhost:3000"
}
}
}
}Permissions:
// .claude/settings.local.json
{
"permissions": {
"allow": ["mcp__cognitive_spaces__*", ...]
},
"enableAllProjectMcpServers": true
}The wrapped Claude instance in this project will automatically:
- Detect
.mcp.jsonin the project root - Start the MCP server when needed
- Make tools available with the
mcp__cognitive_spaces__prefix
No restart needed - the MCP server starts on-demand when wrapped Claude needs it.
Once configured, wrapped Claude Code can use the tools directly:
Use tool: create_space
{
"title": "Project Planning",
"description": "Planning the next quarter's roadmap"
}
Use tool: create_node
{
"spaceId": "2025-11-15T...",
"id": "Q1 Goals",
"meanings": [
{"content": "First quarter objectives", "confidence": 0.9}
],
"focus": 1.0,
"semanticPosition": 0.0,
"checkableList": [
{"item": "Define OKRs", "checked": false},
{"item": "Align with stakeholders", "checked": false}
]
}
Use tool: list_spaces
{}
Wrapped Claude can also access spaces as MCP resources:
List resources: cognitive-space:///*
Read resource: cognitive-space:///2025-11-15T...
curl -s -X POST http://localhost:3000/api/spaces/SPACE_ID/thoughts \
-H 'Content-Type: application/json' \
-d '{"id":"Test","meanings":[{"content":"A test","confidence":0.9}],"focus":1.0}'Problems:
- Permission denials for multi-line commands
- Complex JSON escaping
- No type safety or validation
- Hard to read and maintain
Use tool: create_node
{
"spaceId": "SPACE_ID",
"id": "Test",
"meanings": [{"content": "A test", "confidence": 0.9}],
"focus": 1.0
}
Advantages:
- Native Claude Code integration
- JSON Schema validation
- Clean, readable syntax
- Type-safe parameters
- Automatic WebSocket updates
┌─────────────────┐
│ Wrapped Claude │
│ (Claude Code) │
└────────┬────────┘
│ MCP Protocol (stdio)
↓
┌─────────────────┐
│ MCP Server │
│ (mcp-server.ts)│
└────────┬────────┘
│ HTTP
↓
┌─────────────────┐
│ Next.js API │
│ (localhost:3000)│
└────────┬────────┘
│
↓
┌─────────────────┐
│ Turso Database │
│ + WebSocket │
└─────────────────┘
- Check Claude Code logs for MCP server startup errors
- Verify the
cwdpath is correct in config - Ensure
npm run mcpworks when run manually - Check that the dev server is running on http://localhost:3000
- Verify the Next.js dev server is running (
npm run dev) - Check the MCP server logs (they go to stderr)
- Ensure database is initialized
- Test the HTTP API directly with curl to isolate issues
The MCP server uses the same database configuration as the main app. Check:
.envfile has correctDATABASE_URLandDATABASE_AUTH_TOKEN- Database is accessible
- Run
npx tsx test-turso.tsto verify database connection
To modify the MCP server:
- Edit mcp-server.ts
- Restart the MCP server (Claude Code will auto-restart it)
- Test with wrapped Claude
The server is designed to be stateless and handle all operations via HTTP to the Next.js API, ensuring consistency with the web dashboard.