Skip to main content

What is MCP?

The Model Context Protocol (MCP) is an open standard for connecting AI assistants to external tools and data sources. LexQ CLI includes a built-in MCP server that exposes the entire LexQ API as 53 tools. When connected, AI agents can manage your policies directly:
  • “Create a discount rule for VIP customers”
  • “Dry-run this version with payment_amount=200000”
  • “Run a batch simulation comparing v3 and v4”

Quick Start

  1. Node.js 18+ installed
  2. Run lexq auth login once to store your API key
  3. Start the server:
lexq serve --mcp
The MCP server uses the same API key and base URL from ~/.lexq/config.json. No additional authentication setup is needed.

Setup Guides

Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
  "mcpServers": {
    "lexq": {
      "command": "npx",
      "args": ["-y", "@lexq/cli", "serve", "--mcp"]
    }
  }
}
Restart Claude Desktop after editing.

Claude.ai (Web)

Go to Settings → MCP Servers → Add, set Command: npx, Args: -y @lexq/cli serve --mcp.

VS Code / Cursor

Create .vscode/mcp.json (or .cursor/mcp.json):
{
  "servers": {
    "lexq": {
      "command": "npx",
      "args": ["-y", "@lexq/cli", "serve", "--mcp"]
    }
  }
}

Windsurf / Other MCP Clients

{
  "mcpServers": {
    "lexq": {
      "command": "npx",
      "args": ["-y", "@lexq/cli", "serve", "--mcp"]
    }
  }
}

Available Tools — 53

DomainToolsDescription
Status1lexq_whoami
Groups8CRUD + A/B test
Versions6CRUD + clone
Rules7CRUD + reorder + toggle
Facts4CRUD
Deploy7publish, live, rollback, undeploy, history, detail, overview
Analytics8dry-run, compare, requirements, simulation × 5
History3list, get, stats
Integrations5list, get, save, delete, config-spec
Logs4list, get, action, bulk-action

Agent Best Practices

  1. Read skills first. Have the agent read skills/lexq-shared/SKILL.md before any task.
  2. Follow the standard workflow. Create group → version → facts → rules → dry-run → publish → deploy.
  3. Always dry-run before publishing.
  4. Handle the response envelope. Check result === "SUCCESS"not success === true.

Troubleshooting

”Error: API key not found”

Run lexq auth login before starting the MCP server.

MCP server starts but tools aren’t visible

Restart your AI client after adding the MCP configuration.

Connection timeout

The MCP server uses stdio transport — it doesn’t open network ports. Ensure your client supports stdio transport.

Next Steps

Command Reference

Full list of all CLI commands mapped to MCP tools.

Policy Rules

Condition syntax and action types for rule creation.