get-segment
Retrieve detailed information about a Strava segment using its unique ID to analyze route data, elevation profiles, and performance metrics.
Instructions
Fetches detailed information about a specific segment using its ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| segmentId | Yes | The unique identifier of the segment to fetch. |
Implementation Reference
- src/tools/getSegment.ts:53-84 (handler)The execute function for the 'get-segment' tool, which fetches segment details using a Strava access token and formats them.
execute: async ({ segmentId }: GetSegmentInput) => { const token = process.env.STRAVA_ACCESS_TOKEN; if (!token) { console.error("Missing STRAVA_ACCESS_TOKEN environment variable."); return { content: [{ type: "text" as const, text: "Configuration error: Missing Strava access token." }], isError: true }; } try { console.error(`Fetching details for segment ID: ${segmentId}...`); // Removed getAuthenticatedAthlete call const segment = await fetchSegmentById(token, segmentId); const segmentDetailsText = formatSegmentDetails(segment); // Use metric formatter console.error(`Successfully fetched details for segment: ${segment.name}`); return { content: [{ type: "text" as const, text: segmentDetailsText }] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); console.error(`Error fetching segment ${segmentId}: ${errorMessage}`); // Removed call to handleApiError const userFriendlyMessage = errorMessage.includes("Record Not Found") || errorMessage.includes("404") ? `Segment with ID ${segmentId} not found.` : `An unexpected error occurred while fetching segment details for ID ${segmentId}. Details: ${errorMessage}`; return { content: [{ type: "text" as const, text: `❌ ${userFriendlyMessage}` }], isError: true }; } } - src/tools/getSegment.ts:10-12 (schema)Zod schema defining the input requirements for the 'get-segment' tool.
const GetSegmentInputSchema = z.object({ segmentId: z.number().int().positive().describe("The unique identifier of the segment to fetch.") }); - src/tools/getSegment.ts:49-52 (registration)The export object defining the 'get-segment' tool, including its name, description, schema, and execute handler.
export const getSegmentTool = { name: "get-segment", description: "Fetches detailed information about a specific segment using its ID.", inputSchema: GetSegmentInputSchema,