Skip to main content
Glama
oecd-sdmx-mcp

oecd-sdmx-mcp

README.md
# oecd-sdmx-mcp

A multi-user Model Context Protocol server for the OECD SDMX Data API (the
public data dissemination space at `https://sdmx.oecd.org/public/rest/`). It
supports stdio and authenticated Streamable HTTP, with the skeleton's optional
LangGraph agent, A2A endpoint, durable worker, Vault/Postgres persistence, and
pg-boss scheduling.

This is a new, standalone adaptation of the MIT-licensed
[skeleton-mcp](https://github.com/LesterAJohn/skeleton-mcp), based on commit
`bfbf26a6939a3c3c387a34bd2461f1bb5d0b8eec`. The pre-existing local OECD API
documentation snapshots in [`API-DOCS.md`](API-DOCS.md) and [`docs/`](docs/)
were preserved and are the grounding sources for the implemented API surface.
Agent configuration, task, and schedule state live in scoped Postgres tables;
secrets (including the optional upstream token) live only in Vault.

## API versions and coverage

The OECD Data API documentation (last updated 17 September 2026) states that
only the syntax it lists is guaranteed to be supported. This server implements
every guaranteed callable operation with a dedicated MCP tool:

| Version | Operation | MCP tool | Endpoint |
| --- | --- | --- | --- |
| v1 | Data query | `oecd_v1_get_data` | `GET /data/{agency},{dataflow},{version}/{filter}` |
| v2 | Data query | `oecd_v2_get_data` | `GET /v2/data/dataflow/{agency}/{dataflow}/{version}/{filter}` |
| v1 | Dataflow listing | `oecd_v1_list_dataflows` | `GET /dataflow/all` |
| v1 | Dataflow structure | `oecd_v1_get_dataflow` | `GET /dataflow/{agency}/{dataflow}/{version}` |
| v2 | Dataflow structure | `oecd_v2_get_dataflow` | `GET /v2/structure/dataflow/{agency}/{dataflow}/{version}` |
| v1 | Content constraint (update detection) | `oecd_v1_get_content_constraint` | `GET /contentconstraint/{agency}/{constraintId}` |

All six operations are read-only GET requests. The machine-readable
[endpoint inventory](inventory/operations.json) and the generated
[endpoint-to-tool coverage report](inventory/COVERAGE.md) map every required
operation to its tool and record 39 generic SDMX-REST operations (served by
the OpenAPI specifications in `docs/sdmx-rest-v1.yaml` / `docs/sdmx-rest-v2.yaml`)
as explicitly not-required because the OECD documentation does not guarantee
them. Structural artefacts (DSDs, codelists, concept schemes) are retrieved
through the guaranteed dataflow structure queries with
`references=all&detail=referencepartial`. Reference metadata is available only
through the v2 data query (`attributes=msd`).

Documented optional parameters are validated per version: `startPeriod`,
`endPeriod`, `lastNObservations`, `dimensionAtObservation`, `detail`, and
`updatedAfter` for v1 data; `c[TIME_PERIOD]`, `lastNObservations`,
`dimensionAtObservation`, `attributes`, `measures`, and `updatedAfter` for v2
data. Response formats use the documented non-standard `format` URL parameter
(`genericdata`, `structurespecificdata`, `jsondata`, `csv`, `csvfile`,
`csvfilewithlabels`; `structure` plus `formatVersion` for structure queries)
or an explicit documented SDMX `accept` media type, plus `acceptLanguage` for
the `Accept-Language` header. JSON responses are parsed; other formats are
returned as text. Use `oecd_discover_operations` for the complete operation
schemas and `oecd_suggest_query` to produce a schema-valid placeholder call
without making a request.

## Rate limits, restricted parameters, and reliability

- The OECD API is limited to **60 data downloads per hour**; data tools are
  marked accordingly and HTTP 429 responses return an actionable error.
  Cache results locally and prefer `oecd_v1_get_content_constraint` (its
  `ValidFrom` timestamp and observation-count annotation) to detect dataset
  updates before downloading.
- `lastNObservations` is blocked for the 12 documented very large dataflows
  (and the TiVA/CRS dedicated spaces); such requests return HTTP 413, which is
  surfaced with guidance to remove the parameter or slice the query.
- Requests time out after `OECD_TIMEOUT_MS` (default 30000 ms); responses are
  capped at `OECD_MAX_RESPONSE_BYTES` (default 10 MiB) with slicing guidance.
  Slice large extractions by dimension filter, time period (`startPeriod`/
  `endPeriod` or `c[TIME_PERIOD]`), or incremental `updatedAfter` syncs; the
  API has no offset pagination.
- All operations are read-only, so transient upstream failures
  (429/502/503/504) get a single bounded retry honoring `Retry-After` up to
  two seconds. There are no mutating upstream operations.

## Credentials and identity

**The OECD public dissemination space requires no API key or upstream
authentication.** All OECD data tools work immediately without provisioning
any credential. For parity with sibling skeleton builds — and for deployments
that place an authenticated gateway in front of the OECD API — an optional
upstream bearer token can be provisioned per principal:
`oecd_credential_set` stores or rotates it in Vault (it is then sent as an
`Authorization: Bearer` header), `oecd_credential_status` reveals only whether
it exists, and `oecd_credential_delete` removes the local Vault value.
Credential tools require `mcp:admin` for OAuth callers, or a configured
`MCP_ADMIN_AUTH_KEY` in key-authorized mode, and never return the stored
value; responses and errors are scrubbed of the token.

Credentials use an exact SHA-256 digest of `(tenant_id, principal_type,
principal_id)` under `MCP_SERVER_NAME/oecd/credentials/`. There is no
cross-user credential fallback. Identity is taken from authenticated context,
not caller-supplied tenant/principal fields. Stdio and static-token HTTP use
the configured default identity; use Vault-index tokens or verified OAuth
identities to isolate individual HTTP callers.

All OECD tools are excluded from autonomous agent capabilities so potentially
large API responses and credential operations cannot enter tasks, durable
checkpoints, or agent memory.

## OAuth scope contract

HTTP OAuth uses introspection; this server does not issue tokens. Provider
scope mappings are allowlists configured by the skeleton's OAuth environment
variables. The OECD API itself has no upstream OAuth scopes (it is
unauthenticated for the public space).

| MCP scope | Purpose and authorization |
| --- | --- |
| `mcp:invoke` | Required by default for Vault-index HTTP bearer tokens; permits authenticated invocation and is required for agent/A2A execution. |
| `mcp:read` | Accepted descriptive read capability; current direct read tools (all `oecd_*` data/structure/discovery tools) do not enforce it individually. |
| `mcp:write` | Authorizes ordinary mutating operations (for example `config_set`) under OAuth-scope authorization; does not authorize Vault credential administration. |
| `mcp:admin` | Admin-only Vault credential/token lifecycle (including `oecd_credential_set`/`oecd_credential_delete`), agent administration, and schedule administration; also satisfies `mcp:write`. |
| `mcp:agent` | Alternative scope for agent invocation where configured. |
| `mcp:tenancy:admin` | Tenant-bounded user/account and token administration. |
| `mcp:agent-config:admin` | Tenant-bounded cross-user agent configuration administration. |
| `mcp:proxy:initialize` | Trusted hosted-proxy caller initialization; only accepted with a configured trusted proxy identity. |

OAuth providers may require an admission scope such as `mcp:invoke`; configure
`MCP_HTTP_OAUTH2_REQUIRED_SCOPES` or the provider-specific equivalent, e.g.
`MCP_HTTP_OAUTH2_OKTA_SCOPE_MAP=api.invoke:mcp:invoke,api.admin:mcp:admin`.
Configure the OAuth client's requested scopes to match the server's admission
and authorization policy. In `auto` mode verified OAuth callers use scopes;
stdio/static-token callers use `MCP_ADMIN_AUTH_KEY` for protected operations.
The default Vault-index token verifier requires `mcp:invoke`. All `oecd_v*`
data tools are read-only and require only authenticated admission, never
`mcp:write` or `mcp:admin`.

## Run locally

Requirements: Node.js 22+, Postgres, and Vault. Copy `.env.example` to `.env`,
provision infrastructure credentials locally, and never commit `.env`.
`MCP_SERVER_NAME=oecd-sdmx-mcp` is the sole namespace source for Vault paths,
Postgres tables/schemas, checkpoint schema, and queue names. Changing it
changes the persistence namespace and requires an explicit migration plan
(`npm run vault:migrate-namespace` assists Vault moves). `APP_NAME` is only a
legacy migration input.

```sh
npm ci
npm run start:stdio
# or:
npm run start:http
npm run start:both
```

## Persistence and External Services Mode

For local containers, `docker compose up` starts Postgres, Raft-backed Vault
(with the `vault-unseal-key-init` managed-unseal startup ordering), the MCP
HTTP server, and the dedicated agent worker. Run server and worker with the
same `MCP_SERVER_NAME`, database, and Vault settings. Agent scheduling
requires `MCP_AGENT_WORKER_ENABLED=true` and `PGBOSS_ENABLED=true`; the worker
is a separate `npm run start:agent-worker` process. The supported external
services path is `docker-compose.external.yml`; configure `POSTGRES_HOST`,
`POSTGRES_PORT`, `POSTGRES_DB`, `POSTGRES_USER`, `POSTGRES_PASSWORD`,
`VAULT_ADDR`, and `VAULT_TOKEN` through deployment secrets. Keep queue and
application tables in the same Postgres database for transactional dispatch.

Agent inference is not configured automatically. A fresh deployment with
healthy Vault/Postgres starts all transports and workers, reports
infrastructure readiness separately from inference readiness, and rejects
inference-dependent requests with actionable errors. Use the existing
`agent_config_*` tools (`agent_config_get`, `agent_config_set`,
`agent_config_update`, `agent_config_delete`, `agent_config_validate`,
`agent_config_test_connection`) and the Vault credential tools to set up
inference after deployment, without code changes or a rebuild:

1. Discover fields with `agent_config_validate` and `service_query_suggestion`-style discovery (`oecd_discover_operations` covers the OECD surface).
2. Provision the inference credential into scoped Vault storage via the skeleton's credential tooling.
3. Create scoped configuration with `agent_config_set` (protocol, endpoint, model, Vault credential reference, instructions, permitted capabilities, limits, memory settings).
4. Validate with `agent_config_validate`, then test explicitly with `agent_config_test_connection` (makes a network call to the configured provider and may incur provider costs).
5. Submit a non-destructive verification task with `agent_goal` and inspect it with `agent_task_status`.

See the [inherited skeleton operations reference](docs/SKELETON-README.md),
the [onboarding playbook](agent/playbooks/service-onboarding.md), and
[`vault-production/README.md`](vault-production/README.md) for agent, A2A,
schedule, Vault Raft, managed unseal, backup, and recovery details.

## HTTP TLS

`MCP_HTTP_TLS_ENABLED=false` is the default, matching `.env.example`. HTTP is
for loopback development or a trusted internal connection behind a
TLS-terminating reverse proxy (`MCP_HTTP_TRUST_PROXY=true`). Native TLS
remains configurable:

- Set `MCP_HTTP_TLS_ENABLED=true`.
- Provision `MCP_HTTP_TLS_CERT_PATH` and `MCP_HTTP_TLS_KEY_PATH` externally.
- Optionally configure `MCP_HTTP_TLS_KEY_PASSPHRASE` and
  `MCP_HTTP_TLS_MIN_VERSION` (default `TLSv1.2`).
- Mount certificate and key files read-only in containers.

Startup fails if TLS files are missing or unreadable; it never falls back to
plaintext HTTP. Renew/rotate certificates externally and restart the process.
Use HTTPS client URLs and set `MCP_A2A_PUBLIC_URL` to the HTTPS address when
TLS is enabled. Never commit certificates or private keys.

HTTP retains bearer/OAuth authentication, request body limits, rate limits,
and optional IP/origin controls. The default listener is loopback.

## Configuration and checks

Common service variables:

| Variable | Purpose | Default |
| --- | --- | --- |
| `MCP_SERVER_NAME` | Server identity and persistence namespace | `oecd-sdmx-mcp` |
| `OECD_TIMEOUT_MS` | OECD request timeout | `30000` |
| `OECD_MAX_RESPONSE_BYTES` | OECD response size cap | `10485760` |
| `MCP_HTTP_TLS_ENABLED` | Native HTTP TLS listener | `false` |
| `MCP_TRANSPORT_MODE` | `stdio`, `http`, or `both` | `stdio` |
| `MCP_HTTP_AUTH_MODE` | `token`, `oauth2`, or `both` | `token` |
| `MCP_AGENT_WORKER_ENABLED` | Agent worker activation | Set `true` in supported deployment |
| `PGBOSS_ENABLED` | Durable queues/scheduler | `true` |

See `.env.example` and the [skeleton environment reference](docs/SKELETON-README.md)
for Postgres, Vault, OAuth, token, agent, worker, A2A, and HTTP hardening
settings. `docker-compose.yml` preserves the `vault-unseal-key-init` startup
ordering. Do not commit credentials, Vault data, or unseal-key material.

Reproducible inventory and local test commands:

```sh
npm run inventory:generate
npm run inventory:check
npm test
```

`inventory:check` verifies deterministic output, unique documented endpoints,
tool mappings, read-only classification, not-required recording, and test
mapping. GitHub Actions runs inventory and tests on pull requests and pushes.
Install the versioned pre-push check after Git initialization with
`git config core.hooksPath .githooks`; it runs inventory validation and tests
and blocks a normal push when they fail.

Unit and mocked transport tests do not imply live API or infrastructure
verification. Disposable Postgres/Vault integration tests are opt-in and may
skip when services are unavailable. Controlled inference, live OECD API, and
GitHub Actions checks require their respective external setup. No inference
provider, paid model, or production credential is required for this build;
live OECD smoke tests are optional post-deployment checks and are
non-destructive (the entire guaranteed surface is read-only).

## License

MIT, inherited from [skeleton-mcp](https://github.com/LesterAJohn/skeleton-mcp);
see [LICENSE](LICENSE). OECD data retrieved through this server is subject to
the OECD Terms and Conditions.