Skip to content
FAIRDataTeamPublic

About

FAIR Data Point' Model Context Protocol (MCP)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

fdp-mcp — MCP bridge for FAIR Data Points

A standalone Model Context Protocol (MCP) server that makes any spec-compliant FAIR Data Point (FDP) consumable by AI agents. Point it at an FDP, connect an MCP client (Claude, or any other), and converse with the repository's metadata — datasets, schemas, licenses, access conditions — grounded in real records and cited by IRI.

docker run --rm -p 8080:8000 \
  -e FDP_BASE_URL=https://your-fdp.example.org \
  ghcr.io/fairdatateam/fdp-mcp:main
  • Works on the network that exists. It consumes only the public, specified FDP surface (LDP, /sparql, the search API, SHACL shapes) — so it works against FDPneo and the Java reference implementation with no server-side changes.

  • Read-only by default, and safe. Strict egress (talks only to the target FDP); anonymous by default, or it forwards your FDP API key per session (never stored, never logged). Four write tools (create/update/delete/publish) are available only when the operator sets FDP_MCP_ENABLE_WRITE=true; they need a forwarded credential and every write is decided by the FDP, not the bridge.

  • Honest. A capability the target FDP lacks degrades to a structured unsupported result — never a fabricated answer. Every record result carries its IRI so the agent cites holdings instead of inventing them.

  • Contract-first. The tool contract is implementation-agnostic and published in docs/mcp-tool-surface.md; this codebase is its reference implementation.

  • What it can do

  • How it works

  • Quick start

  • Build from source

  • Configuration

  • Deploy

  • Connect an MCP client

  • Security posture

  • Develop

  • Project docs


What it can do

Eight read tools over one FDP (plus four opt-in write tools, below):

Tool Purpose Notes
fdp_info Describe the repository: root record, the resource kinds it holds, and which optional endpoints (SPARQL, search) it supports. Kinds are discovered at runtime, never hard-coded.
list_records Enumerate records, optionally by kind and/or parent container, paged. Summary records; IRIs always present.
get_record Full metadata for one record IRI, with signposting/containment links. Framed JSON-LD by default; raw Turtle/JSON-LD/RDF-XML/N-Triples on request.
get_schema The SHACL shape for a kind — what its fields mean and expect. Optional (capability shapes).
search Keyword/faceted discovery within the FDP. Optional (capability search-api); degrades where absent.
sparql_query Read-only SPARQL over the public endpoint. Update/SERVICE forms refused before any network call. Optional (sparql).
get_access_conditions "May I use this, under what licence, and whom do I contact?" — resolves dct:license, ODRL dct:rights, dct:accessRights, and contact points. Reports determinable: false honestly when the metadata is silent.
list_data_services Enumerate DCAT DataService records with their endpoints and dct:conformsTo claims. Discovery only; the seed of the capability profile.

Writing (opt-in). With FDP_MCP_ENABLE_WRITE=true the bridge also registers:

Tool Purpose Notes
create_record Create a record in a container (LDP POST). Body parsed client-side (one primary subject), sent verbatim; the FDP runs SHACL → validation_failed with the violations.
update_record Replace (PUT) or patch (SPARQL-update PATCH) a record. if_match = the etag from get_record is mandatory; stale → precondition_failed. PATCH is an optional capability (ldp_patch).
delete_record Delete a record (LDP DELETE). if_match mandatory.
set_record_state DRAFT → PUBLISHED → ARCHIVED transitions. Follows the FDP's advertised affordance; optional capability (state_transition).

Write tools refuse an anonymous session before any network call (authentication_required) — a write cannot succeed without a credential for the FDP to evaluate. Contract: §5.9–§5.12; decision: ADR-0024 (server repo).

Endpoint discovery. When the FDP advertises its service endpoints in the root record (VoID void:sparqlEndpoint, DCAT dcat:DataService), the bridge discovers them automatically; otherwise it falls back to configured paths. An explicit operator override always wins, and an advertised endpoint is used only if it sits on the FDP's own origin (strict egress).


How it works

MCP client  ──MCP──▶  fdp-mcp  ──HTTP (public surface only)──▶  FAIR Data Point
(Claude, …)          (this)      LDP GET · /sparql · search · SHACL shapes

fdp-mcp is a thin adapter: each tool translates, paginates, and shapes results from the FDP's public HTTP surface into agent-friendly JSON. It holds no authorization logic — the FDP's own publication-state / policy machinery decides what a request (anonymous, or with a forwarded key) may see. Because the bridge may use only the public surface, every capability it cannot implement cleanly is recorded as a public-API gap in docs/fdp-api-gaps.md and fed back to the FDP roadmap.

Motivation and placement: the Agent Consumption Vision and ADR-0018.


Quick start

The only required setting is FDP_BASE_URL.

docker run --rm -p 8080:8000 \
  -e FDP_BASE_URL=https://your-fdp.example.org \
  ghcr.io/fairdatateam/fdp-mcp:main

The bridge serves the streamable-HTTP MCP transport at http://localhost:8080/mcp and a liveness probe at http://localhost:8080/healthz. For the full walkthrough — client configs and a scripted three-minute demo — see docs/agent-quickstart.md.


Build from source

Requires Python 3.14+ and uv.

uv sync                                   # install deps into .venv
FDP_BASE_URL=https://your-fdp.example.org uv run fdp-mcp

Build the container image locally:

