station_crowding
Monitor real-time crowdedness levels across Singapore's MRT and LRT stations by train line, updated every 10 minutes to ensure informed commuting decisions.
Instructions
Get real-time MRT/LRT station crowdedness level for a particular train network line. Updates every 10 minutes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| trainLine | Yes | Code of train network line (CCL, CEL, CGL, DTL, EWL, NEL, NSL, BPL, SLRT, PLRT, TEL) |
Implementation Reference
- src/index.ts:173-207 (handler)Handler function for 'station_crowding' tool. Extracts 'trainLine' from arguments, makes API call to LTA DataMall PCDRealTime endpoint, returns JSON response or error.case "station_crowding": { const { trainLine } = request.params.arguments as { trainLine: string; }; try { const response = await axios.get('https://datamall2.mytransport.sg/ltaodataservice/PCDRealTime', { params: { TrainLine: trainLine }, headers: { 'AccountKey': process.env.LTA_API_KEY!, 'accept': 'application/json' } }); return { content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }] }; } catch (error) { if (axios.isAxiosError(error)) { return { content: [{ type: "text", text: `LTA API error: ${error.response?.data?.Message ?? error.message}` }], isError: true }; } throw error; } }
- src/index.ts:70-80 (schema)Input schema for 'station_crowding' tool, defining 'trainLine' as required string with enum of train lines.inputSchema: { type: "object", properties: { trainLine: { type: "string", description: "Code of train network line (CCL, CEL, CGL, DTL, EWL, NEL, NSL, BPL, SLRT, PLRT, TEL)", enum: ["CCL", "CEL", "CGL", "DTL", "EWL", "NEL", "NSL", "BPL", "SLRT", "PLRT", "TEL"] } }, required: ["trainLine"] }
- src/index.ts:67-81 (registration)Registration of 'station_crowding' tool in the ListTools response, including name, description, and input schema.{ name: "station_crowding", description: "Get real-time MRT/LRT station crowdedness level for a particular train network line. Updates every 10 minutes.", inputSchema: { type: "object", properties: { trainLine: { type: "string", description: "Code of train network line (CCL, CEL, CGL, DTL, EWL, NEL, NSL, BPL, SLRT, PLRT, TEL)", enum: ["CCL", "CEL", "CGL", "DTL", "EWL", "NEL", "NSL", "BPL", "SLRT", "PLRT", "TEL"] } }, required: ["trainLine"] } },