Skip to main content
Glama
anoopt

TfL Journey Status MCP Server

get_line_status

Check real-time status and disruptions for London Underground lines using Transport for London data. Query specific tube lines to get current service information for journey planning.

Instructions

Get the status of a TfL line from the Transport for London Unified API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
lineIdYesThe identifier of the line to query (e.g., victoria, central).
app_keyNoOptional application key for the API.

Implementation Reference

  • The core handler function `executeFunction` that fetches the current status of a specified TfL line from the TfL API, handling parameters and errors.
    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)}`
        };
      }
    };
  • The `apiTool` object defining the tool's schema, including name, description, input parameters schema with lineId required and app_key optional.
    const apiTool = {
      function: executeFunction,
      definition: {
        type: 'function',
        function: {
          name: 'get_line_status',
          description: 'Get the status of a TfL line from the Transport for London Unified API.',
          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']
          }
        }
      }
    };
  • lib/tools.js:7-30 (registration)
    The `discoverTools` function that dynamically loads the `apiTool` exports from tool files listed in toolPaths, enabling registration of get_line_status among others for the MCP server.
    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;
      });
    }
  • tools/paths.js:1-5 (registration)
    The `toolPaths` array listing 'tfl/status.js' which provides the get_line_status tool, used by discoverTools for automatic registration.
    export const toolPaths = [
      'tfl/status.js',
      'tfl/status-detail.js',
      'tfl/journey-planner.js'
    ];
Behavior2/5

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

With no annotations provided, the description carries full burden but only states it retrieves status without detailing behavioral traits like rate limits, error handling, authentication needs (beyond the optional app_key parameter), or response format. It lacks crucial context for a read operation.

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 a single, efficient sentence with zero waste, front-loading the core purpose. It's appropriately sized for a simple tool, making it easy to parse quickly.

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

Completeness2/5

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

Given no annotations and no output schema, the description is incomplete for a tool that likely returns structured status data. It fails to explain what 'status' entails (e.g., disruptions, operational state) or provide context on the API's behavior, leaving significant gaps for agent usage.

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 schema already documents both parameters (lineId and app_key). The description adds no additional meaning beyond what the schema provides, such as examples of line status outputs or API specifics, meeting the baseline for high coverage.

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

Purpose4/5

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

The description clearly states the verb ('Get') and resource ('status of a TfL line'), specifying it uses the Transport for London Unified API. However, it doesn't distinguish from sibling 'get_line_status_detail', leaving some ambiguity about scope differences.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'get_line_status_detail' or 'plan_journey'. The description implies a simple status query but offers no explicit context or exclusions for usage.

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

Install Server

Other Tools

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/anoopt/london-tfl-journey-status-mcp-server'

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