Skip to main content
Glama

sdmx-authoring-mcp

WARNING

Experimental software. Not for production use. This repository is an evaluation and development harness; APIs and behavior may change without a compatibility or support commitment. The sandbox credentials are for disposable local/CI use only and must not be reused in a deployed environment.

A first-party Python MCP server for authoring SDMX artefacts in the lab's Fusion Metadata Registry (FMR). It exposes agency and codelist management, as well as the artefacts and rules needed to build dataflow mappings. FMR reads and writes are handled server-side with pysdmx.

Run the server with uv run server.py. Dependencies are declared in the script using PEP 723, so uv installs them when needed. The source files are plain sibling modules rather than an installed Python package.

Capabilities

  • Agencies: list, create, and update agency schemes and agencies.

  • Codelists: list per agency or across all agencies, get, create, and update codelists and codes. List operations return id, agency, version, name, description, and contained-code count without returning every code.

  • Concept schemes: list, get, create, and update concepts.

  • Data structures: list, get, create, and update dimensions, measures, attributes, and groups in a DataStructureDefinition.

  • Dataflows: list and create dataflows, and inspect a dataflow's resolved component schema.

  • Representation maps: list, get, create, and update single-source and multi-source value mappings.

  • Structure maps: list, get, create, and update component, multi-component, fixed-value, implicit, and date-pattern mapping rules.

The MCP tools are registered in server.py; the artefact logic lives in separate modules, with FMR access centralized in fmr_client.py.

For maintenance guidance, start with AGENTS.md, the architecture overview, and its decision records.

Related MCP server: OECD MCP Server

Mapping workflow

Build the workflow in dependency order:

  1. Create a ConceptScheme and the required Codelist artefacts.

  2. Create a DataStructureDefinition that references their concepts and values.

  3. Create source and target Dataflows that reference their data structures.

  4. Create required RepresentationMap or MultiRepresentationMap value conversions.

  5. Connect the dataflows with a StructureMap that references those maps.

Call get_dataflow_structure to discover component ids before writing mapping rules. Create any referenced RepresentationMap or MultiRepresentationMap first. Artefacts are referenced, not embedded: reference parameters accept a URN string or a coordinate object such as {"agency": "BIS", "id": "EXAMPLE", "version": "1.0"}.

Input shapes

All shapes below are JSON objects passed inside the corresponding MCP list or argument. Fields marked optional may be omitted.

  • Concepts (create_concept_scheme.concepts): {"id": "FREQ", "name": "Frequency", "description": "...", "data_type": "String", "codelist": {"agency": "BIS", "id": "FREQ_CL", "version": "1.0"}, "facets": {"min_length": 1}}. codelist accepts a URN or coordinates. facets accepts pysdmx Facets fields: min_length, max_length, min_value, max_value, start_value, end_value, interval, time_interval, decimals, pattern, start_time, end_time, is_sequence, and is_multilingual.

  • Data structure components (create_data_structure.components, and add_components/modify_components): {"id": "FREQ", "role": "dimension", "required": true, "concept_id": "FREQ", "concept_scheme": {"agency": "BIS", "id": "CONCEPTS", "version": "1.0"}, "data_type": "String", "codelist": {"agency": "BIS", "id": "FREQ_CL", "version": "1.0"}, "attachment_level": "O", "local_facets": {"min_length": 1}, "name": "Frequency", "description": "..."}. Required fields are id, role (dimension, measure, or attribute), required, concept_id, and concept_scheme (URN or coordinates). attachment_level is required only for attributes; data_type, codelist, local_facets, name, and description are optional. modify_components merges supplied fields into the existing component; an explicit null clears an optional field.

  • Groups (create_data_structure.groups or optional update_data_structure.groups): {"id": "FREQ_GROUP", "dimensions": ["FREQ"]}. Every listed id must identify a dimension in the resulting data structure. Supplying groups on update replaces the complete group list; omitting it keeps existing groups.

  • Value maps (value_maps): a single-value entry is {"source": "US", "target": "USA", "valid_from": "2020-01-01T00:00:00", "valid_to": "2030-01-01T00:00:00"}; multi-value entries use string arrays for source and target. valid_from and valid_to are optional ISO datetime strings (or datetimes when calling the Python functions). The current pysdmx SDMX-ML writer omits these attributes, so they do not survive an FMR round trip.

  • Structure-map rules (create_structure_map.maps, add_maps, modify_maps) use a type discriminator:

    • component: {"type": "component", "source": "FREQ", "target": "FREQ", "representation_map": "RepresentationMap=BIS:FREQ_MAP(1.0)"}

    • multi_component: {"type": "multi_component", "source": ["COUNTRY", "CURRENCY"], "target": ["CURRENCY"], "representation_map": {"agency": "BIS", "id": "MULTI_MAP", "version": "1.0"}}

    • fixed_value: {"type": "fixed_value", "target": "STATUS", "value": "F", "located_in": "target"} (located_in defaults to target)

    • implicit: {"type": "implicit", "source": "OLD_ID", "target": "NEW_ID"}

    • date_pattern: {"type": "date_pattern", "source": "TIME_PERIOD", "target": "TIME_PERIOD", "pattern": "MMM yy", "frequency": "M", "id": "DATE_RULE", "locale": "en", "pattern_type": "fixed", "resolve_period": "startOfPeriod"}. id, locale, pattern_type, and resolve_period are optional. Rules must have unique targets. representation_map accepts a URN or coordinates and is required for both component and multi_component. For a direct copy without value conversion, use implicit, including for measures: {"type": "implicit", "source": "OBS_VALUE", "target": "OBS_VALUE"}. A component rule without representation_map is not a direct copy and is rejected locally before submission to FMR.

