Skip to content

MCP Setup Guide

This guide walks you through setting up the LumenFlow MCP server with your AI coding assistant.

MCP (Model Context Protocol) is an open standard for AI-to-tool communication. Instead of relying on file-based instructions, MCP provides a programmatic interface for AI assistants to interact with development tools.

Structured Tools

Tools with typed inputs and outputs, not just text parsing

Resource Access

Direct access to LumenFlow data via URI patterns

Consistent Interface

Same tools work across different AI clients

Safety Maintained

All operations respect LumenFlow workflow rules

Before setting up MCP:

  1. LumenFlow initialized in your project

    pnpm lumenflow
  2. AI client with MCP support

    • Claude Code 0.2.x+
    • Cursor (MCP-enabled)
    • Any MCP-compatible client
  1. Install the MCP package (if not already included)

    pnpm add -D @lumenflow/mcp
  2. Verify the binary is available

    npx @lumenflow/mcp --help

Claude Code supports MCP servers via configuration files.

Option 1: Project-level configuration

Create or edit .claude/mcp.json:

{
  "mcpServers": {
    "lumenflow": {
      "command": "npx",
      "args": ["@lumenflow/mcp"],
      "env": {
        "LUMENFLOW_PROJECT_ROOT": "${workspaceFolder}"
      }
    }
  }
}

Option 2: Global configuration

Add to your Claude Code settings (~/.config/claude/mcp.json on Linux, ~/Library/Application Support/claude/mcp.json on macOS):

{
  "mcpServers": {
    "lumenflow": {
      "command": "npx",
      "args": ["@lumenflow/mcp"]
    }
  }
}

Verify the connection:

In Claude Code, the LumenFlow tools should appear in the available tools list:

  • context_get
  • wu_list
  • wu_status
  • wu_create
  • wu_claim
  • wu_done
  • gates_run
  • file_read
  • git_status
  • plan_create
  • signal_cleanup
  • wu_proto

The full MCP surface is documented in /reference/mcp and currently includes 114 registered tools (107 in allTools plus 7 runtime task tools).

The examples above use stdio, which remains the default. Stdio is a local process-environment trust boundary and does not use the HTTP bearer flow.

For a shared long-lived service, select Streamable HTTP and configure the exact remote trust binding:

LUMENFLOW_MCP_TRANSPORT=http \
LUMENFLOW_MCP_HTTP_ISSUER=https://issuer.example.com \
LUMENFLOW_MCP_HTTP_RESOURCE=https://runtime.example.com/mcp \
LUMENFLOW_MCP_HTTP_WORKSPACE_ID=workspace-1 \
LUMENFLOW_CONTROL_PLANE_SIGNING_KEY=replace-with-a-strong-secret \
  npx @lumenflow/mcp

| Variable | Purpose | | ------------------------------------- | ---------------------------------------------------- | | LUMENFLOW_MCP_HTTP_ISSUER | Exact trusted credential issuer | | LUMENFLOW_MCP_HTTP_RESOURCE | Exact protected resource URL and credential audience | | LUMENFLOW_MCP_HTTP_WORKSPACE_ID | Exact workspace accepted by this MCP deployment | | LUMENFLOW_CONTROL_PLANE_SIGNING_KEY | Secret used to verify signed remote credentials | | LUMENFLOW_MCP_HTTP_HOST | Bind host; defaults to 127.0.0.1 | | LUMENFLOW_MCP_HTTP_PORT | Bind port; defaults to 8848 |

Every MCP protocol request must send a signed Authorization: Bearer … credential. Verification requires a valid signature and expiry, the configured issuer, exact resource audience and workspace, and a canonical subject. Opaque bearer fallback is off. Legacy tool scopes do not become transport permissions.

The supported transport permissions are:

  • task:read and task:write
  • event:read and evidence:read
  • discovery:read
  • tool:invoke
  • ag-ui:run

Authentication occurs before URL parsing, body reads, session lookup, or MCP server creation. Invalid credentials receive 401 invalid_token; an authenticated caller without the operation permission receives 403 insufficient_scope.

