datagouv-mcp-server

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

datagouv-mcp-server

datagouv-mcp-server

Skill by ara.so — MCP Skills collection.
ara.so开发的Skill — 属于MCP Skills集合。

Overview

概述

The data.gouv.fr MCP Server is a Model Context Protocol (MCP) server that enables AI chatbots (Claude, ChatGPT, Gemini, etc.) to search, explore, and analyze datasets from data.gouv.fr, the French national Open Data platform, directly through conversation.
Instead of manually browsing the website, users can ask natural language questions like:
  • "Quels jeux de données sont disponibles sur les prix de l'immobilier?"
  • "Montre-moi les dernières données de population pour Paris"
Key Features:
  • Read-only access to French Open Data (no API key required)
  • Search datasets by keywords, topics, and filters
  • Explore dataset metadata, resources, and organizations
  • Works with all major MCP-compatible chatbots
  • Public hosted instance at
    https://mcp.data.gouv.fr/mcp
  • Self-hostable with Docker or Python
data.gouv.fr MCP Server是一款Model Context Protocol(MCP)服务器,它支持AI聊天机器人(Claude、ChatGPT、Gemini等)直接通过对话方式,从法国国家开放数据平台data.gouv.fr搜索、浏览和分析数据集。
无需手动浏览网站,用户可以用自然语言提问,例如:
  • "Quels jeux de données sont disponibles sur les prix de l'immobilier?"
  • "Montre-moi les dernières données de population pour Paris"
核心功能:
  • 只读访问法国开放数据(无需API密钥)
  • 通过关键词、主题和筛选条件搜索数据集
  • 浏览数据集元数据、资源和相关机构
  • 兼容所有主流MCP兼容聊天机器人
  • 公共托管实例地址:
    https://mcp.data.gouv.fr/mcp
  • 可通过Docker或Python自行部署

Installation & Configuration

安装与配置

Using the Public Hosted Instance (Recommended)

使用公共托管实例(推荐)

The easiest way to use this MCP server is to connect to the public instance at
https://mcp.data.gouv.fr/mcp
. No installation required.
使用这款MCP服务器最简单的方式是连接到公共实例
https://mcp.data.gouv.fr/mcp
,无需安装。

Client-Specific Configuration

客户端专属配置

Claude Desktop

Claude Desktop

Add to
~/.config/Claude/claude_desktop_config.json
(Linux),
~/Library/Application Support/Claude/claude_desktop_config.json
(macOS), or
%APPDATA%\Claude\claude_desktop_config.json
(Windows):
json
{
  "mcpServers": {
    "datagouv": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://mcp.data.gouv.fr/mcp"
      ]
    }
  }
}
Windows-specific fix: If the server doesn't connect, add this at the root level:
json
{
  "isUsingBuiltInNodeForMcp": false,
  "mcpServers": {
    "datagouv": {
      "command": "npx",
      "args": ["mcp-remote", "https://mcp.data.gouv.fr/mcp"]
    }
  }
}
添加配置到
~/.config/Claude/claude_desktop_config.json
(Linux)、
~/Library/Application Support/Claude/claude_desktop_config.json
(macOS)或
%APPDATA%\Claude\claude_desktop_config.json
(Windows):
json
{
  "mcpServers": {
    "datagouv": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://mcp.data.gouv.fr/mcp"
      ]
    }
  }
}
Windows专属修复: 如果服务器无法连接,在配置根节点添加以下内容:
json
{
  "isUsingBuiltInNodeForMcp": false,
  "mcpServers": {
    "datagouv": {
      "command": "npx",
      "args": ["mcp-remote", "https://mcp.data.gouv.fr/mcp"]
    }
  }
}

ChatGPT (Paid Plans Only)

ChatGPT(仅付费套餐可用)

  1. Go to
    Settings
    Apps and connectors
  2. Enable Developer mode in
    Advanced settings
  3. Go to
    Connectors
    Browse connectors
    Add a new connector
  4. Set URL to
    https://mcp.data.gouv.fr/mcp
    and save
  1. 进入
    Settings
    Apps and connectors
  2. Advanced settings
    中启用Developer mode
  3. 进入
    Connectors
    Browse connectors
    Add a new connector
  4. 设置URL为
    https://mcp.data.gouv.fr/mcp
    并保存

