opendata-mcp
Enables interaction with the OpenData Platform API by dynamically exposing all endpoints as MCP tools with typed input schemas and HTTP handlers.
README
opendata-mcp
A Model Context Protocol server for the OpenData Platform API. Tools are generated dynamically from the bundled OpenAPI 3.1 spec — every endpoint is exposed as an MCP tool with a typed input schema and a transparent HTTP handler.
- GET endpoints: 76 — exposed without auth (the API serves them unauthenticated).
- Write endpoints (POST / PUT / PATCH / DELETE): 23 — require a Bearer token via
OPENDATA_API_KEY. - Built on
@modelcontextprotocol/sdk(TypeScript) with stdio transport.
Install
Uses pnpm (pinned via packageManager in package.json so corepack enable is enough to get the right version).
pnpm install
pnpm run build
Configure
Copy .env.example → .env (or set in your MCP client config) and fill in:
OPENDATA_BASE_URL=https://api.tryopendata.ai # required at call time
OPENDATA_API_KEY=od_live_xxx # required for writes
# OPENDATA_READ_ONLY=true # optional: only register GET tools
# OPENDATA_TIMEOUT_MS=30000 # optional: per-request timeout
# OPENDATA_MAX_ATTEMPTS=3 # optional: total HTTP attempts (retries are bounded; see below)
# OPENDATA_LOG_LEVEL=info # optional: off|error|info|debug
Secrets are never read from the repo. .env is gitignored; .env.example ships placeholders only.
Run
# Dev (tsx, no build step)
pnpm run dev
# Production (after build)
pnpm start
The server speaks MCP over stdio — wire it into any MCP-capable client. Example client config (Claude Desktop / similar):
{
"mcpServers": {
"opendata": {
"command": "node",
"args": ["/absolute/path/to/opendata-mcp/dist/index.js"],
"env": {
"OPENDATA_BASE_URL": "https://api.tryopendata.ai",
"OPENDATA_API_KEY": "od_live_xxx"
}
}
}
}
Test
pnpm test # unit tests (mocked fetch — offline-safe)
pnpm run typecheck # tsc --noEmit
Live tests against the real API run only when OPENDATA_BASE_URL is set:
OPENDATA_BASE_URL=https://api.tryopendata.ai pnpm test
CI runs the unit suite on every push/PR (badge above). The live smoke job runs on a daily schedule (and on pushes to main) only if the repo has OPENDATA_BASE_URL (and optionally OPENDATA_API_KEY) configured as Actions secrets — it's continue-on-error: true so a transient upstream outage doesn't show the repo as red.
How tool generation works
At startup the server:
- Loads
openapi.json(OpenAPI 3.1, bundled). - Walks every
(path, method)pair (skippingdeprecatedoperations and skipping non-GET whenOPENDATA_READ_ONLY=true). - Converts each operation's path + query parameters (and JSON request body for writes) into a Zod input schema via
openapi-to-zod.ts. - Registers one MCP tool per operation. The tool name is the OpenAPI
operationId(sanitized to[a-zA-Z0-9_-]{1,64}); the description isMETHOD path (auth?) — summary — description. - On invoke, builds the URL (substituting path params + appending the query string), attaches
Authorization: Bearer ${OPENDATA_API_KEY}for non-GET, sends the request, and returns the response as a text MCPcontentblock.
The auth contract is enforced at the client layer (src/api-client.ts):
- GET → no auth header is sent. If you pass a key it's still ignored.
- Non-GET →
OPENDATA_API_KEYis required; the request fails fast with a clear error if it's missing.
Logging, retries, and shutdown
- Structured logging to stderr (stdout is reserved for the MCP protocol). One JSON object per line:
{ts, level, msg, ...fields}. Tuned viaOPENDATA_LOG_LEVEL(off|error|info|debug, defaultinfo). Every tool invocation carries a shortrid(request id) that also surfaces in any error message returned to the client — so a user can quote anERROR (rid=…)and you can grep it in logs. - Bounded retries on transient failures only:
502 / 503 / 504and network errors are retried with jittered exponential backoff (200ms → 600ms → 1.4s, capped).500and any4xxare never retried — a 500 means "I tried, it broke" and retrying just hammers a server that already gave its answer; a 4xx means the request is wrong and retrying won't help. Total attempts viaOPENDATA_MAX_ATTEMPTS(default 3). - Graceful shutdown on
SIGINT/SIGTERM: the MCP transport is closed beforeprocess.exitso any in-flight tool calls have a chance to land.
Layout
src/
index.ts # entry — MCP server, stdio transport
openapi-loader.ts # loads + normalizes the bundled spec
openapi-to-zod.ts # OpenAPI schema → Zod schema converter
api-client.ts # fetch wrapper + auth contract
tools.ts # generates MCP tool defs from normalized ops
__tests__/
tools.test.ts # unit tests (mocked fetch)
live.test.ts # live tests (skipped unless OPENDATA_BASE_URL set)
openapi.json # bundled OpenAPI 3.1 spec
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.