docker build -t fdp-mcp:local .
docker run --rm -p 8080:8000 -e FDP_BASE_URL=https://your-fdp.example.org fdp-mcp:local

The image is multi-stage (uv build → slim, non-root runtime). CI publishes ghcr.io/fairdatateam/fdp-mcp on every push to main (tags: main + commit SHA; no latest tag). The package is currently private — pulling needs docker login ghcr.io with a token that has read:packages, or build from source as above.


Configuration

FDP_BASE_URL is required; everything else has a safe default. Non-URL settings are namespaced under FDP_MCP_.

Variable Default Purpose
FDP_BASE_URL (required) Base URL of the target FDP. The bridge speaks only to this origin.
FDP_MCP_TRANSPORT streamable-http streamable-http (network sidecar) or stdio (desktop-client subprocess).
FDP_MCP_HOST 127.0.0.1 Bind address for streamable-HTTP. The image sets 0.0.0.0.
FDP_MCP_PORT 8000 Bind port for streamable-HTTP.
FDP_MCP_LOG_LEVEL info debug / info / warning / error / critical. Credentials are always redacted.
FDP_MCP_FDP_TIMEOUT_SECONDS 30 Per-request timeout for FDP calls.
FDP_MCP_FDP_MAX_RESPONSE_BYTES 10485760 Response-size cap (10 MiB); oversized responses are aborted.
FDP_MCP_FDP_SPARQL_PATH /fdp-api/sparql SPARQL endpoint path override. When left default, an advertised endpoint is preferred.
FDP_MCP_FDP_SEARCH_PATH /fdp-api/search Search endpoint path override. Same discovery behaviour.
FDP_MCP_ENABLE_WRITE false Register the four write tools. Off = strictly read-only (the tools do not exist). Inert on stdio (no credential can be forwarded).
FDP_MCP_MAX_CONCURRENT_SESSIONS 100 Cap on concurrent sessions (streamable-HTTP).
FDP_MCP_SESSION_IDLE_TIMEOUT_SECONDS 300 Drop a session after this idle period.
FDP_MCP_SESSION_LIFETIME_TIMEOUT_SECONDS 3600 Absolute session lifetime ceiling.

There is no credential setting and no egress allow-list setting by design — a forwarded API key is per-session and memory-only, and egress is pinned to FDP_BASE_URL's origin in code.


Deploy

Run the published image with FDP_BASE_URL (see Quick start), or add it to a compose stack alongside the FDP so an FDPneo install comes up agent-ready:

services:
  fdp-mcp:
    image: ghcr.io/fairdatateam/fdp-mcp:main
    environment:
      FDP_BASE_URL: http://server:8000   # the FDP container's in-network URL
      FDP_MCP_HOST: 0.0.0.0
    ports:
      - "8080:8000"
    depends_on:
      - server
    restart: unless-stopped

Terminate TLS and apply rate limits at a reverse proxy in front of the sidecar, as for any long-lived-connection service.


Connect an MCP client

Claude Desktop (stdio). Add to claude_desktop_config.json:

{
  "mcpServers": {
    "fdp": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-e", "FDP_BASE_URL=https://your-fdp.example.org",
        "-e", "FDP_MCP_TRANSPORT=stdio",
        "ghcr.io/fairdatateam/fdp-mcp:main"
      ]
    }
  }
}

Generic streamable-HTTP clients. Connect to http://localhost:8080/mcp.

Forwarding an API key. Anonymous by default; to see restricted records the client supplies your FDP API key as the session bearer (Authorization: Bearer <key>), forwarded verbatim to the FDP for that session only.

Per-client config snippets, MCP Inspector usage, and the demo script are in docs/agent-quickstart.md.


Security posture

  • Strict egress — outbound HTTP is pinned to FDP_BASE_URL's origin (redirects included); no arbitrary IRIs are dereferenced, and SPARQL SERVICE (federation) is refused.
  • Read-only by default — write tools exist only behind FDP_MCP_ENABLE_WRITE=true, refuse anonymous sessions before any network call, require if_match from the caller, validate bodies/updates client-side (no LOAD/SERVICE, no off-origin graphs), and forward every write for the FDP to decide. sparql_query always rejects update forms.
  • Credentials — anonymous by default; a forwarded key is memory-only, session-scoped, never persisted, and redacted from all logs.
  • Bounded — per-request timeouts, a response-size cap, and a concurrent-session cap.

Develop

Tooling matches the server repo: uv, ruff, pyright (strict), pytest.

uv sync --extra dev
uv run ruff check . && uv run ruff format --check .
uv run pyright
uv run pytest                       # unit + conformance + in-process integration

Run the live integration test against a real FDP:

FDP_MCP_IT_BASE_URL=http://localhost:8000 uv run pytest tests/integration/test_live_fdp.py

Layout: src/fdp_mcp/ — config.py, server.py, fdp/ (client layer: client, ldp, sparql, search, shapes, discovery), tools/ (one module per tool), shaping.py (JSON-LD framing + envelopes). Conventions and ground rules for contributors are in CLAUDE.md.


Project docs

Status

Released — the full read tool surface (eight tools), the opt-in write extension (four tools, ADR-0024), root-metadata endpoint discovery, and unit/conformance/integration suites are in place; the read surface is validated against a live FDPneo. See CHANGELOG.md.

License

Apache-2.0 (matching the FDP server).

About

FAIR Data Point' Model Context Protocol (MCP)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages