Skip to main content
Glama

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).

Related MCP server: gtfs-pro-mcp

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.

Available Tools

3 tools
geocodeGeocode a Helsinki placeA

Look up coordinates for an address, place, or landmark in the Greater Helsinki area. Returns up to 10 candidates with Finnish and Swedish names, coordinates, and a confidence score. Use this before plan_journey when you only have a place name.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of results to return (1-10).
queryYesAddress, place name, or landmark in the Greater Helsinki area (Finnish, Swedish, or English).

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the burden of disclosing behavior. It does well by describing the output: 'Returns up to 10 candidates with Finnish and Swedish names, coordinates, and a confidence score.' However, it doesn't mention error cases or ambiguous query behavior, leaving a minor transparency gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences front-load the purpose, then state the output, then give usage guidance. Every word earns its place with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple 2-parameter geocoding tool, the description covers purpose, output format, and usage context relative to siblings. The absence of an output schema is mitigated by the explicit summary of returned fields.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% for both parameters, so the description leverages the schema's descriptions. It reinforces that query accepts 'address, place, or landmark' but adds no new parameter-level meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: 'Look up coordinates for an address, place, or landmark in the Greater Helsinki area.' This specific verb+resource combination distinguishes it from sibling tools like plan_journey and stop_departures.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit guidance is given: 'Use this before plan_journey when you only have a place name.' This names the alternative tool and provides a clear when-to-use directive, which is exactly what agents need.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

plan_journeyPlan a Helsinki transit journeyA

Plan a public-transport journey between two places in Greater Helsinki. Accepts place names or addresses; both endpoints are geocoded internally. Returns up to 5 itineraries, each with legs, modes, line numbers, and real-time status. Departure time defaults to now; provide an ISO 8601 timestamp with offset to plan ahead.

ParametersJSON Schema
NameRequiredDescriptionDefault
modesNoOptional filter of allowed transit modes (BUS, TRAM, RAIL, SUBWAY, FERRY). Omit to allow any.
originYesOrigin: place name, address, or landmark in Greater Helsinki (e.g. 'Kamppi', 'Otaniemi'). Geocoded internally.
destinationYesDestination: place name, address, or landmark. Geocoded internally.
departureTimeNoISO 8601 timestamp WITH offset, e.g. '2026-08-07T15:00:00+03:00' or '...Z'. Defaults to now.
numItinerariesNoHow many itineraries to return.

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses internal geocoding, return structure (up to 5 itineraries with legs, modes, line numbers, real-time status), default departure time of 'now,' and the requirement for ISO 8601 timestamps with offset. This is strong behavioral disclosure for a read-only planner, though it does not mention error handling or reversibility.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three sentences: first states the purpose, second covers inputs and outputs, third addresses departure time. It is front-loaded with the main action and contains no filler or redundant wording.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has moderate complexity (5 parameters, no output schema). The description sufficiently explains input types, geocoding behavior, return format (itineraries with legs, modes, line numbers, real-time status), and time defaults. Given the absence of an output schema, this is a complete and self-contained description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds some context—internal geocoding, default departure time, and output details—but these are largely redundant with the schema's per-property descriptions. It does not significantly enhance parameter understanding beyond what the schema already provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource: 'Plan a public-transport journey between two places in Greater Helsinki.' It clearly distinguishes the tool from siblings by focusing on journey planning, while mentioning internal geocoding for endpoints. This is a clear, non-tautological purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context: use for public-transport journeys in Greater Helsinki, accepts place names/addresses, returns itineraries. It does not explicitly mention when not to use it or alternatives like geocode or stop_departures, but the purpose is well-scoped enough to avoid confusion with the siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

stop_departuresNext departures from a stopA

Get the next departures from a Helsinki public-transport stop, including real-time delays. Accepts either a stop name (e.g. 'Kamppi', looked up internally) or an HSL stop ID (e.g. 'HSL:1140447'). If the name matches multiple stops, returns the candidate list so the caller can pick one.

ParametersJSON Schema
NameRequiredDescriptionDefault
stopIdNoHSL GTFS stop ID, e.g. "HSL:1140447". Provide this OR stopName.
stopNameNoHuman-readable stop name, e.g. "Kamppi". Provide this OR stopId.
numberOfDeparturesNoHow many upcoming departures to return.

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the burden of disclosing behavior. It does so by mentioning real-time delays, internal stop-name lookup, and the candidate-list response when multiple stops match. This goes beyond the schema's parameter definitions, though it does not cover all edge cases (e.g., invalid inputs, no departures found).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three concise sentences, each adding value: purpose, input options, and ambiguity handling. No fluff or repetition of schema info. The description is front-loaded with the primary function and scales well.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of an output schema, the description does not specify the structure of returned departures (e.g., fields like line, time, delay), which is a notable gap. It also omits error-handling behavior. The core purpose is clear, but the lack of return-format details makes it only moderately complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds context about the OR relationship between stopId and stopName and the disambiguation behavior, but it does not add meaningfully to the numberOfDepartures parameter beyond what the schema already states. Thus, it slightly enhances but does not fully compensate beyond the baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Get') and resource ('next departures from a Helsinki public-transport stop'), clearly distinguishing it from sibling tools like geocode or plan_journey. The scope is precise (Helsinki transit, real-time delays), leaving no ambiguity about what the tool does.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use this tool (to obtain departures from a stop) and explains the two accepted input modes, including a note about ambiguity resolution. However, it does not explicitly state when not to use it or mention alternatives (e.g., use plan_journey for route planning), so it falls short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A4.1/5.0
Disambiguation5/5

Each tool targets a clearly distinct aspect of transit: geocode for place lookup, stop_departures for real-time departures, and plan_journey for routing. The descriptions reinforce these boundaries, making misselection unlikely.

Naming Consistency3/5

The naming style is lowercase with underscores, but the grammatical patterns vary: 'geocode' is a single verb, 'plan_journey' is verb_noun, and 'stop_departures' is a noun phrase. This mix is readable but not as consistent as a strict verb_noun convention.

Tool Count4/5

Three tools is at the lower end of the typical well-scoped range, but each tool serves a core transit use case. The set feels slightly sparse for a full public-transport domain, but it is not overly thin or bloated.

Completeness4/5

The tool surface covers the primary journey-planning workflow: geocoding, departures, and route planning. Minor gaps exist such as no tool for disruptions, fares, or stop metadata, but agents can accomplish the main tasks without dead ends.

Maintenance

ActivityMaintained
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/devusvulgaris/mcp-hsl'

If you have feedback or need assistance with the MCP directory API, please join our Discord server