Cursor

Cursor

In Cursor Settings, search for "MCP" and add:
json
{
  "mcpServers": {
    "datagouv": {
      "url": "https://mcp.data.gouv.fr/mcp",
      "transport": "http"
    }
  }
}
在Cursor设置中搜索"MCP"并添加:
json
{
  "mcpServers": {
    "datagouv": {
      "url": "https://mcp.data.gouv.fr/mcp",
      "transport": "http"
    }
  }
}

VS Code

VS Code

Run MCP: Open User Configuration from Command Palette, then add:
json
{
  "servers": {
    "datagouv": {
      "url": "https://mcp.data.gouv.fr/mcp",
      "type": "http"
    }
  }
}
从命令面板运行MCP: Open User Configuration,然后添加:
json
{
  "servers": {
    "datagouv": {
      "url": "https://mcp.data.gouv.fr/mcp",
      "type": "http"
    }
  }
}

Windsurf

Windsurf

Add to
~/.codeium/windsurf/mcp_config.json
:
json
{
  "mcpServers": {
    "datagouv": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://mcp.data.gouv.fr/mcp"]
    }
  }
}
添加配置到
~/.codeium/windsurf/mcp_config.json
json
{
  "mcpServers": {
    "datagouv": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://mcp.data.gouv.fr/mcp"]
    }
  }
}

Le Chat (Mistral)

Le Chat (Mistral)

  1. Go to
    Intelligence
    Connectors
  2. Click
    Add connector
    Custom MCP Connector
  3. Name it (e.g., "DataGouv")
  4. Set URL to
    https://mcp.data.gouv.fr/mcp
  5. Leave authentication disabled and click Create
  1. 进入
    Intelligence
    Connectors
  2. 点击
    Add connector
    Custom MCP Connector
  3. 命名(例如"DataGouv")
  4. 设置URL为
    https://mcp.data.gouv.fr/mcp
  5. 保持认证禁用状态,点击Create

HuggingChat

HuggingChat

  1. Click + icon →
    MCP Servers
    Manage MCP Servers
  2. Click
    + Add Server
  3. Enter Server Name (e.g., "Data Gouv")
  4. Set Server URL to
    https://mcp.data.gouv.fr/mcp
  5. Click
    Add Server
    , then
    Health Check
    to verify
  1. 点击+图标 →
    MCP Servers
    Manage MCP Servers
  2. 点击
    + Add Server
  3. 输入服务器名称(例如"Data Gouv")
  4. 设置服务器URL为
    https://mcp.data.gouv.fr/mcp
  5. 点击
    Add Server
    ,然后点击
    Health Check
    验证连接

Running Locally

本地运行

Prerequisites

前置条件

  • Docker & Docker Compose (recommended)
  • OR Python with uv installed
  • Docker & Docker Compose(推荐)
  • 或安装了uv的Python环境

With Docker (Recommended)

使用Docker(推荐)

bash
undefined
bash
undefined

Clone the repository

克隆仓库

git clone git@github.com:datagouv/datagouv-mcp.git cd datagouv-mcp
git clone git@github.com:datagouv/datagouv-mcp.git cd datagouv-mcp

Run with default settings (port 8000, prod environment)

使用默认设置运行(端口8000,生产环境)

docker compose up -d
docker compose up -d

Run with custom settings

使用自定义设置运行

MCP_PORT=8007 DATAGOUV_API_ENV=demo LOG_LEVEL=DEBUG docker compose up -d
MCP_PORT=8007 DATAGOUV_API_ENV=demo LOG_LEVEL=DEBUG docker compose up -d

Stop

停止服务

docker compose down
undefined
docker compose down
undefined

With Python/uv

使用Python/uv

bash
undefined
bash
undefined

Clone the repository

克隆仓库

git clone git@github.com:datagouv/datagouv-mcp.git cd datagouv-mcp
git clone git@github.com:datagouv/datagouv-mcp.git cd datagouv-mcp

Install dependencies

