mcp-hsl

mcp-hsl

An MCP server exposing Greater Helsinki public transport data from Digitransit, enabling LLM hosts to answer live transit queries, plan journeys, and fetch stop departures via natural language.

Category
访问服务器

README

mcp-hsl

npm version Node.js License: MIT

MCP server exposing Greater Helsinki (HSL) public-transport data from Digitransit. Covers Helsinki, Espoo, Vantaa, Kauniainen, Kerava, Kirkkonummi, Sipoo, Siuntio, and Tuusula.

Lets an LLM host (Claude Desktop, Claude Code, Cursor, etc.) answer live-transit questions like "next tram from Kamppi to Töölö" or "plan a trip from Otaniemi to Kallio at 5pm".

Prerequisites

  • Node.js 20.6 or newer (uses native --env-file).
  • A free Digitransit subscription key (see below).

Getting a Digitransit API key

Digitransit publishes HSL data through an Azure API Management portal. The key is free and easy to obtain.

  1. Go to https://portal-api.digitransit.fi/ and click Sign up (top rig ht).
  2. Verify your email and sign in.
  3. Open Products → pick Digitransit API (the free tier).
  4. Click Subscribe, give the subscription a name (e.g. mcp-hsl), and confirm.
  5. Under Profile → Subscriptions, reveal the Primary key. That's you r DIGITRANSIT_SUBSCRIPTION_KEY.

The free tier has generous rate limits (see https://digitransit.fi/en/developers/api-registration/ for current numbers). Keep the key private — treat it like a password.

Install

mcp-hsl is a standard stdio MCP server, so any MCP-compatible host can use it — Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, Zed, and so on.

Option A — CLI (fastest, if your host has one)

# Claude Code
claude mcp add hsl-transit -e DIGITRANSIT_SUBSCRIPTION_KEY=your-key -- npx -y mcp-hsl

Other hosts (Cursor, VS Code) offer GUI-driven "Add MCP server" flows in their command palettes — same fields as the JSON below.

Option B — Config file

Add this entry to your host's MCP config:

{
  "mcpServers": {
    "hsl-transit": {
      "command": "npx",
      "args": ["-y", "mcp-hsl"],
      "env": {
        "DIGITRANSIT_SUBSCRIPTION_KEY": "your-key-here"
      }
    }
  }
}

Where to put it:

Host Config path Wrapper key
Claude Desktop (macOS) ~/Library/Application Support/Claude/claude_desktop_config.json mcpServers
Claude Desktop (Windows) %APPDATA%\Claude\claude_desktop_config.json mcpServers
Claude Code ~/.claude.json (or use claude mcp add) mcpServers
Cursor ~/.cursor/mcp.json (global) or .cursor/mcp.json (project) mcpServers
VS Code (Copilot) .vscode/mcp.json (project) or user settings servers

VS Code uses "servers" instead of "mcpServers" — otherwise the entry is identical.

Restart the host after editing the config. The server should appear as Connected / Ready.

Local development

git clone <this-repo>
cd mcp-hsl
npm install
cp .env.example .env      # then fill in DIGITRANSIT_SUBSCRIPTION_KEY
npm run build

Run against your own build:

{
  "mcpServers": {
    "hsl-transit": {
      "command": "node",
      "args": [
        "--env-file=/absolute/path/to/mcp-hsl/.env",
        "/absolute/path/to/mcp-hsl/build/stdio.js"
      ]
    }
  }
}

The server exits immediately with a clear message if DIGITRANSIT_SUBSCRIPTION_KEY is missing.

Tools

Name Purpose Key inputs
geocode Place / address → coordinates query, limit
plan_journey Route between two places origin, destination, optional modes, departureTime
stop_departures Next departures from a stop stopId OR stopName, numberOfDepartures

All three call Digitransit's HSL routing API. plan_journey geocodes both endpoints internally; stop_departures looks up a stop by name if you don't have the HSL ID.

plan_journey modes

Filter transit modes with the modes array: BUS, TRAM, RAIL, SUBWAY, FERRY. Omit to allow any. departureTime is an ISO 8601 timestamp with offset (e.g. 2026-08-13T17:00:00+03:00); defaults to now.

stop_departures name lookup

HSL stop IDs look like HSL:1140447. If you pass stopName and it matches multiple stops (e.g. Kamppi has several platform IDs), the tool returns the candidate list — the LLM then re-calls with the specific stopId.

Example prompts

  • "Geocode 'Kamppi metro station' in Helsinki."
  • "When are the next departures from Kamppi?"
  • "Plan a tram journey from Kamppi to Töölö."
  • "Get me from Otaniemi to Kallio around 5pm today, no bus."
  • "Kamppista Töölöön seuraava ratikka?"

Design notes

  • Transport-agnostic core. src/server.ts exposes a buildServer() factory that registers tools without touching any transport. To add HTTP later, add a new entry point that calls buildServer() and wires it to StreamableHTTPServerTransport.
  • Output for LLMs. Tool results are compact plain-text tables/blocks — enough for the model to reason over without wasting tokens on raw GraphQL responses.
  • Multilingual. Digitransit returns Finnish and Swedish names side by side; the LLM handles user-facing language.
  • Real-time. Journey legs and departures include real-time state (SCHEDULED, UPDATED, CANCELED) so the model can distinguish "on time" from "delayed 3 min".

Attribution

Data © Helsinki Region Transport (HSL) and other producers, provided by Digitransit under Creative Commons BY 4.0. This project is not affiliated with HSL or Digitransit.

License

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选