Skip to content

Commit

Permalink
fix return values of tools
Browse files Browse the repository at this point in the history
  • Loading branch information
dsp-ant committed Nov 20, 2024
1 parent dee1bd0 commit 07d3b2f
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions src/mcp/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,30 +265,8 @@ def decorator(
async def handler(req: types.CallToolRequest):
try:
results = await func(req.params.name, (req.params.arguments or {}))
content = []
for result in results:
match result:
case str() as text:
content.append(
types.TextContent(type="text", text=text)
)
case types.ImageContent() as img:
content.append(
types.ImageContent(
type="image",
data=img.data,
mimeType=img.mimeType,
)
)
case types.EmbeddedResource() as resource:
content.append(
types.EmbeddedResource(
type="resource", resource=resource.resource
)
)

return types.ServerResult(
types.CallToolResult(content=content, isError=False)
types.CallToolResult(content=list(results), isError=False)
)
except Exception as e:
return types.ServerResult(
Expand Down

0 comments on commit 07d3b2f

Please sign in to comment.