安装依赖

uv sync
uv sync

Create environment file

创建环境变量文件

cp .env.example .env
cp .env.example .env

Edit .env as needed (optional)

根据需要编辑.env文件(可选)

MCP_HOST=127.0.0.1

MCP_HOST=127.0.0.1

MCP_PORT=8007

MCP_PORT=8007

DATAGOUV_API_ENV=prod

DATAGOUV_API_ENV=prod

LOG_LEVEL=INFO

LOG_LEVEL=INFO

Load environment variables

加载环境变量

set -a && source .env && set +a
set -a && source .env && set +a

Start the server

启动服务器

uv run main.py
undefined
uv run main.py
undefined

Environment Variables

环境变量

VariableDefaultDescription
MCP_HOST
0.0.0.0
Host to bind to (use
127.0.0.1
for local dev)
MCP_PORT
8000
Port for the MCP HTTP server
MCP_ENV
local
Environment name (for Sentry):
local
,
prod
,
preprod
,
demo
DATAGOUV_API_ENV
prod
data.gouv.fr environment:
prod
or
demo
LOG_LEVEL
INFO
Python logging level:
DEBUG
,
INFO
,
WARNING
,
ERROR
,
CRITICAL
SENTRY_DSN
(unset)Sentry DSN for error monitoring (optional)
SENTRY_SAMPLE_RATE
1.0
Sentry trace sampling rate (0.0-1.0)
变量默认值描述
MCP_HOST
0.0.0.0
绑定的主机地址(本地开发使用
127.0.0.1
MCP_PORT
8000
MCP HTTP服务器的端口
MCP_ENV
local
环境名称(用于Sentry):
local
prod
preprod
demo
DATAGOUV_API_ENV
prod
data.gouv.fr环境:
prod
demo
LOG_LEVEL
INFO
Python日志级别:
DEBUG
INFO
WARNING
ERROR
CRITICAL
SENTRY_DSN
(未设置)用于错误监控的Sentry DSN(可选)
SENTRY_SAMPLE_RATE
1.0
Sentry追踪采样率(0.0-1.0)

Using the MCP Server

使用MCP服务器

Once configured, you can interact with the MCP server through your AI chatbot by asking questions in natural language.
配置完成后,你可以通过AI聊天机器人以自然语言提问的方式与MCP服务器交互。

Example Queries

示例查询

Search datasets:
"Find datasets about real estate prices in France"
"Quels jeux de données existent sur la pollution de l'air?"
"Show me population data for Paris"
Explore organizations:
"What datasets does INSEE publish?"
"List all datasets from the Ministry of Health"
Dataset details:
"Give me information about dataset ID abc123"
"What resources are available in this dataset?"
搜索数据集:
"Find datasets about real estate prices in France"
"Quels jeux de données existent sur la pollution de l'air?"
"Show me population data for Paris"
浏览机构:
"What datasets does INSEE publish?"
"List all datasets from the Ministry of Health"
数据集详情:
"Give me information about dataset ID abc123"
"What resources are available in this dataset?"

Available MCP Tools

可用的MCP工具

The server exposes read-only tools for searching and exploring data.gouv.fr:
服务器提供了用于搜索和浏览data.gouv.fr的只读工具:

search_datasets

search_datasets

Search for datasets by keywords, topics, organizations, etc.
Parameters:
  • q
    (string, optional): Search query
  • page_size
    (int, optional): Results per page (default: 20)
  • page
    (int, optional): Page number (default: 1)
  • Additional filters:
    organization
    ,
    tag
    ,
    badge
    ,
    featured
    ,
    temporal_coverage
    ,
    granularity
    ,
    schema
    ,
    license
通过关键词、主题、机构等条件搜索数据集。
参数:
  • q
    (字符串,可选):搜索查询词
  • page_size
    (整数,可选):每页结果数量(默认:20)
  • page
    (整数,可选):页码(默认:1)
  • 额外筛选条件:
    organization
    tag
    badge
    featured
    temporal_coverage
    granularity
    schema
    license

get_dataset

get_dataset

Retrieve detailed information about a specific dataset.
Parameters:
  • dataset_id
    (string, required): The dataset ID or slug
获取特定数据集的详细信息。
参数:
  • dataset_id
    (字符串,必填):数据集ID或slug

list_resources

list_resources

List all resources (files, APIs) within a dataset.
Parameters:
  • dataset_id
    (string, required): The dataset ID or slug
列出数据集中的所有资源(文件、API)。
参数:
  • dataset_id
    (字符串,必填):数据集ID或slug

get_resource

get_resource

Get detailed information about a specific resource.
Parameters:
  • resource_id
    (string, required): The resource ID
获取特定资源的详细信息。
参数:
  • resource_id
    (字符串,必填):资源ID

Code Examples

代码示例

Python Client Example

Python客户端示例

python
import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

async def search_datasets():
    server_params = StdioServerParameters(
        command="npx",
        args=["mcp-remote", "https://mcp.data.gouv.fr/mcp"]
    )
    
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            # Initialize the connection
            await session.initialize()
            
            # Search for datasets
            result = await session.call_tool(
                "search_datasets",
                arguments={"q": "population", "page_size": 5}
            )
            
            print(result)

asyncio.run(search_datasets())
python
import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

async def search_datasets():
    server_params = StdioServerParameters(
        command="npx",
        args=["mcp-remote", "https://mcp.data.gouv.fr/mcp"]
    )
    
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            # 初始化连接
            await session.initialize()
            
            # 搜索数据集
            result = await session.call_tool(
                "search_datasets",
                arguments={"q": "population", "page_size": 5}
            )
            
            print(result)

asyncio.run(search_datasets())

Connecting a Custom Local Server

连接自定义本地服务器

If you're running the server locally on port 8007:
json
{
  "mcpServers": {
    "datagouv-local": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://127.0.0.1:8007"
      ]
    }
  }
}
如果你在本地8007端口运行服务器:
json
{
  "mcpServers": {
    "datagouv-local": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://127.0.0.1:8007"
      ]
    }
  }
}

