datagouv-mcp

repository·main·Indexed 23 days ago

https://github.com/datagouv/datagouv-mcp

A Model Context Protocol (MCP) server that enables AI chatbots to search, explore, and analyze datasets and resources from the French national Open Data platform (data.gouv.fr). It provides read-only tools including search_datasets, search_organizations, get_dataset_info, list_dataset_resources, get_resource_info, and query_resource_data. The server supports Streamable HTTP transport and can be deployed via Docker Compose or manually using uv.

Tokens
4.8K
Snippets
20
Records
32
Agent score
80%

What's inside datagouv-mcp

  1. Test the MCP server

    main

    Automated Tests (pytest)

    Run tests using uv run pytest.

    • Verbose: uv run pytest -v
    • Specific file: uv run pytest tests/test_tabular_api.py
    • With environment: DATAGOUV_API_ENV=prod uv run pytest

    Stress Tests

    Requires a running server. These test concurrency and client disconnect handling.

    # In a new terminal while server is running:
    uv run pytest -m stress

    Health Check

    Validates the end-to-end stack (tool layer + data.gouv.fr API).

    uv run pytest -m health_check

    Local Tool Testing Script

    Use scripts/call_tool.py to call tools without manual JSON-RPC handshakes. Requires a running server.

    python scripts/call_tool.py search_datasets '{"query": "IRVE"}'

    Interactive Testing (MCP Inspector)

    Use the official MCP Inspector to test tools interactively. Requires Node.js.

    1. Start the MCP server.
    2. In another terminal:
    npx @modelcontextprotocol/inspector --http-url "http://127.0.0.1:${MCP_PORT}/mcp"
  2. Configure OpenCode to use the data.gouv.fr MCP server

    main

    Add the configuration to opencode.json (e.g., ~/.config/opencode/opencode.json or your project root). Remote servers must use the top-level mcp object with type: "remote".

    {
      "$schema": "https://opencode.ai/config.json",
      "mcp": {
        "datagouv": {
          "type": "remote",
          "url": "https://mcp.data.gouv.fr/mcp",
          "enabled": true
        }
      }
    }
  3. Configure Cursor to use the data.gouv.fr MCP server

    main
    1. Open Cursor Settings.
    2. Search for "MCP" or "Model Context Protocol".
    3. Add a new MCP server with the following configuration:
    {
      "mcpServers": {
        "datagouv": {
          "url": "https://mcp.data.gouv.fr/mcp",
          "transport": "http"
        }
      }
    }
  4. Configure Le Chat (Mistral) to use the data.gouv.fr MCP server

    main

    Available on all plans, including free.

    1. Open Mistral in your browser and navigate to Intelligence > Connectors.
    2. Click Add connector > Custom MCP Connector.
    3. Provide a name (e.g., DataGouv) and set the server URL to https://mcp.data.gouv.fr/mcp.
    4. Leave authentication disabled.
    5. Click Create.
  5. Run the MCP server with Docker (Recommended)

    main

    The recommended way to run the data.gouv.fr MCP server is using Docker Compose. This handles dependencies and environment setup automatically.

    Setup

    1. Clone the repository:
    git clone git@github.com:datagouv/datagouv-mcp.git
    cd datagouv-mcp
    1. Ensure Docker Desktop or a compatible Docker Engine is installed.

    Commands

    • Start with default settings (Port 8000, production environment):
      docker compose up -d
    - **Start with custom environment variables**:
      ```shell
    MCP_PORT=8007 DATAGOUV_API_ENV=demo LOG_LEVEL=DEBUG docker compose up -d
    • Stop the server:
      docker compose down
    
    ```shell
    # With default settings (port 8000, prod environment)
    docker compose up -d
    
    # With custom environment variables
    MCP_PORT=8007 DATAGOUV_API_ENV=demo LOG_LEVEL=DEBUG docker compose up -d
    
    # Stop
    docker compose down
  6. Lint and format code manually

    main

    Before submitting contributions, you must ensure your code follows the project's style guidelines. This project uses Ruff for linting and formatting (following PEP 8) and ty for type checking. You can run these checks manually using uv.

    # Lint (including import sorting) and format code
    uv run ruff check --fix && uv run ruff format
    
    # Type check (ty)
    uv run ty check
  7. Configure VS Code to use the data.gouv.fr MCP server

    main

    Add the configuration to your VS Code mcp.json file. You can open this file by running MCP: Open User Configuration from the Command Palette.

    File Locations:

    • Linux: ~/.config/Code/User/mcp.json
    • MacOS: ~/Library/Application Support/Code/User/mcp.json
    • Windows: %APPDATA%\Code\User\mcp.json
    {
      "servers": {
        "datagouv": {
          "url": "https://mcp.data.gouv.fr/mcp",
          "type": "http"
        }
      }
    }
  8. Configure Claude Desktop to use the data.gouv.fr MCP server

    main

    Add the server configuration to your claude_desktop_config.json file.

    File Locations:

    • Linux: ~/.config/Claude/claude_desktop_config.json
    • MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json

    Windows Troubleshooting: If the server appears but tools are missing, Claude may be using its built-in Node.js runtime which cannot see your system npm packages. To fix this, set isUsingBuiltInNodeForMcp to false at the root of your config file to force Claude to use your installed Node version.

    {
      "isUsingBuiltInNodeForMcp": false,
      "mcpServers": {
        "datagouv": {
          "command": "npx",
          "args": [
            "mcp-remote",
            "https://mcp.data.gouv.fr/mcp"
          ]
        }
      }
    }
  9. Configure Kiro CLI and IDE to use the data.gouv.fr MCP server

    main

    For both CLI and IDE, add the configuration to mcp.json.

    File Locations:

    • Workspace config: .kiro/settings/mcp.json
    • Global config (Linux/MacOS): ~/.kiro/settings/mcp.json
    • Global config (Windows): %USERPROFILE%\.kiro\settings\mcp.json
    {
      "mcpServers": {
        "datagouv": {
          "url": "https://mcp.data.gouv.fr/mcp"
        }
      }
    }
  10. Configure ChatGPT to use the data.gouv.fr MCP server

    main

    Note: Requires a paid plan (Plus, Pro, Team, or Enterprise).

    1. Open ChatGPT in your browser and navigate to Settings > Apps and connectors.
    2. Go to Advanced settings and enable Developer mode.
    3. Return to Settings > Connectors > Browse connectors and click Add a new connector.
    4. Set the URL to https://mcp.data.gouv.fr/mcp and save.
  11. Create a new release using tag_version.sh

    main

    The project uses a tag_version.sh script to automate the release process, including creating git tags, generating GitHub releases, and updating CHANGELOG.md.

    Prerequisites:

    • GitHub CLI must be installed and authenticated.
    • You must be on the main branch with a clean working directory.

    Features:

    • Automatically extracts commits since the last tag for the changelog.
    • Identifies breaking changes (commits with !: in the subject).
    • Creates and pushes the git tag.
    • Creates a GitHub release.
    # Create a new release
    ./tag_version.sh <version>
    
    # Example
    ./tag_version.sh 2.5.0
    
    # Dry run to see what would happen
    ./tag_version.sh 2.5.0 --dry-run
  12. Configure AnythingLLM to use the data.gouv.fr MCP server

    main

    Locate the anythingllm_mcp_servers.json file in your AnythingLLM storage plugins directory:

    • Linux: ~/.config/anythingllm-desktop/storage/plugins/anythingllm_mcp_servers.json
    • MacOS: ~/Library/Application Support/anythingllm-desktop/storage/plugins/anythingllm_mcp_servers.json
    • Windows: C:\Users\<username>\AppData\Roaming\anythingllm-desktop\storage\plugins\anythingllm_mcp_servers.json

    Add the following configuration to the mcpServers object:

    {
      "mcpServers": {
        "datagouv": {
          "type": "streamable",
          "url": "https://mcp.data.gouv.fr/mcp"
        }
      }
    }