ehr-mcp
MCP server that exposes the ehr_building_data tool to query the Estonian Building Register by EHR code, returning a compact summary of building info (address, technical data, usage, energy certificate, cadastral units) excluding geometry.
README
ehr-mcp
A small MCP server (streamable HTTP) that exposes
one tool backed by the Estonian Building Register (Ehitisregister) endpoint
GET /v3/buildingData. It lets you ask Claude about a building by its EHR code and
get back a compact, trimmed answer — address, key technical indicators, usage
purpose, energy certificate and cadastral units. Geometry is never returned.
- Tool:
ehr_building_data— inputehr_kood(numeric string), optionaltaielik(boolean). Default returns a compact <2 KB summary;taielik: truereturns every field except geometry (~6 KB compact). Geometry is never returned in either mode. - Upstream:
https://livekluster.ehr.ee/api/building/v3/buildingData(public, no auth). - Output budget: trimmed result stays well under ~2 KB (≈0.5 KB typical) so it is cheap to load into model context. See docs/upstream.md for the full contract and trim decisions.
Stack
Node 20+, TypeScript (strict), Express, @modelcontextprotocol/sdk, zod, Vitest.
Develop
npm install
cp .env.example .env # optional; leave MCP_TOKEN empty for no-auth local dev
npm run dev # tsx watch on http://localhost:3000
Other scripts: npm run build (tsc → dist/), npm start (node dist/index.js),
npm test (Vitest).
Health check: GET /healthz → { "ok": true }.
Smoke test with MCP Inspector
Start the dev server (npm run dev), then in another terminal:
npx @modelcontextprotocol/inspector --cli --transport http --server-url http://localhost:3000/mcp --method tools/list
Expect one tool, ehr_building_data. Then call it with a real EHR code
(101018690 is the Tallinn sample used in the tests):
npx @modelcontextprotocol/inspector --cli --transport http --server-url http://localhost:3000/mcp --method tools/call --tool-name ehr_building_data --tool-arg ehr_kood=101018690
Expect trimmed JSON (< 2 KB, no kujud key). An unknown code such as 120896
returns a friendly EHR koodiga 120896 ehitist ei leitud. message.
If
MCP_TOKENis set, add--header "Authorization: Bearer <token>"to the Inspector commands.
Auth
Compatibility note: the claude.ai web custom-connector dialog authenticates only via OAuth (Client ID + Client Secret) — it has no field for a static bearer token. So the bearer token below cannot be used from the web connector; to use claude.ai, run the service authless (leave
MCP_TOKENunset — see Connect to Claude). The bearer token still works anywhere a custom header can be sent: Claude Code (--header), the MCP Inspector, and directcurl.
Auth on POST /mcp is a single shared bearer token — it is a secret string, not
a hash or a signed token, and there is no issuance, expiry, or user model by design.
/healthz is always open. If MCP_TOKEN is unset/empty, /mcp is open too
(local no-auth dev); if it is set, every request must send
Authorization: Bearer <token>. The comparison is constant-time
(crypto.timingSafeEqual, length-checked first so it can't throw).
Generate the token once:
openssl rand -hex 32
# or
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
The same value goes in three places:
- Local
.env—MCP_TOKEN=...(gitignored, never committed). - Render → your service → Environment →
MCP_TOKEN. This is whyrender.yamlmarks itsync: false: the value is entered in the dashboard, never stored in the repo. - Wherever you send it as a header — Claude Code (
--header "Authorization: Bearer ..."), the MCP Inspector (--header), orcurl. (Not the claude.ai web connector — see the compatibility note above.)
Rotation: generate a new value, update it in Render's Environment and in the connector, and redeploy. The old token stops working the moment the new value is live — there is no grace window or revocation list to manage.
Verify auth against the deployed service (replace host + token):
# 401 without the header
curl -s -o /dev/null -w "%{http_code}\n" -X POST https://ehr-mcp.onrender.com/mcp \
-H "content-type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
# 200 with it
curl -s -o /dev/null -w "%{http_code}\n" -X POST https://ehr-mcp.onrender.com/mcp \
-H "content-type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
Deploy to Render
The repo includes render.yaml (a web service: npm ci && npm run build → node dist/index.js, health check /healthz).
- Push this repo to GitHub.
- In the Render dashboard: New → Web Service (or Blueprint to pick up
render.yamldirectly) and connect the GitHub repo. - Set the
MCP_TOKENenvironment variable in the dashboard (see Auth).EHR_BASE_URLis supplied byrender.yaml. - Deploy. The service will be at
https://<service>.onrender.com, with the MCP endpoint athttps://<service>.onrender.com/mcp.
Free-tier cold start: the free plan spins the service down after ~15 min idle; the next request then waits ~30–50 s while it wakes. The first Inspector or Claude call after idle may look like a timeout — retry. Render's Starter tier keeps the service always-on and removes the cold start.
Connect to Claude
claude.ai (custom connector): Settings → Connectors → Add custom connector →
URL https://<service>.onrender.com/mcp. Leave the OAuth Client ID / Client Secret
fields empty — the web connector only supports OAuth, not a static bearer token, so
the service must be running authless (MCP_TOKEN unset in Render). Once connected,
ask in Estonian, e.g. "Mis hoone on EHR koodiga 101018690?" — Claude will call
ehr_building_data and answer with the address and key indicators.
Running authless means anyone with the URL can call the tool. That's low-risk here — it only reads public, read-only Ehitisregister data — but it does mean your Render compute is open. If you need it locked down, use Claude Code with the bearer token instead of the web connector.
Claude Code (CLI):
claude mcp add --transport http ehr https://<service>.onrender.com/mcp
If auth is enabled, add the header:
claude mcp add --transport http ehr https://<service>.onrender.com/mcp --header "Authorization: Bearer <token>"
Acceptance checklist
- [x] Inspector
tools/listreturnsehr_building_data - [x]
tools/callwith a valid EHR code returns trimmed JSON < 2 KB, nokujudkey - [x] Invalid EHR code returns a friendly not-found message
- [x] Request without bearer token (when
MCP_TOKENset) → 401 - [ ] From claude.ai, "Mis hoone on EHR koodiga <code>?" triggers the tool (verify after deploying + connecting)
Project layout
src/
config.ts env-derived config (PORT, EHR_BASE_URL, MCP_TOKEN)
index.ts Express app: /healthz + stateless POST /mcp
mcp.ts McpServer + ehr_building_data tool
ehr/
client.ts getBuildingData() with timeout + typed errors
trim.ts trimBuildingData() -> <2 KB, drops geometry
types.ts loose response types
docs/upstream.md upstream contract, params, response shape, trim map
test/ Vitest: trim + client, plus the raw response fixture
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。