Docker Compose Custom Configuration

Docker Compose自定义配置

yaml
undefined
yaml
undefined

docker-compose.yml

docker-compose.yml

services: mcp-server: build: . ports: - "8007:8007" environment: - MCP_HOST=0.0.0.0 - MCP_PORT=8007 - MCP_ENV=prod - DATAGOUV_API_ENV=prod - LOG_LEVEL=INFO - SENTRY_DSN=${SENTRY_DSN} restart: unless-stopped
undefined
services: mcp-server: build: . ports: - "8007:8007" environment: - MCP_HOST=0.0.0.0 - MCP_PORT=8007 - MCP_ENV=prod - DATAGOUV_API_ENV=prod - LOG_LEVEL=INFO - SENTRY_DSN=${SENTRY_DSN} restart: unless-stopped
undefined

Common Patterns

常见使用模式

Searching with Filters

带筛选条件的搜索

When helping users search datasets, combine text queries with filters:
python
undefined
帮助用户搜索数据集时,可结合文本查询和筛选条件:
python
undefined

Search for recent environmental datasets from a specific org

搜索特定机构发布的最新环境相关数据集

result = await session.call_tool( "search_datasets", arguments={ "q": "environment climate", "organization": "ademe", "badge": "climate-change", "page_size": 10 } )
undefined
result = await session.call_tool( "search_datasets", arguments={ "q": "environment climate", "organization": "ademe", "badge": "climate-change", "page_size": 10 } )
undefined

Progressive Exploration

渐进式浏览

  1. Start with broad search
  2. Get dataset details with
    get_dataset
  3. List resources with
    list_resources
  4. Get specific resource details with
    get_resource
  1. 从宽泛搜索开始
  2. 使用
    get_dataset
    获取数据集详情
  3. 使用
    list_resources
    列出资源
  4. 使用
    get_resource
    获取特定资源详情

Handling Pagination

处理分页

python
undefined
python
undefined

Get first page

获取第一页

page1 = await session.call_tool( "search_datasets", arguments={"q": "transport", "page": 1, "page_size": 20} )
page1 = await session.call_tool( "search_datasets", arguments={"q": "transport", "page": 1, "page_size": 20} )

