diff --git a/scripts/generate_test_map.py b/scripts/generate_test_map.py index 9a1d63d..7f26b2f 100644 --- a/scripts/generate_test_map.py +++ b/scripts/generate_test_map.py @@ -115,8 +115,7 @@ async def generate(): print("Generating mock map HTML from resource...") resource_handler = mcp.resources["strava://activity/{activity_id}/map"] - resource_result = await resource_handler(99999) - html_text = resource_result.contents[0].text + html_text = await resource_handler(99999) if html_text: output_path = os.path.join(os.path.dirname(__file__), "..", "test.html") @@ -176,8 +175,7 @@ async def generate(): print("Generating map HTML from resource...") resource_handler = mcp.resources["strava://activity/{activity_id}/map"] - resource_result = await resource_handler(activity_id) - html_text = resource_result.contents[0].text + html_text = await resource_handler(activity_id) if html_text: output_path = os.path.join(os.path.dirname(__file__), "..", "test.html") diff --git a/src/strava_mcp_server/tools/activities.py b/src/strava_mcp_server/tools/activities.py index f818c11..258413e 100644 --- a/src/strava_mcp_server/tools/activities.py +++ b/src/strava_mcp_server/tools/activities.py @@ -6,7 +6,6 @@ from mcp.types import ( EmbeddedResource, TextResourceContents, CallToolResult, - ReadResourceResult, ) from strava_mcp_server.strava_client import StravaClient from strava_mcp_server.utils import ( @@ -902,52 +901,18 @@ def register(mcp: FastMCP, strava: StravaClient) -> None: ) @mcp.resource("strava://activity/{activity_id}/map", mime_type="text/html") - async def get_activity_map_resource(activity_id: int) -> ReadResourceResult: + async def get_activity_map_resource(activity_id: int) -> str: """HTML map resource for a specific Strava activity.""" - html_content = await _render_activity_map_html(activity_id) - return ReadResourceResult( - contents=[ - TextResourceContents( - uri=f"strava://activity/{activity_id}/map", - mimeType="text/html", - text=html_content, - ) - ] - ) + return await _render_activity_map_html(activity_id) @mcp.resource("strava://activity/last/map", mime_type="text/html") - async def get_last_activity_map_resource() -> ReadResourceResult: + async def get_last_activity_map_resource() -> str: """HTML map resource for the most recent Strava activity.""" try: activities = await strava.list_activities(limit=1) if not activities: - return ReadResourceResult( - contents=[ - TextResourceContents( - uri="strava://activity/last/map", - mimeType="text/html", - text="
Keine Strava-Aktivitäten gefunden.
", - ) - ] - ) + return "Keine Strava-Aktivitäten gefunden.
" last_id = activities[0]["id"] - html_content = await _render_activity_map_html(last_id) - return ReadResourceResult( - contents=[ - TextResourceContents( - uri="strava://activity/last/map", - mimeType="text/html", - text=html_content, - ) - ] - ) + return await _render_activity_map_html(last_id) except Exception as e: - return ReadResourceResult( - contents=[ - TextResourceContents( - uri="strava://activity/last/map", - mimeType="text/html", - text=f"Error loading last activity: {str(e)}
", - ) - ] - ) + return f"Error loading last activity: {str(e)}
" diff --git a/tests/unit/test_map.py b/tests/unit/test_map.py index 27de6d9..31588b8 100644 --- a/tests/unit/test_map.py +++ b/tests/unit/test_map.py @@ -67,14 +67,9 @@ async def test_get_activity_map_success(): # Now fetch and test the actual HTML from the registered resource handler assert "strava://activity/{activity_id}/map" in mcp.resources resource_handler = mcp.resources["strava://activity/{activity_id}/map"] - resource_result = await resource_handler(12345) + html_text = await resource_handler(12345) - assert len(resource_result.contents) == 1 - resource_content = resource_result.contents[0] - assert str(resource_content.uri) == "strava://activity/12345/map" - assert resource_content.mimeType == "text/html" - - html_text = resource_content.text + assert isinstance(html_text, str) assert "" in html_text assert "unpkg.com/leaflet" in html_text assert "latlngData" in html_text