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 ---
Behavior5/5

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

With no annotations provided, the description carries the full burden and excels by disclosing key behavioral traits: it specifies required OAuth scopes ('activity:read' vs 'activity:read_all'), notes data sources (Strava or Instagram), describes edge cases ('Returns empty array if activity has no photos'), and mentions output format details. This goes well beyond basic functionality.

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 well-structured with clear sections (Use Cases, Parameters, Output Format, Notes), front-loaded with the core purpose, and every sentence adds value without redundancy. It efficiently conveys necessary information in a readable format.

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?

Given the complexity of handling photos with authentication and data sources, no annotations, and no output schema, the description is highly complete. It covers purpose, usage, parameters, output details, authentication requirements, data sources, and edge cases, providing all needed context for effective tool 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 both parameters adequately. The description adds minimal value beyond the schema by clarifying the 'size' parameter's effect ('returns all available sizes' if unspecified) and providing example values, but does not significantly enhance understanding of parameter semantics.

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 tool's purpose with a specific verb ('Retrieves') and resource ('photos associated with a specific Strava activity'), distinguishing it from sibling tools like 'get-activity-details' or 'get-activity-streams' that handle different aspects of activities. It precisely defines what is being fetched without ambiguity.

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 provides clear context for when to use this tool through 'Use Cases' (e.g., fetching photos, getting URLs, accessing metadata), but does not explicitly state when not to use it or name alternatives among siblings. It implies usage for photo-related needs without direct comparison to other tools.

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