asset

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

krl-mcp

CI Go Reference

A fully self-contained Model Context Protocol server for Jakarta's KRL Commuter train schedules — written in Go, running entirely from pinned data artifacts in memory. No database, no cache, no network: clone it, hand it to your MCP host, and ask it about trains.

Part of a larger system: this is the MCP face of krl-schedule-service (production service with a REST API, Postgres, Redis, and a trip planner), rebuilt here as a zero-infrastructure demo that anyone can run in 60 seconds.

Install

Option A — one line with Go (1.25+):

go install github.com/athallarizky/krl-mcp/cmd/krl-mcp@latest
claude mcp add krl --scope user -- "$(go env GOPATH)/bin/krl-mcp"

Option B — download a prebuilt binary (no Go needed): grab your platform from Releases, chmod +x it, then:

claude mcp add krl --scope user -- /path/to/krl-mcp

Other MCP hosts (Claude Desktop, Cursor, ...) — same idea, JSON config:

{ "mcpServers": { "krl": { "command": "/path/to/krl-mcp" } } }

Build from source:

git clone https://github.com/athallarizky/krl-mcp && cd krl-mcp
go build -o krl-mcp ./cmd/krl-mcp   # Go 1.25+

Then ask Claude Code:

Then ask Claude Code:

"I'm at Monas (-6.1754, 106.8272), which KRL station is closest?" "I'm at Tanah Abang and must reach Kebayoran before 6 AM — which train?" "How does train 5133D get from Kranji to Duri?"

No Docker. No Postgres. No API keys. The open-krl snapshot is embedded in the binary (go:embed) — one self-contained executable that runs from anywhere, spawned from any working directory.

Tools

Tool What it answers
get_stations The 111-station catalog (Jabodetabek + Yogyakarta–Solo) with coordinates
get_departures One station's departure board in a time window
get_lines The commercial lines with canonical colors
plan_trip Direct-trip planner: depart_at (earliest first) or arrive_by (latest-that-still-makes-it first), with intermediate stops
find_nearest_station GPS coordinate → closest stations with distances
get_trip_stops One train's full ordered stop sequence — the auditable route narrative

Design details worth stealing:

  • Honest empty answers. When no direct trip exists, plan_trip returns meta.transfer_candidates — the stops where a one-transfer route is possible (empty means none exists). An LLM caller can reason about transfers from data instead of inventing routes.
  • Station names just work. "Tanah Tinggi", "tanah tinggi", "TANAHTINGGI", and "THI" all resolve (4-tier resolution: exact code → exact name → normalized → substring).
  • The service-day clock. 24:04 means 00:04 after midnight of the same service day — how GTFS keeps late-night trains sortable. The planner accepts hours up to 47.
  • Headsigns are not routes. Train 5133D says "ANGKE" but runs the southern ring via Manggarai — get_trip_stops exists because an LLM once confidently narrated the wrong direction from the headsign alone.

Architecture

boards/*.json ──────┐
stations.json ──────┤  parse once  ┌──────────────────────────────┐
GTFS stop_times ────┼─────────────▶│  in-memory store (~5 MB RAM) │
GTFS trips ─────────┘              └──────────────┬───────────────┘
                                                  │ stdio (JSON-RPC 2.0)
                                                  ▼
                                        your MCP host (Claude Code, ...)

The snapshot is baked into the binary at build time (go:embed) — one ~15 MB static executable, no working-directory assumptions, no data files to lose. What the production service runs as SQL against Postgres becomes plain scans here: the planner's trip self-join is a prebuilt stop → (trip, seq) index; line colors are reduced in-memory; station resolution is three maps plus a fallback scan. Same logic, same output shapes — zero moving parts.

The story: my LLM found my bugs

I built this as my first MCP server — and the most valuable testing turned out to be letting Claude use it. Across dogfooding sessions, the LLM surfaced bugs that an integration suite never caught:

  1. A relative data path that resolved against the host's working directory — the tool silently served empty boards.
  2. A name resolution gap: the tool description promised "or case-insensitive name" but the code only uppercased — the LLM compared two queries and caught the lie.
  3. A route narration hallucination: with no intermediate-stop data exposed, the model invented a plausible-but-wrong route from the train's headsign. The fix — exposing via and get_trip_stops — is why this repo can answer "which way does this train actually go" from data.

Each fix became a test with real, verified numbers (train 1903A departs Tangerang 04:27:00, arrives Duri 04:53:00 — every golden assertion in this repo was checked against the artifacts before it was written).

Data

  • Schedule & station data: open-krl/pipeline raw snapshot + GTFS release — © open-krl contributors, CC-BY 4.0. Pinned in data/ with a manifest (capture date, source hashes).
  • Yogyakarta–Solo coordinates: extracted from OpenStreetMap (ODbL).

Caveat: the feed merges weekday/weekend day types — a listed train may not run every day. Verify critical trips.

  • krl-schedule-service — the production system behind this demo: REST /v1 API with Swagger, lazy syncing, cache-aside + singleflight, curated door-side data, and an HTTP+MCP dual face over one service layer.

License

Code: MIT. Bundled data: see NOTICE (CC-BY 4.0 / ODbL — attribution required).

Documentation

Overview

Package asset embeds the pinned open-krl data snapshot into the binary. krl-mcp ships as a single static file: no data directory, no working- directory assumptions — the exact failure mode (cwd-relative data path serving empty boards) an LLM found in the production service's early days. Embedding kills that bug class for good.

Index

Constants

This section is empty.

Variables

FS holds everything under data/ (snapshot, GTFS release, OSM coords).

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
krl-mcp command
Command krl-mcp runs a fully self-contained KRL Commuter schedule MCP server over stdio: the pinned open-krl snapshot is EMBEDDED in the binary and parsed into memory at startup — no database, no cache, no network, no working-directory assumptions.
Command krl-mcp runs a fully self-contained KRL Commuter schedule MCP server over stdio: the pinned open-krl snapshot is EMBEDDED in the binary and parsed into memory at startup — no database, no cache, no network, no working-directory assumptions.
internal
server
Package server wires the six schedule tools onto an MCP server.
Package server wires the six schedule tools onto an MCP server.
store
Domain queries over the in-memory snapshot — ports of the production service logic (krl-schedule-service/internal/service), with the SQL replaced by plain scans.
Domain queries over the in-memory snapshot — ports of the production service logic (krl-schedule-service/internal/service), with the SQL replaced by plain scans.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL