Skip to main content
Glama

get-activity-photos

Fetch photos from Strava activities to display, download, or analyze metadata including location and timestamps.

Instructions

Retrieves photos associated with a specific Strava activity.

Use Cases:

  • Fetch all photos uploaded to an activity

  • Get photo URLs for display or download

  • Access photo metadata including location and timestamps

Parameters:

  • id (required): The unique identifier of the Strava activity.

  • size (optional): Size of photos to return in pixels (e.g., 100, 600, 2048). If not specified, returns all available sizes.

Output Format: Returns both a human-readable summary and complete JSON data for each photo, including:

  1. A text summary with photo count and URLs

  2. Raw photo data containing all fields from the Strava API:

    • Photo ID and unique identifier

    • URLs for different sizes

    • Source (1 = Strava, 2 = Instagram)

    • Timestamps (uploaded_at, created_at)

    • Location coordinates if available

    • Caption if provided

Notes:

  • Requires activity:read scope for public/followers activities, activity:read_all for private activities

  • Photos may come from Strava uploads or linked Instagram posts

  • Returns empty array if activity has no photos

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe identifier of the activity to fetch photos for.
sizeNoOptional photo size in pixels (e.g., 100, 600, 2048).

Implementation Reference

  • The main definition and implementation of the get-activity-photos tool. It handles input validation, calling the Strava client, and formatting the output.
    export const getActivityPhotosTool = {
        name,
        description,
        inputSchema,
        execute: async ({ id, size }: GetActivityPhotosInput) => {
            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 {
                // Convert id to number if it's a string
                const activityId = typeof id === 'string' ? parseInt(id, 10) : id;
    
                if (isNaN(activityId)) {
                    return {
                        content: [{ type: "text" as const, text: `Invalid activity ID: ${id}` }],
                        isError: true
                    };
                }
    
                console.error(`Fetching photos for activity ID: ${activityId}...`);
                const photos = await getActivityPhotosClient(token, activityId, size);
    
                if (!photos || photos.length === 0) {
                    return {
                        content: [{ type: "text" as const, text: `No photos found for activity ID: ${activityId}` }]
                    };
                }
    
                // Generate human-readable summary
                const photoSummaries = photos.map((photo, index) => {
                    const details = [
                        `Photo ${index + 1}${photo.id ? ` (ID: ${photo.id})` : ''}${photo.unique_id ? ` [${photo.unique_id}]` : ''}`,
                    ];
    
                    // Add source info
                    if (photo.source !== undefined) {
                        const sourceText = photo.source === 1 ? 'Strava' : photo.source === 2 ? 'Instagram' : `Unknown (${photo.source})`;
                        details.push(`  Source: ${sourceText}`);
                    }
    
                    // Add caption if available
                    if (photo.caption) {
                        details.push(`  Caption: ${photo.caption}`);
                    }
    
                    // Add location if available
                    if (photo.location && photo.location.length === 2) {
                        const lat = photo.location[0];
                        const lng = photo.location[1];
                        if (lat !== undefined && lng !== undefined) {
                            details.push(`  Location: ${lat.toFixed(6)}, ${lng.toFixed(6)}`);
                        }
                    }
    
                    // Add timestamps
                    if (photo.created_at) {
                        details.push(`  Created: ${photo.created_at}`);
                    }
    
                    // Add URLs
                    if (photo.urls && Object.keys(photo.urls).length > 0) {
                        details.push(`  URLs:`);
                        for (const [sizeKey, url] of Object.entries(photo.urls)) {
                            details.push(`    ${sizeKey}: ${url}`);
                        }
                    }
    
                    return details.join('\n');
                });
    
                const summaryText = `Activity Photos (ID: ${activityId})\nTotal Photos: ${photos.length}\n\n${photoSummaries.join('\n\n')}`;
    
                // Add raw data section
                const rawDataText = `\n\nComplete Photo Data:\n${JSON.stringify(photos, null, 2)}`;
    
                console.error(`Successfully fetched ${photos.length} photos for activity ${activityId}`);
    
                return {
                    content: [
                        { type: "text" as const, text: summaryText },
                        { type: "text" as const, text: rawDataText }
                    ]
                };
            } catch (error) {
                const errorMessage = error instanceof Error ? error.message : String(error);
                console.error(`Error fetching photos for activity ${id}: ${errorMessage}`);
                const userFriendlyMessage = errorMessage.includes("Record Not Found") || errorMessage.includes("404")
                    ? `Activity with ID ${id} not found.`
                    : `An unexpected error occurred while fetching photos for activity ${id}. Details: ${errorMessage}`;
                return {
                    content: [{ type: "text" as const, text: `Error: ${userFriendlyMessage}` }],
                    isError: true
                };
            }
        }
    };
  • Zod schema for validating the input parameters of the get-activity-photos tool.
    const inputSchema = z.object({
        id: z.union([z.number(), z.string()]).describe("The identifier of the activity to fetch photos for."),
        size: z.number().int().positive().optional().describe("Optional photo size in pixels (e.g., 100, 600, 2048)."),
    });
  • src/server.ts:189-189 (registration)
    Marker for where the get-activity-photos tool is registered in the server.
    // --- Register get-activity-photos tool ---

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.2.1

TDQS

A4.6/5.0
Behavior5/5

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

Despite no annotations, the description discloses scope requirements (activity:read vs activity:read_all), the possibility of Instagram-sourced photos, and the empty-array behavior. It also explains the size parameter's default behavior, providing thorough transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections. It could be slightly tighter in the output-format section, but every part serves a purpose and is easy to scan.

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

Completeness5/5

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

For a two-parameter tool with no annotations and no output schema, the description is exceptionally complete. It covers purpose, parameters, output structure, auth scopes, and edge cases, leaving no critical gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema already covers both parameters, but the description adds value with size examples and the behavior when size is omitted (returns all sizes). This enhances understanding beyond the schema's bare definition.

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 opens with a specific verb and resource: 'Retrieves photos associated with a specific Strava activity.' This clearly distinguishes it from sibling tools like get-activity-details or get-activity-streams, which handle other types of activity data.

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?

Use cases explicitly state when to use the tool: fetching photos, getting URLs, and accessing metadata. While it doesn't name alternative tools, the context makes the appropriate scenario clear. A slight improvement would be explicitly contrasting with other activity-data tools.

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