/ MCP Server
GitHub

MCP Server

Reference·Claude Desktop · Claude Code

CrewLayer ships a built-in MCP (Model Context Protocol) server that exposes all core features as tools. This means Claude — in Claude Desktop, Claude Code, or any MCP-compatible host — can call CrewLayer directly without you writing any HTTP code.

Transports

The MCP server supports two transports:

Claude Desktop

Add the following to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS, %APPDATA%\Claude\claude_desktop_config.json on Windows):

claude_desktop_config.json
{
  "mcpServers": {
    "crewlayer": {
      "command": "python",
      "args": ["-m", "mcp.server"],
      "cwd": "/path/to/CrewLayer",
      "env": {
        "CREWLAYER_API_KEY": "crwl_your_key_here",
        "CREWLAYER_BASE_URL": "http://localhost:8000",
        "MCP_TRANSPORT": "stdio"
      }
    }
  }
}

Restart Claude Desktop. You'll see the CrewLayer tools appear in the tool picker.

Claude Code (VS Code)

In Claude Code settings (/config → MCP servers), add:

.claude/settings.json
{
  "mcpServers": {
    "crewlayer": {
      "command": "python",
      "args": ["-m", "mcp.server"],
      "cwd": "/path/to/CrewLayer",
      "env": {
        "CREWLAYER_API_KEY": "crwl_your_key_here",
        "CREWLAYER_BASE_URL": "http://localhost:8000"
      }
    }
  }
}
💡

If CrewLayer is running in Docker, set CREWLAYER_BASE_URL=http://host.docker.internal:8000 (macOS/Windows) or use the container's network IP on Linux.

Docker / SSE Mode

For headless environments or when running behind a reverse proxy, use SSE transport. The MCP server runs alongside the API:

terminal
# Start in SSE mode (listens on :8001)
MCP_TRANSPORT=sse CREWLAYER_API_KEY=crwl_... python -m mcp.server

# Or via Docker (already included in docker-compose.yml)
docker compose up -d mcp

Then point your MCP client to http://localhost:8001/sse.

Available Tools

The MCP server exposes 9 tools. All tool calls are automatically logged to CrewLayer actions (except the agent status tools, which manage status directly).

memory_recall

Search an agent's long-term memories using semantic similarity.

ParameterTypeRequiredDescription
agent_idstringrequiredUUID of the agent
querystringrequiredNatural language search query
top_kintoptionalMax memories to return (default: 10)

memory_append

Append a message to an agent's short-term (Redis) memory for a session.

ParameterTypeRequiredDescription
agent_idstringrequiredUUID of the agent
session_idstringrequiredUUID of the active session
rolestringrequireduser | assistant | system
contentstringrequiredMessage text

memory_extract

Close a session and extract long-term memories from its conversation history using Claude.

ParameterTypeRequiredDescription
agent_idstringrequiredUUID of the agent (for action logging)
session_idstringrequiredUUID of the session to close and extract from

action_log

Log a tool invocation as an immutable action record.

ParameterTypeRequiredDescription
agent_idstringrequiredUUID of the agent
tool_namestringrequiredName of the tool called
input_paramsobjectrequiredTool input parameters
output_resultobjectrequiredTool output
statusstringrequiredsuccess | error | timeout
duration_msintoptionalWall-clock execution time
session_idstringoptionalSession this action belongs to

action_list

List recent actions for an agent with optional filters.

ParameterTypeRequiredDescription
agent_idstringrequiredUUID of the agent
toolstringoptionalFilter by tool name
statusstringoptionalFilter by status
limitintoptionalMax results (default: 50)
cursorstringoptionalPagination cursor

context_write

Write a value to the shared context blackboard.

ParameterTypeRequiredDescription
namespacestringrequiredLogical grouping (e.g. pipeline)
keystringrequiredKey within the namespace
valueanyrequiredAny JSON-serializable value
agent_idstringoptionalFor action logging

context_read

Read a value from the shared context blackboard.

ParameterTypeRequiredDescription
namespacestringrequiredNamespace
keystringrequiredKey
agent_idstringoptionalFor action logging

agent_status

Get the current runtime status of an agent. Served from Redis cache (TTL 60s).

ParameterTypeRequiredDescription
agent_idstringrequiredUUID of the agent

agent_set_status

Update the runtime status of an agent. This is the only way to change status — the @auto_log decorator intentionally does not touch status.

ParameterTypeRequiredDescription
agent_idstringrequiredUUID of the agent
statusstringrequiredidle | working | error
session_idstringoptionalAssociate with an active session
ℹ️

The @auto_log decorator wraps all tools except agent_status and agent_set_status. It records tool_name, input_params, output_result, and duration_ms to the CrewLayer action log automatically — you don't need to call action_log manually when using the MCP server.