Skip to main content

MCP server exposing Spanish public-data sources (Catastro, BORME, CENDOJ, public tenders) to AI agents

Project description

DataPrem MCP Server

A Model Context Protocol (MCP) server that exposes Spanish public-data sources to AI agents (Claude Desktop, Cursor, ChatGPT, …).

It is a thin client of the DataPrem REST API: each MCP tool maps to an HTTPS call against api.dataprem.com using your API key.

Tool status (v0.3.0)

Tool Status Real source Available
dataprem_catastro_lookup Live Sede Electrónica del Catastro via DataPrem API
dataprem_borme_search Stub Boletín Oficial del Registro Mercantil Phase 3 (TK-481)
dataprem_cendoj_search Stub Centro de Documentación Judicial Phase 4 (TK-487)
dataprem_tenders_search Stub Plataforma de Contratación del Sector Público Phase 3 (TK-482)

Stubs return demonstration data flagged with _status: "stub" in the payload — useful so the LLM learns the expected shape of each tool and for UX mockups, but they are not real data.

Getting an API key

The "live" tools require a valid Bearer token from api.dataprem.com. While we are in pre-monetisation (Phase 1) tokens are issued manually:

  1. Request access by email to info@dataprem.com describing the use case (B2B integrator, B2C professional, …).
  2. You will receive a token prefixed dpa_… along with the API URL.
  3. Configure it in your MCP client (next section).

In Phase 2 the /account portal (TK-477) will let you generate and rotate tokens self-service.

Installation

Requires Python 3.11+.

# Via PyPI (recommended for MCP clients)
uvx dataprem-mcp

# Or local install for development
pip install -e ".[dev]"

Claude Desktop configuration

Edit claude_desktop_config.json (Mac: ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "dataprem": {
      "command": "uvx",
      "args": ["dataprem-mcp"],
      "env": {
        "DATAPREM_API_KEY": "dpa_YOUR_TOKEN_HERE",
        "DATAPREM_API_URL": "https://api.dataprem.com"
      }
    }
  }
}

Restart Claude Desktop. The four tools should show up as available to the model.

Server-side HTTP transport

For clients that cannot spawn the server as a subprocess (e.g. a multi-request web app) there is a streamable-http transport that runs the server as a long-lived process listening for JSON-RPC over HTTP.

# Without Docker
python -m dataprem_mcp --transport streamable-http --host 0.0.0.0 --port 8080

# With Docker
docker compose up dataprem_mcp     # local image build; exposed only on the internal network

The MCP endpoint is /mcp (no trailing slash). The standard handshake (initializetools/listtools/call) works with Content-Type: application/json and Accept: application/json, text/event-stream. Each conversation receives an mcp-session-id that the client must echo back on subsequent requests.

# Example: initialize handshake
curl -sL -X POST http://127.0.0.1:8080/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize",
    "params": {
      "protocolVersion": "2025-03-26",
      "clientInfo": {"name": "smoke", "version": "1"},
      "capabilities": {}
    }
  }' -i

By default the compose service does not publish the port to the host: place it on a Docker network shared with your client and reach it as http://dataprem_mcp:8080/mcp.

Alternative configuration (local development)

{
  "mcpServers": {
    "dataprem-dev": {
      "command": "python",
      "args": ["-m", "dataprem_mcp"],
      "cwd": "/path/to/dataprem-mcp",
      "env": {
        "DATAPREM_API_KEY": "dpa_dev_token",
        "DATAPREM_API_URL": "http://localhost:8000"
      }
    }
  }
}

Environment variables

Variable Default Description
DATAPREM_API_KEY (empty) Bearer token (dpa_…). Required for live tools.
DATAPREM_API_URL https://api.dataprem.com API base URL. Override to point at a development environment.

Tools — reference

dataprem_catastro_lookup ✅ Live

Looks up cadastral data for a property. Two modes are supported:

By cadastral reference:

Parameter Type Description
refcat string Cadastral reference (14, 18 or 20 characters)

By address:

Parameter Type Required Description
address string yes Literal address (street type + name + number)
city string yes Municipality
province string no Province

Returns the normalised cadastral record (class, use, surfaces, year of construction, address with INE codes, breakdown of constructions by floor and use). Does not expose the owner for LOPD/GDPR reasons.

dataprem_borme_search (stub — Phase 3)

Parameter Type Required
company_name string yes
date_from string YYYY-MM-DD no
date_to string YYYY-MM-DD no

dataprem_cendoj_search (stub — Phase 4)

Parameter Type Required
query string yes
court string no
date_from string YYYY-MM-DD no

dataprem_tenders_search (stub — Phase 3)

Parameter Type Required
query string yes
location string no
status "open" | "closed" | "all" no

Response shape

Every tool returns a dict. Live tools mark success or failure with ok:

{ "ok": true, "data": { ... cadastral record ... } }

{ "ok": false, "error": "unauthorized", "message": "API key invalid or revoked..." }

Stub tools advertise their nature with _status and the real ETA:

{ "_status": "stub", "_eta_phase": "Phase 3 (TK-481)", "_message": "Demonstration data...", ...demo data... }

Error codes returned by live tools:

error Meaning
missing_api_key DATAPREM_API_KEY is not set in the environment
invalid_request Required parameters are missing
unauthorized Token revoked or expired
not_found The upstream returned no match
validation_error Catastro rejected the input (malformed RC, unknown street, …)
rate_limited Monthly quota exhausted
upstream_error Catastro or DataPrem temporarily unavailable
upstream_unreachable DATAPREM_API_URL cannot be reached

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run the server with a local API key
DATAPREM_API_KEY=dpa_xxx DATAPREM_API_URL=http://localhost python -m dataprem_mcp

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dataprem_mcp-0.3.2.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dataprem_mcp-0.3.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file dataprem_mcp-0.3.2.tar.gz.

File metadata

  • Download URL: dataprem_mcp-0.3.2.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dataprem_mcp-0.3.2.tar.gz
Algorithm Hash digest
SHA256 9dc4867db8308ba711119a9be59ef1c450ae7fb53034587911b987c73dd4b650
MD5 847469a22daacfc2e6042c20402e1647
BLAKE2b-256 1be2b704029170682c973c5fb5a51e3a89e74228990a78fcef23573c41b80e21

See more details on using hashes here.

File details

Details for the file dataprem_mcp-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: dataprem_mcp-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dataprem_mcp-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b6b1bb44fc001330ee193111b580e20f6a308e65395a15b11bec7932b23ebbb7
MD5 084e28e5ee325718b7812ad5f8a96779
BLAKE2b-256 6c60100b37961f9f4a81200de38ce0b0cb778d8ba23f791b09b13cc56751a1be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page