From 04663d7ba14d4efe080279debc15c77aa21e5939 Mon Sep 17 00:00:00 2001 From: Matthias Hinrichs Date: Sat, 30 May 2026 19:00:38 +0200 Subject: [PATCH] feat: add static strava://activity/last/map resource to show up in MCP Inspector Resources tab --- src/strava_mcp_server/__init__.py | 2 +- src/strava_mcp_server/tools/activities.py | 47 +++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/strava_mcp_server/__init__.py b/src/strava_mcp_server/__init__.py index 3506b38..8f71c96 100644 --- a/src/strava_mcp_server/__init__.py +++ b/src/strava_mcp_server/__init__.py @@ -1,3 +1,3 @@ """Strava MCP Server""" -__version__ = "0.2.5" +__version__ = "0.2.6" diff --git a/src/strava_mcp_server/tools/activities.py b/src/strava_mcp_server/tools/activities.py index 4c27325..a039edd 100644 --- a/src/strava_mcp_server/tools/activities.py +++ b/src/strava_mcp_server/tools/activities.py @@ -267,6 +267,53 @@ def register(mcp: FastMCP, strava: StravaClient) -> None: except Exception as e: return [TextContent(type="text", text=f"Error fetching kudoers: {str(e)}")] + @mcp.resource("strava://activity/{activity_id}/map") + async def get_activity_map_resource(activity_id: int) -> str: + """HTML map resource for a specific Strava activity.""" + + class DummyContext: + async def info(self, msg): + pass + + async def warning(self, msg): + pass + + async def error(self, msg): + pass + + ctx = DummyContext() + result = await get_activity_map(ctx, activity_id) + if result and result.content: + return result.content[0].text + return "

Error loading map

" + + @mcp.resource("strava://activity/last/map") + async def get_last_activity_map_resource() -> str: + """HTML map resource for the most recent Strava activity.""" + + class DummyContext: + async def info(self, msg): + pass + + async def warning(self, msg): + pass + + async def error(self, msg): + pass + + ctx = DummyContext() + try: + activities = await strava.list_activities(limit=1) + if not activities: + return "

Keine Strava-Aktivitäten gefunden.

" + last_id = activities[0]["id"] + result = await get_activity_map(ctx, last_id) + if result and result.content: + return result.content[0].text + except Exception as e: + return f"

Error loading last activity: {str(e)}

" + return "

Error loading map

" + @mcp.tool() async def get_laps_by_activity_id(activity_id: int): """