Skip to main content
Glama

explore-segments

Find popular running and cycling segments within a specific geographical area to discover new routes and challenges.

Instructions

Searches for popular segments within a given geographical area.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
boundsYesThe geographical area to search, specified as a comma-separated string: south_west_lat,south_west_lng,north_east_lat,north_east_lng
activityTypeNoFilter segments by activity type (optional: 'running' or 'riding').
minCatNoFilter by minimum climb category (optional, 0-5). Requires riding activityType.
maxCatNoFilter by maximum climb category (optional, 0-5). Requires riding activityType.

Implementation Reference

  • The 'exploreSegments' constant defines the tool name, description, schema, and the 'execute' function which contains the tool's core logic for interacting with the Strava API.
    export const exploreSegments = {
        name: "explore-segments",
        description: "Searches for popular segments within a given geographical area.",
        inputSchema: ExploreSegmentsInputSchema,
        execute: async ({ bounds, activityType, minCat, maxCat }: ExploreSegmentsInput) => {
            const token = process.env.STRAVA_ACCESS_TOKEN;
    
            if (!token || token === 'YOUR_STRAVA_ACCESS_TOKEN_HERE') {
                console.error("Missing or placeholder STRAVA_ACCESS_TOKEN in .env");
                return {
                    content: [{ type: "text" as const, text: "❌ Configuration Error: STRAVA_ACCESS_TOKEN is missing or not set in the .env file." }],
                    isError: true,
                };
            }
            if ((minCat !== undefined || maxCat !== undefined) && activityType !== 'riding') {
                return {
                    content: [{ type: "text" as const, text: "❌ Input Error: Climb category filters (minCat, maxCat) require activityType to be 'riding'." }],
                    isError: true,
                };
            }
    
            try {
                console.error(`Exploring segments within bounds: ${bounds}...`);
                const athlete = await getAuthenticatedAthlete(token);
                const response: StravaExplorerResponse = await fetchExploreSegments(token, bounds, activityType, minCat, maxCat);
                console.error(`Found ${response.segments?.length ?? 0} segments.`);
    
                if (!response.segments || response.segments.length === 0) {
                    return { content: [{ type: "text" as const, text: " MNo segments found in the specified area with the given filters." }] };
                }
    
                const distanceFactor = athlete.measurement_preference === 'feet' ? 0.000621371 : 0.001;
                const distanceUnit = athlete.measurement_preference === 'feet' ? 'mi' : 'km';
                const elevationFactor = athlete.measurement_preference === 'feet' ? 3.28084 : 1;
                const elevationUnit = athlete.measurement_preference === 'feet' ? 'ft' : 'm';
    
                const segmentItems = response.segments.map(segment => {
                    const distance = (segment.distance * distanceFactor).toFixed(2);
                    const elevDifference = (segment.elev_difference * elevationFactor).toFixed(0);
                    const text = `
    πŸ—ΊοΈ **${segment.name}** (ID: ${segment.id})
       - Climb: Cat ${segment.climb_category_desc} (${segment.climb_category})
       - Distance: ${distance} ${distanceUnit}
       - Avg Grade: ${segment.avg_grade}%
       - Elev Difference: ${elevDifference} ${elevationUnit}
       - Starred: ${segment.starred ? 'Yes' : 'No'}
                    `.trim();
                    const item: { type: "text", text: string } = { type: "text" as const, text };
                    return item;
                });
    
                const responseText = `**Found Segments:**\n\n${segmentItems.map(item => item.text).join("\n---\n")}`;
    
                return { content: [{ type: "text" as const, text: responseText }] };
            } catch (error) {
                const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
                console.error("Error in explore-segments tool:", errorMessage);
                return {
                    content: [{ type: "text" as const, text: `❌ API Error: ${errorMessage}` }],
                    isError: true,
                };
            }
        }
    };
  • The 'ExploreSegmentsInputSchema' defines the Zod schema for the tool's input parameters, including validation for geographic bounds and activity type filters.
    const ExploreSegmentsInputSchema = z.object({
        bounds: z.string()
            .regex(/^-?\d+(\.\d+)?,-?\d+(\.\d+)?,-?\d+(\.\d+)?,-?\d+(\.\d+)?$/, "Bounds must be in the format: south_west_lat,south_west_lng,north_east_lat,north_east_lng")
            .describe("The geographical area to search, specified as a comma-separated string: south_west_lat,south_west_lng,north_east_lat,north_east_lng"),
        activityType: z.enum(["running", "riding"])
            .optional()
            .describe("Filter segments by activity type (optional: 'running' or 'riding')."),
        minCat: z.number().int().min(0).max(5).optional()
            .describe("Filter by minimum climb category (optional, 0-5). Requires riding activityType."),
        maxCat: z.number().int().min(0).max(5).optional()
            .describe("Filter by maximum climb category (optional, 0-5). Requires riding activityType."),
    });
Behavior2/5

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

With no annotations, the description carries full burden but adds minimal behavioral context. It mentions 'popular segments' but doesn't define popularity metrics, disclose rate limits, authentication needs, or response format. For a search tool with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

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. It's front-loaded with the core purpose and avoids redundancy. Every word earns its place, making it easy for an agent to parse quickly.

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

Completeness3/5

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

Given 4 parameters, 100% schema coverage, no output schema, and no annotations, the description is minimally adequate. It states what the tool does but lacks context on authentication, rate limits, return values, or sibling differentiation. For a search tool with filtering parameters, more guidance would improve completeness.

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 fully documents all parameters. The description adds no parameter-specific semantics beyond implying geographical filtering via 'geographical area.' It doesn't explain parameter interactions (e.g., minCat/maxCat requiring riding activityType) or provide examples, so it meets the baseline for high schema 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 tool's purpose: 'Searches for popular segments within a given geographical area.' It specifies the verb ('searches'), resource ('segments'), and scope ('geographical area'). However, it doesn't differentiate from sibling tools like 'list-starred-segments' or 'get-segment', which also retrieve segments but with different criteria.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., requiring Strava connection), exclusions, or compare it to siblings like 'list-starred-segments' (user-specific) or 'get-segment' (single segment by ID). The agent must infer usage from the name and parameters alone.

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