Skip to content

Commit e0d5757

Browse files
committed
feat: Add output schema definitions for server responses in simple tools and low-level server tests
1 parent 8bc6394 commit e0d5757

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

examples/servers/simple-streamablehttp-stateless/mcp_simple_streamablehttp_stateless/server.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ async def list_tools() -> list[types.Tool]:
9999
},
100100
},
101101
},
102+
outputSchema={
103+
"type": "array",
104+
"items": {
105+
"type": "object",
106+
"description": "TextContent with notification information",
107+
},
108+
"description": "List of text content with notification results",
109+
},
102110
)
103111
]
104112

examples/servers/simple-tool/mcp_simple_tool/server.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ async def list_tools() -> list[types.Tool]:
5454
}
5555
},
5656
},
57+
outputSchema={
58+
"type": "array",
59+
"items": {
60+
"anyOf": [
61+
{"type": "object", "description": "TextContent"},
62+
{"type": "object", "description": "ImageContent"},
63+
{"type": "object", "description": "EmbeddedResource"},
64+
]
65+
},
66+
"description": "List of content from the fetched website",
67+
},
5768
)
5869
]
5970

tests/server/test_lowlevel_tool_annotations.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ async def list_tools():
3838
},
3939
"required": ["message"],
4040
},
41+
outputSchema={"type": "string", "description": "The echoed message"},
4142
annotations=ToolAnnotations(
4243
title="Echo Tool",
4344
readOnlyHint=True,
@@ -54,9 +55,11 @@ async def list_tools():
5455

5556
# Message handler for client
5657
async def message_handler(
57-
message: RequestResponder[ServerRequest, ClientResult]
58-
| ServerNotification
59-
| Exception,
58+
message: (
59+
RequestResponder[ServerRequest, ClientResult]
60+
| ServerNotification
61+
| Exception
62+
),
6063
) -> None:
6164
if isinstance(message, Exception):
6265
raise message

0 commit comments

Comments
 (0)