get_line_status_detail
Check real-time Transport for London line status and disruption details to plan your journey effectively.
Instructions
Get the status and details of a TfL line.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app_key | No | Optional application key for authentication. | |
| lineId | Yes | The identifier of the line to query (e.g., victoria, central). |
Implementation Reference
- tools/tfl/status-detail.js:9-41 (handler)The main handler function that fetches detailed TfL line status and disruption information from the API.const executeFunction = async ({ lineId, app_key }) => { if (!lineId) { throw new Error('lineId is required'); } const params = new URLSearchParams([['detail', 'true']]); if (app_key) { params.append('app_key', app_key); } const url = `https://api.tfl.gov.uk/Line/${encodeURIComponent(lineId)}/Status?${params.toString()}`; try { const response = await fetch(url, { method: 'GET', headers: { 'Content-Type': 'application/json' } }); if (!response.ok) { const errorData = await response.json(); throw new Error(JSON.stringify(errorData)); } return await response.json(); } catch (error) { console.error('Error fetching status and details:', error); return { error: `An error occurred while fetching status and details: ${error instanceof Error ? error.message : JSON.stringify(error)}` }; } };
- tools/tfl/status-detail.js:47-70 (schema)Tool definition including name, description, input schema, and reference to the handler function.const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'get_line_status_detail', description: 'Get the status and details of a TfL line.', 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 authentication.' } }, required: ['lineId'] } } } };
- tools/paths.js:1-5 (registration)Lists the paths to tool modules, enabling automatic discovery of the get_line_status_detail tool.export const toolPaths = [ 'tfl/status.js', 'tfl/status-detail.js', 'tfl/journey-planner.js' ];
- lib/tools.js:7-30 (registration)Dynamically loads and registers tools from the toolPaths array, including get_line_status_detail.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; }); }