feat: add static strava://activity/last/map resource to show up in MCP Inspector Resources tab
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
"""Strava MCP Server"""
|
"""Strava MCP Server"""
|
||||||
|
|
||||||
__version__ = "0.2.5"
|
__version__ = "0.2.6"
|
||||||
|
|||||||
@@ -267,6 +267,53 @@ def register(mcp: FastMCP, strava: StravaClient) -> None:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return [TextContent(type="text", text=f"Error fetching kudoers: {str(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 "<html><body><p>Error loading map</p></body></html>"
|
||||||
|
|
||||||
|
@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 "<html><body><p>Keine Strava-Aktivitäten gefunden.</p></body></html>"
|
||||||
|
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"<html><body><p>Error loading last activity: {str(e)}</p></body></html>"
|
||||||
|
return "<html><body><p>Error loading map</p></body></html>"
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def get_laps_by_activity_id(activity_id: int):
|
async def get_laps_by_activity_id(activity_id: int):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user