
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 分