Skip to main content
Glama

LexQ CLI

面向工程团队的决策平台。 LexQ 的 CLI 和 MCP 服务器 — 将业务规则从您的部署流水线中剥离出来,通过模拟验证每一次变更,无需 git push 即可发布。

网站 · 文档 · 控制台

npm License


为什么选择 LexQ?

您的业务规则(定价、促销、费用逻辑、资格检查)经常变动。但每一次变更都必须经历与核心应用程序代码相同的 PR → 代码审查 → 预发布 → 部署周期。一条简单的折扣规则可能需要两周时间才能上线。

这是一个架构问题,而非流程问题。每周都会变动的业务逻辑不应该存在于每季度才发布一次的代码中。

LexQ 将两者分离开来。 规则存在于应用程序之外。您可以在可视化控制台或通过此 CLI 修改它们。您可以使用真实执行数据进行批量模拟,以验证每一次变更。您无需触碰代码库即可进行部署。

每一项决策都会留下完整的审计追踪。

安装

npm install -g @lexq/cli

或者直接运行,无需安装:

npx @lexq/cli

需要 Node.js 18+

快速入门

# 1. Authenticate
lexq auth login
# Enter your API key (create one at console.lexq.io → Management → API Keys)

# 2. Verify
lexq auth whoami

# 3. Create a policy group
lexq groups create --json '{"name":"my-policy","priority":0}'

# 4. Create a draft version
lexq versions create --group-id <GROUP_ID> --json '{"commitMessage":"v1"}'

# 5. Add a rule
lexq rules create --group-id <GROUP_ID> --version-id <VERSION_ID> --json '{
  "name": "VIP Discount",
  "priority": 0,
  "condition": {
    "type": "SINGLE",
    "field": "customer_tier",
    "operator": "EQUALS",
    "value": "VIP",
    "valueType": "STRING"
  },
  "actions": [{
    "type": "DISCOUNT",
    "parameters": {"method":"PERCENTAGE","rate":10,"refVar":"payment_amount"}
  }]
}'

# 6. Test against your data before shipping
lexq analytics dry-run --version-id <VERSION_ID> --debug --mock \
  --json '{"facts":{"customer_tier":"VIP","payment_amount":100000}}'

# 7. Deploy
lexq deploy publish --group-id <GROUP_ID> --version-id <VERSION_ID> --memo "v1"
lexq deploy live --group-id <GROUP_ID> --version-id <VERSION_ID> --memo "Initial deploy"

面向 AI 智能体 — 63 个 MCP 工具

LexQ 专为 AI 原生设计。整个策略引擎 API(全部 63 个工具)均通过模型上下文协议 (MCP) 公开。Claude、Cursor 以及其他兼容 MCP 的智能体可以自主创建、模拟和部署规则,并在生产环境生效前获得人工批准。

Claude.ai (云端 — 无需安装)

  1. 设置 (Settings) → 连接器 (Connectors) → 添加自定义集成 (Add Custom Integration)

  2. 输入:https://mcp.lexq.io

  3. 使用您的 LexQ 账户登录并选择一个 API 密钥

  4. 完成 — 每次对话中均可使用 63 个工具

远程 (流式 HTTP)

对于任何支持远程服务器的 MCP 客户端:

{
  "mcpServers": {
    "lexq": {
      "url": "https://mcp.lexq.io"
    }
  }
}

OAuth 2.1 身份验证由您的客户端自动处理。

本地 (stdio)

将 LexQ CLI 作为本地 MCP 服务器运行:

lexq serve --mcp

Claude Desktop

添加到 claude_desktop_config.json

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

VS Code / Cursor

.vscode/mcp.json

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

前提条件: 必须先运行 lexq auth login 以将 API 密钥存储在 ~/.lexq/config.json 中。

AI 智能体技能

LexQ CLI 附带 AI 智能体技能 — 这是结构化的文档,智能体可以通过阅读这些文档来理解如何使用这些工具,而不仅仅是了解它们是什么。

skills/
├── lexq-shared/SKILL.md       Core concepts, auth, workflow
├── lexq-groups/SKILL.md       Policy groups, conflict resolution, A/B testing
├── lexq-rules/SKILL.md        Condition syntax, action types, mutex
├── lexq-simulation/SKILL.md   Dry run, batch simulation, compare
├── lexq-execution/SKILL.md    Execution history, stats, failure logs
└── lexq-recipes/SKILL.md      End-to-end recipes

.claude/CLAUDE.md              Claude Code project context
AGENTS.md                      Universal agent guide (Cursor, Windsurf, Gemini CLI, Cline)
CONTEXT.md                     Platform architecture & glossary

安装 @lexq/cli 后,智能体可以从以下位置读取技能:

node_modules/@lexq/cli/skills/
node_modules/@lexq/cli/AGENTS.md
node_modules/@lexq/cli/CONTEXT.md

命令

lexq auth                  login | logout | whoami
lexq status                API health check
lexq serve                 Run as MCP stdio server (--mcp)
lexq groups                list | get | create | update | delete
lexq groups ab-test        start | stop | adjust
lexq versions              list | get | create | update | delete | clone
lexq rules                 list | get | create | update | delete | reorder | toggle
lexq facts                 list | create | update | delete | action-metadata
lexq deploy                publish | live | rollback | undeploy | history | detail | overview | deployable | diff
lexq analytics             dry-run | dry-run-compare | requirements
lexq analytics simulation  start | status | list | cancel | export
lexq analytics dataset     upload | template
lexq history               list | get | stats
lexq integrations          list | get | save | delete | config-spec
lexq logs                  list | get | action | bulk-action
lexq webhook-subscriptions list | get | save | delete | test

全局选项

标志

描述

--format <json|table>

输出格式 (默认: json)

--api-key <key>

覆盖已存储的 API 密钥

--base-url <url>

覆盖 API 基础 URL

--dry-run

预览 HTTP 请求而不执行

--verbose

显示请求/响应详情

--no-color

禁用彩色输出

配置

配置存储在 ~/.lexq/config.json

{
  "apiKey": "YOUR_API_KEY",
  "baseUrl": "https://api.lexq.io/api/v1/partners",
  "format": "json"
}

开发

git clone https://github.com/lexq-io/lexq-cli.git
cd lexq-cli
pnpm install
pnpm build
pnpm start -- groups list
pnpm typecheck                  # Type check
pnpm lint                       # ESLint
bash tests/e2e.sh               # CLI E2E tests (requires API key)
bash tests/test-engine-api.sh   # Engine API integration tests

许可证

Apache-2.0

A
license - permissive license
-
quality - not tested
C
maintenance

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lexq-io/lexq-cli'

If you have feedback or need assistance with the MCP directory API, please join our Discord server