datagouv-mcp-server
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesedatagouv-mcp-server
datagouv-mcp-server
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 . No installation required.
https://mcp.data.gouv.fr/mcp使用这款MCP服务器最简单的方式是连接到公共实例,无需安装。
https://mcp.data.gouv.fr/mcpClient-Specific Configuration
客户端专属配置
Claude Desktop
Claude Desktop
Add to (Linux), (macOS), or (Windows):
~/.config/Claude/claude_desktop_config.json~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.jsonjson
{
"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"]
}
}
}添加配置到(Linux)、(macOS)或(Windows):
~/.config/Claude/claude_desktop_config.json~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.jsonjson
{
"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(仅付费套餐可用)
- Go to →
SettingsApps and connectors - Enable Developer mode in
Advanced settings - Go to →
Connectors→Browse connectorsAdd a new connector - Set URL to and save
https://mcp.data.gouv.fr/mcp
- 进入→
SettingsApps and connectors - 在中启用Developer mode
Advanced settings - 进入→
Connectors→Browse connectorsAdd a new connector - 设置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.jsonjson
{
"mcpServers": {
"datagouv": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp.data.gouv.fr/mcp"]
}
}
}添加配置到:
~/.codeium/windsurf/mcp_config.jsonjson
{
"mcpServers": {
"datagouv": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp.data.gouv.fr/mcp"]
}
}
}Le Chat (Mistral)
Le Chat (Mistral)
- Go to →
IntelligenceConnectors - Click →
Add connectorCustom MCP Connector - Name it (e.g., "DataGouv")
- Set URL to
https://mcp.data.gouv.fr/mcp - Leave authentication disabled and click Create
- 进入→
IntelligenceConnectors - 点击→
Add connectorCustom MCP Connector - 命名(例如"DataGouv")
- 设置URL为
https://mcp.data.gouv.fr/mcp - 保持认证禁用状态,点击Create
HuggingChat
HuggingChat
- Click + icon → →
MCP ServersManage MCP Servers - Click
+ Add Server - Enter Server Name (e.g., "Data Gouv")
- Set Server URL to
https://mcp.data.gouv.fr/mcp - Click , then
Add Serverto verifyHealth Check
- 点击+图标 → →
MCP ServersManage MCP Servers - 点击
+ Add Server - 输入服务器名称(例如"Data Gouv")
- 设置服务器URL为
https://mcp.data.gouv.fr/mcp - 点击,然后点击
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
undefinedbash
undefinedClone 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
undefineddocker compose down
undefinedWith Python/uv
使用Python/uv
bash
undefinedbash
undefinedClone 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
undefineduv run main.py
undefinedEnvironment Variables
环境变量
| Variable | Default | Description |
|---|---|---|
| | Host to bind to (use |
| | Port for the MCP HTTP server |
| | Environment name (for Sentry): |
| | data.gouv.fr environment: |
| | Python logging level: |
| (unset) | Sentry DSN for error monitoring (optional) |
| | Sentry trace sampling rate (0.0-1.0) |
| 变量 | 默认值 | 描述 |
|---|---|---|
| | 绑定的主机地址(本地开发使用 |
| | MCP HTTP服务器的端口 |
| | 环境名称(用于Sentry): |
| | data.gouv.fr环境: |
| | Python日志级别: |
| (未设置) | 用于错误监控的Sentry DSN(可选) |
| | 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_datasetssearch_datasets
search_datasetsSearch for datasets by keywords, topics, organizations, etc.
Parameters:
- (string, optional): Search query
q - (int, optional): Results per page (default: 20)
page_size - (int, optional): Page number (default: 1)
page - Additional filters: ,
organization,tag,badge,featured,temporal_coverage,granularity,schemalicense
通过关键词、主题、机构等条件搜索数据集。
参数:
- (字符串,可选):搜索查询词
q - (整数,可选):每页结果数量(默认:20)
page_size - (整数,可选):页码(默认:1)
page - 额外筛选条件:、
organization、tag、badge、featured、temporal_coverage、granularity、schemalicense
get_dataset
get_datasetget_dataset
get_datasetRetrieve detailed information about a specific dataset.
Parameters:
- (string, required): The dataset ID or slug
dataset_id
获取特定数据集的详细信息。
参数:
- (字符串,必填):数据集ID或slug
dataset_id
list_resources
list_resourceslist_resources
list_resourcesList all resources (files, APIs) within a dataset.
Parameters:
- (string, required): The dataset ID or slug
dataset_id
列出数据集中的所有资源(文件、API)。
参数:
- (字符串,必填):数据集ID或slug
dataset_id
get_resource
get_resourceget_resource
get_resourceGet detailed information about a specific resource.
Parameters:
- (string, required): The resource ID
resource_id
获取特定资源的详细信息。
参数:
- (字符串,必填):资源ID
resource_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
undefinedyaml
undefineddocker-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
undefinedservices:
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
undefinedCommon Patterns
常见使用模式
Searching with Filters
带筛选条件的搜索
When helping users search datasets, combine text queries with filters:
python
undefined帮助用户搜索数据集时,可结合文本查询和筛选条件:
python
undefinedSearch 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
}
)
undefinedresult = await session.call_tool(
"search_datasets",
arguments={
"q": "environment climate",
"organization": "ademe",
"badge": "climate-change",
"page_size": 10
}
)
undefinedProgressive Exploration
渐进式浏览
- Start with broad search
- Get dataset details with
get_dataset - List resources with
list_resources - Get specific resource details with
get_resource
- 从宽泛搜索开始
- 使用获取数据集详情
get_dataset - 使用列出资源
list_resources - 使用获取特定资源详情
get_resource
Handling Pagination
处理分页
python
undefinedpython
undefinedGet 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}
)
undefinedpage2 = await session.call_tool(
"search_datasets",
arguments={"q": "transport", "page": 2, "page_size": 20}
)
undefinedTroubleshooting
故障排除
Server Not Connecting in Claude Desktop (Windows)
Claude Desktop(Windows)中服务器无法连接
Symptom: Server appears in list but never connects, no tools visible
Solution: Add to the root of :
"isUsingBuiltInNodeForMcp": falseclaude_desktop_config.jsonjson
{
"isUsingBuiltInNodeForMcp": false,
"mcpServers": { ... }
}See issue #69
症状: 服务器出现在列表中但始终无法连接,看不到工具
解决方案: 在的根节点添加:
claude_desktop_config.json"isUsingBuiltInNodeForMcp": falsejson
{
"isUsingBuiltInNodeForMcp": false,
"mcpServers": { ... }
}Connection Timeout
连接超时
Symptom: Server fails to respond or times out
Solutions:
- Verify the public instance is up:
curl https://mcp.data.gouv.fr/mcp - Check your network/firewall settings
- Try running a local instance instead
症状: 服务器无响应或超时
解决方案:
- 验证公共实例是否正常运行:
curl https://mcp.data.gouv.fr/mcp - 检查网络/防火墙设置
- 尝试运行本地实例
Local Server Won't Start
本地服务器无法启动
Symptom: Error when running
uv run main.pySolutions:
- Ensure is installed:
uvpip install uv - Verify Python version compatibility (check )
pyproject.toml - Check file exists and is loaded
.env - Review logs with
LOG_LEVEL=DEBUG
症状: 运行时出现错误
uv run main.py解决方案:
- 确保已安装:
uvpip install uv - 验证Python版本兼容性(查看)
pyproject.toml - 检查文件是否存在并已加载
.env - 使用查看日志
LOG_LEVEL=DEBUG
No Results Returned
无结果返回
Symptom: Search returns empty results
Solutions:
- Verify is set correctly (
DATAGOUV_API_ENVvsprod)demo - Try broader search terms
- Check if specific filters are too restrictive
- Test the same query on https://www.data.gouv.fr directly
症状: 搜索返回空结果
解决方案:
- 验证设置是否正确(
DATAGOUV_API_ENVvsprod)demo - 尝试更宽泛的搜索词
- 检查筛选条件是否过于严格
- 在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
undefinedbash
undefinedInstall dev dependencies
安装开发依赖
uv sync --dev
uv sync --dev
Run tests
运行测试
uv run pytest
uv run pytest
Run with coverage
运行测试并生成覆盖率报告
uv run pytest --cov=src
undefineduv run pytest --cov=src
undefinedEnable Debug Logging
启用调试日志
bash
LOG_LEVEL=DEBUG uv run main.pybash
LOG_LEVEL=DEBUG uv run main.pyTest Against Demo Environment
针对演示环境测试
bash
DATAGOUV_API_ENV=demo uv run main.pyThis connects to https://demo.data.gouv.fr instead of production.
bash
DATAGOUV_API_ENV=demo uv run main.pyResources
资源
- Project Repository: https://github.com/datagouv/datagouv-mcp
- Public Instance: https://mcp.data.gouv.fr/mcp
- data.gouv.fr Platform: https://www.data.gouv.fr
- MCP Specification: https://modelcontextprotocol.io
- Feedback Form: https://tally.so/r/KYMboX
- 项目仓库: https://github.com/datagouv/datagouv-mcp
- 公共实例: https://mcp.data.gouv.fr/mcp
- data.gouv.fr平台: https://www.data.gouv.fr
- MCP规范: https://modelcontextprotocol.io
- 反馈表单: https://tally.so/r/KYMboX
License
许可证
MIT License - See the repository for full details.
MIT许可证 - 详见仓库中的完整说明。