Get next page

获取下一页

page2 = await session.call_tool( "search_datasets", arguments={"q": "transport", "page": 2, "page_size": 20} )
undefined
page2 = await session.call_tool( "search_datasets", arguments={"q": "transport", "page": 2, "page_size": 20} )
undefined

Troubleshooting

故障排除

Server Not Connecting in Claude Desktop (Windows)

Claude Desktop(Windows)中服务器无法连接

Symptom: Server appears in list but never connects, no tools visible
Solution: Add
"isUsingBuiltInNodeForMcp": false
to the root of
claude_desktop_config.json
:
json
{
  "isUsingBuiltInNodeForMcp": false,
  "mcpServers": { ... }
}
症状: 服务器出现在列表中但始终无法连接,看不到工具
解决方案:
claude_desktop_config.json
的根节点添加
"isUsingBuiltInNodeForMcp": false
json
{
  "isUsingBuiltInNodeForMcp": false,
  "mcpServers": { ... }
}
参考issue #69

Connection Timeout

连接超时

Symptom: Server fails to respond or times out
Solutions:
  1. Verify the public instance is up:
    curl https://mcp.data.gouv.fr/mcp
  2. Check your network/firewall settings
  3. Try running a local instance instead
症状: 服务器无响应或超时
解决方案:
  1. 验证公共实例是否正常运行:
    curl https://mcp.data.gouv.fr/mcp
  2. 检查网络/防火墙设置
  3. 尝试运行本地实例

Local Server Won't Start

本地服务器无法启动

Symptom: Error when running
uv run main.py
Solutions:
  1. Ensure
    uv
    is installed:
    pip install uv
  2. Verify Python version compatibility (check
    pyproject.toml
    )
  3. Check
    .env
    file exists and is loaded
  4. Review logs with
    LOG_LEVEL=DEBUG
症状: 运行
uv run main.py
时出现错误
解决方案:
  1. 确保已安装
    uv
    pip install uv
  2. 验证Python版本兼容性(查看
    pyproject.toml
  3. 检查
    .env
    文件是否存在并已加载
  4. 使用
    LOG_LEVEL=DEBUG
    查看日志

No Results Returned

无结果返回

Symptom: Search returns empty results
Solutions:
  1. Verify
    DATAGOUV_API_ENV
    is set correctly (
    prod
    vs
    demo
    )
  2. Try broader search terms
  3. Check if specific filters are too restrictive
  4. Test the same query on https://www.data.gouv.fr directly
症状: 搜索返回空结果
解决方案:
  1. 验证
    DATAGOUV_API_ENV
    设置是否正确(
    prod
    vs
    demo
  2. 尝试更宽泛的搜索词
  3. 检查筛选条件是否过于严格
  4. https://www.data.gouv.fr直接测试相同查询

CORS Issues (Browser-Based Clients)

CORS问题(基于浏览器的客户端)

Symptom: CORS errors in browser console
Solution: The public instance should handle CORS. If self-hosting, ensure your server configuration allows CORS from your client origin.
症状: 浏览器控制台出现CORS错误
解决方案: 公共实例已处理CORS问题。如果是自行部署,请确保服务器配置允许来自客户端源的CORS请求。

Development & Testing

开发与测试

Run Tests

运行测试

bash
undefined
bash
undefined

Install dev dependencies

安装开发依赖

uv sync --dev
uv sync --dev

Run tests

运行测试

uv run pytest
uv run pytest

Run with coverage

运行测试并生成覆盖率报告

uv run pytest --cov=src
undefined
uv run pytest --cov=src
undefined

Enable Debug Logging

启用调试日志

bash
LOG_LEVEL=DEBUG uv run main.py
bash
LOG_LEVEL=DEBUG uv run main.py

Test Against Demo Environment

针对演示环境测试

bash
DATAGOUV_API_ENV=demo uv run main.py
This connects to https://demo.data.gouv.fr instead of production.
bash
DATAGOUV_API_ENV=demo uv run main.py

Resources

资源

License

许可证

MIT License - See the repository for full details.
MIT许可证 - 详见仓库中的完整说明。