公共交通数据服务器

为n8n的MCP客户端工具设计的Docker化公共交通数据服务器,提供SSE端点和消息处理功能。

  • by Paneed
  • JavaScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 Paneed/ratp_mcp

使用说明

ratp-mcp

MCP server (Navitia / Ile-de-France Mobilites) designed to run in Docker and be consumed by n8n's MCP Client Tool.

What n8n expects

n8n's MCP Client Tool asks for an SSE endpoint. This server exposes:

  • GET /sse (SSE endpoint)
  • POST /messages?sessionId=... (message endpoint)

It also exposes an optional Streamable HTTP endpoint:

  • /mcp (GET/POST/DELETE)

Environment

Required:

  • NAVITIA_TOKEN

Optional:

  • NAVITIA_BASE_URL (default: IDFM Navitia marketplace)
  • NAVITIA_AUTH_HEADER (default: apikey)
  • NAVITIA_PREFIX (default: empty)

MCP server:

  • MCP_HOST (default: 0.0.0.0)
  • MCP_PORT (default: 3000)
  • MCP_AUTH_TOKEN (if set: requires Authorization: Bearer <token>)
  • MCP_ALLOWED_HOSTS (comma-separated; enables Host header validation)

Tools

  • navitia-get: low-level GET request helper
  • navitia-journeys: wrapper around GET /journeys
  • navitia-places: wrapper around GET /places

Run locally

cd ratp-mcp
cp .env.example .env
export NAVITIA_TOKEN=...
npm start

Docker

Build:

docker build -t ratp-mcp:local .

Run (example):

docker run --rm -p 3000:3000 \
  -e NAVITIA_TOKEN=... \
  ratp-mcp:local

Or with compose:

export NAVITIA_TOKEN=...
docker compose -f docker-compose.example.yml up -d --build

n8n configuration

In n8n, add an MCP Client Tool node:

  • SSE Endpoint: http://ratp-mcp:3000/sse
  • Authentication: None (or Bearer if you set MCP_AUTH_TOKEN)

If n8n runs in a different compose project, put both containers on the same Docker network (example n8n):

docker network create n8n || true
docker network connect n8n <your-n8n-container>
docker network connect n8n <your-ratp-mcp-container>

If you run n8n behind a reverse proxy (nginx/traefik), make sure SSE buffering is disabled for this endpoint.

Example nginx location:

location /sse {
    proxy_http_version 1.1;
    proxy_buffering off;
    gzip off;
    chunked_transfer_encoding off;
    proxy_set_header Connection '';
}