get_line_status
Check real-time Transport for London line status to get current service information and disruption details for specific tube lines.
Instructions
Get the status of a TfL line from the Transport for London Unified API.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app_key | No | Optional application key for the API. | |
| lineId | Yes | The identifier of the line to query (e.g., victoria, central). |
Implementation Reference
- tools/tfl/status.js:9-39 (handler)Handler function that executes the get_line_status tool, fetching the current status of a specified TfL line from the API.const executeFunction = async ({ lineId, app_key }) => { if (!lineId) { throw new Error('lineId is required'); } const params = new URLSearchParams(); if (app_key) { params.append('app_key', app_key); } const query = params.toString(); const url = `https://api.tfl.gov.uk/Line/${encodeURIComponent(lineId)}/Status${query ? `?${query}` : ''}`; try { const response = await fetch(url, { method: 'GET' }); if (!response.ok) { const errorData = await response.json(); throw new Error(JSON.stringify(errorData)); } return await response.json(); } catch (error) { console.error('Error fetching the status:', error); return { error: `An error occurred while fetching the status: ${error instanceof Error ? error.message : JSON.stringify(error)}` }; } };
- tools/tfl/status.js:52-66 (schema)Input schema defining parameters for the get_line_status tool: lineId (required), app_key (optional).parameters: { type: 'object', properties: { lineId: { type: 'string', description: 'The identifier of the line to query (e.g., victoria, central).' }, app_key: { type: 'string', description: 'Optional application key for the API.' } }, required: ['lineId'] } }
- tools/paths.js:1-5 (registration)Registration of tool modules via toolPaths array; 'tfl/status.js' provides the get_line_status tool.export const toolPaths = [ 'tfl/status.js', 'tfl/status-detail.js', 'tfl/journey-planner.js' ];
- lib/tools.js:7-30 (registration)Dynamic registration: discoverTools loads apiTool from each path in toolPaths, including the get_line_status tool.export async function discoverTools() { const tools = await Promise.all( toolPaths.map(async (file) => { const { apiTool } = await import(`../tools/${file}`); return { ...apiTool, path: file }; }) ); // deduplicate tool names const nameCounts = {}; return tools.map((tool) => { const name = tool.definition?.function?.name; if (!name) return tool; nameCounts[name] = (nameCounts[name] || 0) + 1; if (nameCounts[name] > 1) { tool.definition.function.name = `${name}_${nameCounts[name]}`; } return tool; }); }