The server never forwards the bearer to tools, the kernel, logs, evidence, or session state. It stores only the sanitized principal, workspace, resource, and permission set. Every Mcp-Session-Id is bound to that exact context; a later request that changes the principal, workspace, resource, or permissions is rejected. Successful transport admission does not bypass downstream kernel ownership, scope, policy, approval, or evidence checks.

The protected-resource metadata endpoint is the public RFC 9728 exception. It is derived from the resource URL: for https://runtime.example.com/mcp, use https://runtime.example.com/.well-known/oauth-protected-resource/mcp. All other MCP HTTP routes require authentication.

The web HTTP surface uses the same signed credential and permission model, but its deployment variables are:

LUMENFLOW_WEB_HTTP_ISSUER=https://issuer.example.com
LUMENFLOW_WEB_HTTP_RESOURCE=https://runtime.example.com
LUMENFLOW_CONTROL_PLANE_SIGNING_KEY=replace-with-a-strong-secret

The web runtime reads the exact workspace ID from workspace.yaml. GET /api/health without a credential is intentionally public but returns only { "success": true, "status": "ok" }. Presenting a credential opts into authentication: an invalid credential is rejected, and detailed diagnostics are returned only after successful authentication.

Once configured, your AI assistant can use LumenFlow tools directly.

User: Create a WU for adding authentication

AI uses: wu_create {
  "lane": "Framework: Core",
  "title": "Add user authentication",
  "description": "Context: No auth. Problem: Users cannot log in. Solution: Add auth.",
  "acceptance": ["Users can register", "Users can log in"],
  "code_paths": ["src/auth/"],
  "exposure": "backend-only"
}

AI: Created WU-123. Would you like me to claim it?

User: Yes, claim it

AI uses: wu_claim {
  "id": "WU-123",
  "lane": "Framework: Core"
}

AI: WU-123 claimed. Worktree created at worktrees/framework-core-wu-123.

The AI can check current context at any time:

AI uses: context_get {}

Result: {
  "location": { "type": "worktree", ... },
  "wu": { "id": "WU-123", "status": "in_progress" }
}

AI assistants can read LumenFlow data via resources:

Read resource: lumenflow://backlog
Read resource: lumenflow://wu/WU-123
Read resource: lumenflow://context

| Approach | Best For | When to Use | | ---------- | --------------------------- | ----------------------------- | | MCP | Programmatic AI interaction | AI clients with MCP support | | CLI | Human operators, scripts | Terminal workflows, CI/CD | | File-based | Universal AI compatibility | Any AI that can read markdown |

Check: Is the package installed?

pnpm list @lumenflow/mcp

Check: Can you run it directly?

npx @lumenflow/mcp --help

Check: Is MCP enabled in your AI client?

Check: Is the configuration file in the correct location?

Check: Are there any errors in the AI client logs?

Check: Is LUMENFLOW_PROJECT_ROOT set correctly?

Fix: Use explicit path or ensure the AI client is opened in the project directory.

Check: Does the user running the AI client have access to the project?

Check: Are all LumenFlow files readable?

The MCP server:

  • Runs with the permissions of the user starting the AI client
  • Only accesses files within the project root
  • Respects all LumenFlow workflow rules (worktree discipline, gates)
  • Cannot bypass safety hooks or constraints
  • Authenticates remote HTTP before route, body, session, or state work
  • Separates transport permissions from kernel tool scopes
  • Never treats request-body authority fields as caller identity
  • Never passes a remote bearer credential into the kernel or evidence

For custom integrations:

import { createMcpServer } from '@lumenflow/mcp';

const server = createMcpServer({
  projectRoot: '/path/to/project',
  logLevel: 'debug',
});

// List tools
console.log(server.listTools());

// List resources
console.log(server.listResources());
console.log(server.listResourceTemplates());

// Start the server
await server.start();

Gates can take longer to run. The default timeout for gates_run is 10 minutes. This is configured in the tool implementation and cannot be overridden via MCP.