
LexAPI
io.github.Lex-API由 GitHub 账号 Lex-API 发布v0.3.0更新于 Oct 29, 2026
EU law for AI: EUR-Lex legislation and case law, citation graph, semantic search with asOf.
概览
LexAPI 让助手检索欧盟法律:EUR-Lex 法规到条文级别、欧盟法院判例、引用关系图与语义搜索,并可查询某一历史日期生效的文本。
- 可以做什么
- 按语义检索法规与判例,支持法院、日期、案号筛选,并用 asOf 取指定日期生效的版本
- 执行结构化 EUR-Lex 检索、查看近期发布、把 URL、ELI 或 ECLI 解析为 CELEX
- 按 CELEX、URL 或批量获取文档,支持大纲、条文 ID、语言回退与版本历史
- 查询引用关系图:被引与引用、双向网络、最短引用链、相关文件与统计
- 按国家浏览成员国法规与判例,并查看覆盖范围与来源署名
- 管理新文件与关注法案的 webhook,并查看套餐、积分余额与限额
- 适用场景
- 适合需要依据原文并附 CELEX 引注回答欧盟法律问题、追踪法案之间的修订与废止关系,或确认某条规则在过去某日的规定。也适合通过 webhook 跟踪新发布文件。
- 运行要求
- 需要一个 LexAPI 账户。托管端点 mcp.lex-api.com/v1 使用 OAuth 登录;npm 包(需 Node.js 20 或更高版本,用 npx 运行)需要 LEXAPI_API_KEY。不支持 OAuth 的客户端可用 Authorization bearer 头传 API 密钥。需能访问 LexAPI 网络;有含每月额度的免费套餐。
安装
在 SourceWeft 中
- 打开 控制台中的 LexAPI,将其添加到工作区。
- 连接 Authorization token 凭据。它们会被私密存储,绝不会在公开页面上展示。
- 为需要使用其工具的对话启用该服务。
Web executable,通过 Streamable HTTP。 远程服务在工作区中配置后即可从网页运行时运行。
交给智能体安装
把这段提示词粘贴到 Claude Code、Codex、Cursor 等智能体,或 SourceWeft 对话中。智能体会读取该服务器的安装指南,先向你展示发布者、端点和登录方式,经你同意后再把它添加到你的客户端。密钥不会写进任何命令。
阅读 https://sourceweft.com/mcp/io.github.Lex-API%2Flexapi-mcp/install.md,并按其中说明把这个 MCP 服务器接入我的客户端。修改任何配置之前,先告诉我它的发布者、端点和登录方式,等我确认。不要把 API 密钥写进命令或我会提交的文件;问我密钥应从哪里获取。其他 MCP 客户端
把它添加到你客户端的 mcpServers 配置中。
{
"mcpServers": {
"lexapi": {
"type": "http",
"url": "https://mcp.lex-api.com/v1",
"headers": {
"Authorization": "Bearer <YOUR_TOKEN>"
}
}
}
}README
LexAPI MCP
Model Context Protocol server for LexAPI — EU law for AI assistants: EUR-Lex legislation parsed to article level, CJEU case law, the typed citation graph, and semantic search (including the law as in force on a past date). Works with Claude, Cursor, VS Code and any other MCP client.
Ask your assistant "what does Article 17 GDPR require?", "which acts amended REACH?" or "what were the own-funds requirements for banks in June 2019?" — the model calls LexAPI and answers from the source text, with CELEX citations.
You need a LexAPI account. With the hosted server you just sign in with LexAPI from your MCP client; with the npm package (or if you prefer), use an API key from lex-api.com/dashboard. There is a FREE plan, no card required, with enough credits to try the read tools; current allowances are on lex-api.com/pricing.
Connect to the hosted server (sign in with LexAPI)
The server is hosted at https://mcp.lex-api.com/v1 (Streamable HTTP). Add that URL to your client and sign in with your LexAPI account when it asks — no key to copy. You see a LexAPI consent page listing what the connection can do; calls are billed to your plan exactly like your own API key, and you can disconnect the app at any time under Dashboard → Connected apps (that revokes it immediately).
claude.ai and Claude Desktop
Settings → Connectors → Add custom connector, name it LexAPI, URL https://mcp.lex-api.com/v1, then Connect and sign in. Connectors added on claude.ai are also available in Claude Desktop (same account).
Claude Code
Then run /mcp in Claude Code and choose Authenticate for lexapi; your browser opens the LexAPI sign-in.
Other MCP clients
Any client that implements MCP authorization (OAuth 2.1 with protected-resource discovery) connects the same way: point it at https://mcp.lex-api.com/v1. The server answers an unauthenticated request with 401 and WWW-Authenticate: Bearer … resource_metadata="https://mcp.lex-api.com/.well-known/oauth-protected-resource/v1"; the client discovers LexAPI (https://lex-api.com) as the authorization server from there.
With an API key instead
Clients without OAuth support — or scripts — send a key from the dashboard as Authorization: Bearer lex_... (or x-api-key: lex_...):
Run it locally (npm, API key)
Claude Desktop (local)
Add to claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):
Restart Claude Desktop.
Claude Code (local)
Cursor, VS Code and other stdio clients
Run npx -y @lexapi/mcp with LEXAPI_API_KEY in the environment (Cursor: ~/.cursor/mcp.json; VS Code: .vscode/mcp.json; same command / args / env shape as above).
The npm package needs Node.js 20 or newer. It uses an API key; signing in with LexAPI is a feature of the hosted server.
Tools
Every call is billed from your LexAPI credit pool exactly like the REST endpoint it wraps; each tool's description states its cost so the model can see it.
National law
lex_national_coverage, lex_list_national_documents, lex_get_national_document, lex_national_semantic_case_law and lex_national_semantic_legislation cover member-state legislation and case law alongside the EU_LAW tools above. A country can be registered on LexAPI before it is made available to customers — always call lex_national_coverage first; the other tools answer an error for a country that isn't live yet. The citation-graph tools (lex_cited_by, lex_cites, lex_citation_network, lex_citation_path, lex_related, lex_citation_stats) accept national document ids directly (e.g. "AT-NOR-12345") and an includeNational option to pull in national neighbours — BUSINESS, SCALE and ENTERPRISE only, 403 below that. National results have the same fields in every country (LexAPI API 2.8.0): documentKind (act | decision) everywhere, and on a decision court, chamber, caseNumbers and citedNorms — whatever the source calls them. Every national result carries attribution (the official source and its licence, e.g. RIS, gesetze-im-internet.de, Normattiva, Légifrance/Judilibre, the Rechtspraak open data) — show it to the user alongside anything quoted. On FREE/STARTER/PROFESSIONAL plans, national-law calls also draw from a separate monthly allowance (reported as allowance on each response); BUSINESS and higher have no separate limit. A document its source withdrew (a takedown, a pseudonymisation fix) answers a distinct error — nothing of it is served, not even the title; the model is told not to retry and to drop any cached copy.
How results are shaped for models
- Compact output. Responses drop envelopes and duplicate legacy fields. Documents keep their metadata,
textAvailability(why text is missing, which languages exist, a pointer to the latest consolidated version) and language-fallback labels. - Large documents.
lex_get_documentreturns the whole body when it fitsmaxChars(default 40,000 characters), otherwise an outline (article ids, section tree, counts). Fetch an article witharticleIdor parts withinclude; long parts continue withoffset. - Consolidated texts are not authentic. Consolidated versions carry
consolidated: true,consolidatedAsOf,baseCelexand a note: quote them, cite the act as published in the Official Journal. asOf. Each legislation hit says whether it carries the version in force on that date (asOfResolved,asOfVersion); unresolved hits keep the current text with anasOfReason, and the response warns about them.- Errors say what to do. A 402 states the credits needed, the credits left and the reset date; a 429 says how long to wait.
Configuration
The key is sent only as the x-api-key header to LexAPI; it is never logged or included in tool output. A LEXAPI_API_KEY containing whitespace or control characters (e.g. a multi-line paste) is rejected at startup.
Hosting the HTTP server
npm run start:http (or the Dockerfile) runs the Streamable HTTP transport (POST /v1, GET /health). Self-hosted, it accepts LexAPI API keys (Authorization: Bearer lex_… or x-api-key: lex_…); a request without one gets 401. A value that cannot be an API key (it contains a . or is longer than 8192 characters) is answered 401 and never forwarded.
Sign in with LexAPI is a feature of the hosted server at https://mcp.lex-api.com/v1: it needs an OAuth client registered with LexAPI, so a self-hosted copy runs with API keys only. The OAuth-related settings in src/oauth/config.ts (LEXAPI_OAUTH_*, LEXAPI_MCP_*) are for that deployment; the server refuses to start if they are set incompletely.
/health returns status, name, version, tools and oauth (whether sign-in is enabled). It never contains addresses, tokens or configuration values.
Timeouts. MCP clients give up on a tool call after their own timeout (60 s by default in the official SDK; Claude Code: MCP_TOOL_TIMEOUT). A first, live EUR-Lex fetch can take longer. The server gives each tool call one 55 s deadline — retries and rate-limit waits included — and then returns a message the model can act on, instead of the client's generic timeout error. When the client sends a progress token, the server also sends a progress notification every 10 s; whether that keeps the call alive is up to the client (the official SDK only extends its timeout on progress when the caller opts into resetTimeoutOnProgress, and a server cannot detect that), so the deadline stays 55 s. If you raise your client's timeout, raise LEXAPI_TIMEOUT_MS to match. Cancelling a call aborts the request to LexAPI.
Troubleshooting
LEXAPI_API_KEY is not set— the variable isn't reaching the spawned process; check theenvblock of your MCP client config.LexAPI error 401— the key is wrong or revoked; create a new one at the dashboard.- Hosted server: "LexAPI sign-in expired or was revoked" — the connection was disconnected (for example from the dashboard); reconnect LexAPI in your client to sign in again.
- Hosted server:
403 Subscription inactive— the signed-in account's paid plan is not active; the same as with an API key. LexAPI error 402 (CREDITS_EXHAUSTED)— the monthly credit pool is used up. The message gives the reset date; top-ups and upgrades are on the dashboard.LexAPI error 429— the per-minute rate limit of your key (FREE: 15 per minute). Short waits are retried once automatically; otherwise the message says how long to wait.LexAPI error 403— the plan doesn't include the feature (e.g. export below BUSINESS, or semantic search on a legacy pre-credits FREE plan).LexAPI error 400creating a webhook — the details name the problem (unsupported criteria, a watch list over the plan limit, or the plan's webhook limit; FREE has none).
Development
npm run start:http runs the hosted Streamable HTTP transport (POST /v1, GET /health, port from PORT, default 3000; see Hosting the HTTP server above); the Dockerfile builds it. The OAuth tests run against a local mock authorization server (tests/oauth-mock.ts), no network.
License
MIT
来源:README.md,提交 0332a58
工具
0版本历史
2- v0.3.0最新Oct 29, 2026
- v0.1.3Sep 16, 2026
评分
已满足适用检查项的 85%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通必需25 分
- 已声明认证方式必需10 分
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分