Authoring behavior

  • Create operations reject an artefact that already exists at the requested agency, id, and version.

  • Updates merge into the existing artefact at the same id/version without a version bump; duplicate additions and missing targets are rejected.

  • Pass dry_run=true to preview a mutation without submitting it to the FMR.

Agency ids returned by RegistryClient.get_agencies(parent_agency) may include their ancestor path (for example BIS.CBS for the CBS agency under BIS), while SDMX-ML stores the short local id (CBS). The agency tools normalize these ids before submission and accept either form as input.

Run locally

Set the FMR URLs and credentials for the environment, then launch the server:

FMR_SDMX_URL=http://localhost:5000/sdmx/v2 \
FMR_SUBMIT_URL=http://localhost:5000/ws/secure/sdmxapi/rest/ \
FMR_ROOT_USER=demo \
FMR_ROOT_PASSWORD=password \
uv run server.py

Inside the aio-sandbox, use the FMR service name on the shared Docker network. For standalone runs, start the labspace stack and use a host/port reachable from the server process. The server uses the official mcp SDK's FastMCP implementation and serves Streamable HTTP at /mcp.

Tests

Run the full suite against the standalone, resettable FMR sandbox with:

./sandbox/run.sh test

The sandbox uses public container images, requires no sibling repository or private registry login, and treats an unavailable FMR as a failure. See sandbox/README.md for up, health, logs, reset, and configuration options.

For a fast local run without starting FMR, use:

uv run pytest

FMR-dependent tests skip when the service is unavailable in this optional local mode.

Before submitting a change, run the same locked fast gates as CI:

uv sync --locked --group dev
uv run ruff check .
uv run ruff format --check .
uv run pytest -q -m "not fmr_integration"

Run ./sandbox/run.sh test -q as well for registry, serialization, or authoring behavior changes. See AGENTS.md for the complete agent workflow.

License

This repository is distributed under the Workshop License. It allows workshop participants to download, copy, execute, and modify the software for personal learning, experimentation, and workshop-related purposes. Commercial use, production use, redistribution, and incorporation into other projects require prior written permission.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables searching, exploring, and querying over 1,500 OECD statistical datasets via SDMX, covering national accounts, employment, trade, PISA, health, and more.
      384 npm
      5
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables querying Bank for International Settlements central-bank and global financial statistics via the SDMX v2 API, including credit-to-GDP gaps, curated dataflows, and full registry search with dataset fetching, without authentication.
      77 npm
      1
      MIT