Skip to content

Repository files navigation

datagouv-mcp-client

A small experimental Python client and agent-tool layer for exploring public data from data.gouv.fr.

The client calls the public data.gouv.fr APIs directly and provides Python methods plus OpenAI-compatible function schemas for dataset discovery, metadata, resources, downloads, and dataservices. It mirrors a subset of the read-only workflows available through the official data.gouv.fr MCP server, but it is not the official server and does not implement MCP transport.

Status: early prototype. Install from source; this project is not published on PyPI.

What is included

  • Search datasets and dataservices.
  • Read dataset, resource, and dataservice metadata.
  • Download and parse CSV, TSV, JSON, JSONL, and Parquet resources.
  • Generate OpenAI-compatible function definitions for agent loops.
  • Register additional local tool runners.
  • Build a small public-spending data demo from data.gouv.fr sources.

Repository structure

Path Purpose
src/datagouv_client/ Python API client and agent-tool schemas
examples/ Small Python usage examples
scripts/ Data preparation and validation scripts
app/ React public-spending demo using generated static JSON

Install from source

Python 3.13 and uv are recommended.

git clone https://github.com/offmann/datagouv-mcp-client.git
cd datagouv-mcp-client
uv sync

Python client

from datagouv_client import DatagouvClient

client = DatagouvClient()

result = client.search_datasets("qualite de l'air")
print(result["datasets"][:3])

dataset = client.get_dataset_info("56fd8e8788ee387079c352f7")
print(dataset["title"], dataset["resources_count"])

Agent function tools

from datagouv_client import DatagouvClient
from datagouv_client.client import get_openai_tools, run_tool

client = DatagouvClient()
tools = get_openai_tools()

# Run a tool selected by an agent.
result = run_tool("search_datasets", {"query": "air quality"}, client)

These are function-call schemas and local Python runners. To connect an MCP-compatible assistant directly to data.gouv.fr, use the official hosted endpoint:

https://mcp.data.gouv.fr/mcp

See datagouv/datagouv-mcp for supported clients and configuration.

Public-spending demo

The repository also contains a small React demonstration built from generated static JSON:

uv run python scripts/prepare_data.py
uv run python scripts/validate_data_contract.py
cd app
npm install
npm run dev

The preparation pipeline records source provenance and falls back to configured direct URLs when resource metadata lookup fails. See docs/data_pipeline_modes.md.

Data handling

  • The client has no persistent cache.
  • Downloads are held in memory while being parsed.
  • max_size_mb rejects resources after download when they exceed the configured limit.
  • max_rows limits parsed output; it does not limit network transfer size.

License

MIT

About

Lightweight Python client and agent-tool prototype for exploring data.gouv.fr alongside the official MCP server.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages