refactor: migrate tool outputs to use EmbeddedResource with typed JSON for assistant-facing data
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
from mcp.server.fastmcp import FastMCP, Context
|
||||
from mcp.types import TextContent, Annotations
|
||||
from mcp.types import ContentBlock, TextContent, Annotations, EmbeddedResource, TextResourceContents
|
||||
from strava_mcp_server.strava_client import StravaClient
|
||||
from strava_mcp_server.utils import parse_iso_to_unix, format_date_iso, format_date_human
|
||||
|
||||
@@ -12,7 +12,7 @@ def register(mcp: FastMCP, strava: StravaClient) -> None:
|
||||
page: int = 1,
|
||||
before: str | None = None,
|
||||
after: str | None = None,
|
||||
) -> list[TextContent]:
|
||||
) -> list[ContentBlock]:
|
||||
"""
|
||||
List recent Strava activities for the authenticated user.
|
||||
:param limit: Number of activities to return per page (default 10, max 200).
|
||||
@@ -62,9 +62,13 @@ def register(mcp: FastMCP, strava: StravaClient) -> None:
|
||||
text=markdown_summary.strip(),
|
||||
annotations=Annotations(audience=["user"])
|
||||
),
|
||||
TextContent(
|
||||
type="text",
|
||||
text=json.dumps(essential_data, indent=2),
|
||||
EmbeddedResource(
|
||||
type="resource",
|
||||
resource=TextResourceContents(
|
||||
uri="internal://activities/list",
|
||||
mimeType="application/json",
|
||||
text=json.dumps(essential_data, indent=2)
|
||||
),
|
||||
annotations=Annotations(audience=["assistant"])
|
||||
)
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user