Token导航 LogoToken导航TokenDH.com
Spanish Public Info Radar MCP logo
数据服务stdio官方来源来源级核验

Spanish Public Info Radar MCP

MCP Server

西班牙公共数据MCP服务器提供查询西班牙政府开放数据的LLM友好工具,包括国家资助数据库、官方公报、公司注册公报、国家统计局数据和开放数据目录等。

工具数

26

提示词数

0

GitHub Stars

3

资源数

0
开放数据PythonClaude数据分析Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

mjgmario

提供方

mjgmario

最后核验

2026/5/17 20:20

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uv run python -m public_radar

详细介绍

西班牙公共数据MCP

![CI](https://github.com/mjgmario/spanish-public-info-radar-mcp/actions/workflows/ci.yml) ![Integration Tests](https://github.com/mjgmario/spanish-public-info-radar-mcp/actions/workflows/integration.yml) ![Coverage](https://github.com/mjgmario/spanish-public-info-radar-mcp) ![Python 3.11+](https://www.python.org/downloads/)

用于查询西班牙政府开放数据API的MCP服务器。

概述

西班牙公共数据MCP提供LLM友好的工具,用于实时查询西班牙政府数据:

  • BDNS -国家赠款数据库(赠款和补贴)
  • 京东方 -官方公报(综合立法)
  • BORME -公司注册公报(公司法)
  • INE -国家统计局(官方统计)
  • 数据.gob.es -国家开放数据目录(40000多个数据集)

架构: 实时查询官方API。不需要数据库。

总计: 26个MCP工具|211个测试|53%+覆盖率

安装

# Clone repository
git clone https://github.com/mjgmario/spanish-public-info-radar-mcp.git
cd spanish-public-data-mcp

# Install with uv (recommended)
uv sync

# For development
uv sync --extra dev

快速开始

选项1:直接运行(开发/测试)

# Install dependencies
uv sync

# Run MCP server (HTTP/SSE mode)
uv run python -m public_radar

# Or on a specific port
uv run python -m public_radar --port 9000

# Or in stdio mode (for Claude Desktop)
uv run python -m public_radar --stdio

选项2:使用Docker

# Build and run
docker-compose up -d

# View logs
docker-compose logs -f

# Stop
docker-compose down

验证它是否正常工作

# Health check (HTTP mode)
curl http://localhost:8080/health

# Should return: {"status":"healthy","service":"spanish-public-data-mcp"}

Claude桌面集成

步骤1:找到您的配置文件

Claude Desktop配置文件位于:

  • 窗户: %APPDATA%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

步骤2:添加MCP服务器配置

打开配置文件并添加以下内容:

{
  "mcpServers": {
    "spanish-public-data": {
      "command": "uv",
      "args": ["run", "python", "-m", "public_radar", "--stdio"],
      "cwd": "C:\\Users\\YOUR_USER\\path\\to\\spanish-public-data-mcp"
    }
  }
}

注: 替换 YOUR_USER 以及您实际安装路径的路径。

步骤3:重新启动克劳德桌面

关闭并重新打开Claude Desktop以加载新的MCP服务器。

步骤4:验证连接

问克劳德:“你有什么西班牙公共数据工具?”

Claude应该提供有关26个可用工具的信息。

______________________________________________________________________

可用的MCP工具

BDNS(赠款)-3个工具

工具说明
search_grants按日期范围和授权机构搜索授权呼叫
search_grant_awards按日期范围和受益人NIF搜索已授予的补助金
get_grant_details获取特定授权电话的详细信息

英国央行(立法)-11种工具

工具说明
search_legislation使用过滤器搜索合并法律(查询、日期、部门、法律范围、事项)
get_legislation_details获取特定法律或法规的元数据(可选配法律分析)
get_legislation_text获取法律的完整合并文本
get_legislation_structure获取法律的结构/索引(条款、处置、附件)
get_legislation_block从法律中获得特定的块(文章、处置)
get_departments_table获取带有代码的政府部门列表
get_legal_ranges_table获取法律规范类型列表(Ley、Real Decreto等)
get_matters_table获取带有代码的主题列表
find_related_laws查找与特定立法相关的法律(修改、废除、参考)
search_recent_boe使用筛选器搜索过去N天的京东方出版物
get_boe_summary获取特定日期的每日BOE摘要(带过滤器)

BORME(公司注册处)-1个工具

工具说明
get_borme_summary获取特定日期的每日公司注册行为

INE(统计)-6个工具

工具说明
get_ine_operations列出所有可用的统计操作(IPC、EPA、PIB等)
get_ine_operation获取特定统计操作的详细信息
get_ine_table_data从特定统计表中获取数据
get_ine_series_data按序列码获取时间序列数据
search_ine_tables在统计操作中搜索表
get_ine_variables列出可用变量,可选择按操作筛选

datos.gob.es(开放数据)-4个工具

工具说明
search_open_data在国家开放数据目录中搜索数据集
get_open_data_details获取特定数据集的详细信息
list_open_data_themes列出可用主题/类别
list_open_data_publishers列出出版机构

通用-1工具

工具说明
get_system_info获取可用数据源和工具的概述

______________________________________________________________________

Claude的查询示例

以下是MCP连接后您可以向Claude询问的实际示例:

赠款和补贴(BDNS)

"Find grants published in the last month"

"Search for grants related to innovation or R&D"

"What grants has the company with NIF B12345678 received?"

"Show me details of grant BDNS 123456"

立法(英国央行)

"Search for laws about renewable energy"

"What was published in the BOE today?"

"Find legislation about public subsidies from 2023"

"Show me the full text of the data protection law"

公司注册处(BORME)

"What companies were registered in Madrid today?"

"Show me the BORME summary for January 15, 2024"

"Find recent company dissolutions"

统计(INE)

"What statistical operations are available from INE?"

"Show me the latest CPI (IPC) data"

"Get unemployment statistics from the EPA survey"

"What is the current inflation rate in Spain?"

"Show me GDP growth data for the last 12 quarters"

"Find tables about population in the Census operation"

综合研究

"I want to investigate company XYZ. Check:
1. What grants have they received?
2. Any recent BORME entries about them?"

"Find all funding opportunities for renewable energy projects:
1. Current open grants
2. Relevant legislation"

"Give me an economic overview of Spain:
1. Latest unemployment rate (EPA)
2. Current inflation (IPC)
3. Recent GDP growth"

开放数据(datos.gob.es)

"Search for datasets about air quality"

"Find open data from the Madrid city council"

"What data categories are available in datos.gob.es?"

"Show me details of dataset e05068001-mapas-estrategicos-de-ruido"

______________________________________________________________________

刀具参数参考

搜索_咆哮

{
  "date_from": "2024-01-01",    // Optional: Start date (YYYY-MM-DD)
  "date_to": "2024-12-31",      // Optional: End date (YYYY-MM-DD)
  "granting_body": "E00003901", // Optional: Granting body code
  "limit": 20                   // Optional: Max results (1-100, default 20)
}

search_grant_awards

{
  "date_from": "2024-01-01",      // Optional: Start date
  "date_to": "2024-12-31",        // Optional: End date
  "beneficiary_nif": "B12345678", // Optional: Beneficiary NIF/CIF
  "limit": 20                     // Optional: Max results
}

get_grant_details

{
  "grant_id": "123456"  // Required: BDNS grant ID
}

搜索_立法

{
  "query": "energias renovables",  // Required: Search text
  "date_from": "2020-01-01",       // Optional: Start date
  "date_to": "2024-12-31",         // Optional: End date
  "title": "ley energia",          // Optional: Filter by title
  "department_code": "4225",       // Optional: Department code (use get_departments_table)
  "legal_range_code": "ley",       // Optional: Legal range (use get_legal_ranges_table)
  "matter_code": "170",            // Optional: Matter code (use get_matters_table)
  "include_derogated": false,      // Optional: Include repealed laws (default false)
  "offset": 0,                     // Optional: Skip results (pagination)
  "limit": 20                      // Optional: Max results (1-100)
}

get_legislation_details

{
  "legislation_id": "BOE-A-2015-10566"  // Required: BOE legislation ID
}

get_legislation_text

{
  "legislation_id": "BOE-A-2015-10566"  // Required: BOE legislation ID
}

get_legislation_structure

{
  "legislation_id": "BOE-A-2015-10566"  // Required: BOE legislation ID
}

get_legislation_block

{
  "legislation_id": "BOE-A-2015-10566", // Required: BOE legislation ID
  "block_id": "a1"                       // Required: Block ID (e.g., "a1" for article 1)
}

get_departments_table

{}  // No parameters required

get_legal_ranges_table

{}  // No parameters required

get_matters_table

{}  // No parameters required

get_boe_summary

{
  "date": "2024-01-15"  // Optional: Date (YYYY-MM-DD), defaults to today
}

get_forme_summary

{
  "date": "2024-01-15"  // Optional: Date (YYYY-MM-DD), defaults to today
}

get_ine_operations

{}  // No parameters required

get_ine_operation

{
  "operation_id": "IPC"  // Required: Operation ID or code (e.g., 'IPC', 'EPA', '25')
}

get_ine_table_data

{
  "table_id": "50902",  // Required: Table ID from INE
  "nult": 12            // Optional: Number of last periods (1-100, default 12)
}

获取_系列_数据

{
  "series_code": "IPC251856", // Required: Series code from INE
  "nult": 12                   // Optional: Number of last periods (1-100, default 12)
}

search_ine_tables

{
  "operation_id": "IPC"  // Required: Operation ID to search tables for
}

get_ine_variables

{
  "operation_id": "IPC"  // Optional: Filter variables by operation
}

搜索打开数据

{
  "query": "air quality",           // Optional: Search text
  "theme": "medio-ambiente",        // Optional: Theme code
  "publisher": "L01280796",         // Optional: Publisher ID
  "limit": 20                       // Optional: Max results (1-100)
}

get_open_data_details

{
  "dataset_id": "e05068001-mapas-estrategicos-de-ruido"  // Required: Dataset ID
}

list_open_data_themes

{}  // No parameters required

list_open_data_出版商

{
  "limit": 50  // Optional: Max results (default 50)
}

______________________________________________________________________

项目结构

src/public_radar/
├── common/          # HTTP client, dates, logging
├── sources/         # API clients (BDNS, BOE, INE, datos.gob.es)
│   ├── bdns.py      # BDNS client (grants)
│   ├── boe.py       # BOE client (legislation, BORME)
│   ├── ine.py       # INE client (statistics)
│   └── datos_gob.py # datos.gob.es client (open data)
├── mcp/             # MCP server and tools
│   ├── server.py    # MCP server + 26 tool handlers
│   └── logging.py   # Tool call logging (JSONL)
├── __init__.py
└── __main__.py      # CLI entry point

tests/
├── unit/            # Unit tests with mocks (168 tests)
├── integration/     # Real API tests (43 tests)
└── fixtures/        # Sample API responses

配置

环境变量

变量描述默认值
MCP_HOST主机绑定SSE服务器0.0.0.0
MCP_PORTSSE服务器端口8080
MCP_LOGS_DIR工具调用日志目录./logs
LOG_LEVEL日志记录级别INFO

工具调用记录

所有MCP工具调用都记录到 logs/mcp_calls_YYYY-MM-DD.jsonl:

{
  "timestamp": "2024-01-15T10:30:00Z",
  "tool": "search_grants",
  "input": {"date_from": "2024-01-01", "limit": 10},
  "output_summary": {"count": 10, "first_title": "..."},
  "duration_ms": 450,
  "success": true,
  "error": null
}

日志会自动轮换(7天后删除)。

Docker部署

# Start MCP server
docker-compose up -d

# Check health
curl http://localhost:8080/health

# View logs
docker-compose logs -f mcp

# Stop server
docker-compose down

发展

# Install dev dependencies
uv sync --extra dev

# Run tests
uv run pytest

# Run with coverage
uv run pytest --cov

# Run linting
uv run pre-commit run --all-files

# Type checking
uv run mypy src/

当前测试覆盖率

  • 211测试通过 (168台+43台集成)
  • 53%以上的代码覆盖率 (仅限单元测试)
  • 所有解析器和工具处理程序的单元测试
  • 实际API调用的集成测试(BDNS、BOE、INE、datos.gob.es)

数据源

来源API说明
BDNS昂首阔步国家资助数据库
BOE开放数据官方公报和立法
API手册国家统计研究所
数据.gob.esAPI数据国家开放数据目录

故障排除

Claude Desktop看不到MCP

  1. 检查配置文件路径是否正确
  2. 确保 uv 在你的路径中
  3. 验证 cwd 路径指向项目目录
  4. 完全重新启动克劳德桌面

API返回空结果

  • BOE/BORME不在周末或节假日发布
  • BDNS可能有速率限制
  • INE数据定期更新(每月、每季度)

工具调用错误

查看日志 logs/mcp_calls_YYYY-MM-DD.jsonl 获取详细的错误信息。

许可证

麻省理工学院

目录标签

目录标签

开放数据PythonClaude数据分析政府数据本地部署数据查询LLM工具API集成

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

26

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP