Skip to main content
Glama

export-route-gpx

Export Strava routes as GPX files for offline navigation or device compatibility. Save route data to a local directory for use with GPS devices and mapping applications.

Instructions

Exports a specific Strava route in GPX format and saves it to a pre-configured local directory.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
routeIdYesThe ID of the Strava route to export.

Implementation Reference

  • The execution handler for the export-route-gpx tool.
    execute: async ({ routeId }: ExportRouteGpxInput) => {
        const token = process.env.STRAVA_ACCESS_TOKEN;
        if (!token) {
            // Strict return structure
            return {
                content: [{ type: "text" as const, text: "❌ Error: Missing STRAVA_ACCESS_TOKEN in .env file." }],
                isError: true
            };
        }
    
        const exportDir = process.env.ROUTE_EXPORT_PATH;
        if (!exportDir) {
            // Strict return structure
            return {
                content: [{ type: "text" as const, text: "❌ Error: Missing ROUTE_EXPORT_PATH in .env file. Please configure the directory for saving exports." }],
                isError: true
            };
        }
    
        try {
            // Ensure the directory exists, create if not
            if (!fs.existsSync(exportDir)) {
                console.error(`Export directory ${exportDir} not found, creating it...`);
                fs.mkdirSync(exportDir, { recursive: true });
            } else {
                // Check if it's a directory and writable (existing logic)
                const stats = fs.statSync(exportDir);
                if (!stats.isDirectory()) {
                    // Strict return structure
                    return {
                        content: [{ type: "text" as const, text: `❌ Error: ROUTE_EXPORT_PATH (${exportDir}) is not a valid directory.` }],
                        isError: true
                    };
                }
                fs.accessSync(exportDir, fs.constants.W_OK);
            }
    
            const gpxData = await fetchGpxData(token, routeId);
            const filename = `route-${routeId}.gpx`;
            const fullPath = path.join(exportDir, filename);
            fs.writeFileSync(fullPath, gpxData);
    
            // Strict return structure
            return {
                content: [{ type: "text" as const, text: `✅ Route ${routeId} exported successfully as GPX to: ${fullPath}` }],
            };
    
        } catch (err: any) {
            console.error(`Error in export-route-gpx tool for route ${routeId}:`, err);
            // Strict return structure
            let userMessage = `❌ Error exporting route ${routeId} as GPX: ${err.message}`;
            if (err.code === 'EACCES') {
                userMessage = `❌ Error: No write permission for ROUTE_EXPORT_PATH directory (${exportDir}).`;
            }
            return {
                content: [{ type: "text" as const, text: userMessage }],
                isError: true
            };
        }
    },
  • The input schema definition for the export-route-gpx tool.
    const ExportRouteGpxInputSchema = z.object({
        routeId: z.string().describe("The ID of the Strava route to export."),
    });
  • The definition object for the export-route-gpx tool, including name, description, and schema.
    export const exportRouteGpx = {
        name: "export-route-gpx",
        description: "Exports a specific Strava route in GPX format and saves it to a pre-configured local directory.",
        inputSchema: ExportRouteGpxInputSchema,
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that the tool saves files locally, which is a key behavioral trait. However, it lacks details on permissions, error handling, or file naming conventions, which are important for a file-export 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, well-structured sentence that efficiently conveys the tool's purpose and key behavior (saving to local directory). Every word earns its place, with no redundant or vague phrasing.

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

Completeness4/5

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

Given the tool's moderate complexity (exporting a file), no annotations, and no output schema, the description is mostly complete but could improve by mentioning output details like file path or success indicators. It covers the core action and destination adequately for basic use.

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 the 'routeId' parameter. The description does not add any additional meaning or context beyond what the schema provides, such as format examples or source of the ID, resulting in a baseline score of 3.

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

Purpose5/5

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

The description clearly states the specific action ('Exports'), resource ('a specific Strava route'), and output format ('GPX format'), distinguishing it from sibling tools like 'export-route-tcx' which exports in TCX format. It provides complete information about what the tool does.

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

Usage Guidelines4/5

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

The description implies usage context by specifying 'saves it to a pre-configured local directory,' which suggests when to use this tool (for local GPX export). However, it does not explicitly state when not to use it or name alternatives like 'export-route-tcx' for different formats, leaving some guidance implicit.

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/LimeON-source/Strava-MCP'

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