File tree Expand file tree Collapse file tree 1 file changed +8
-16
lines changed
Expand file tree Collapse file tree 1 file changed +8
-16
lines changed Original file line number Diff line number Diff line change 66
77Common usage pattern:
88```
9- server = Server(name)
10-
11- @server.call_tool()
12- async def handle_tool_call(ctx: RequestContext, arguments: dict[str, Any]) -> Any:
9+ async def handle_call_tool(ctx: RequestContext, params: CallToolRequestParams) -> CallToolResult:
1310 # Check client capabilities before proceeding
1411 if ctx.session.check_client_capability(
1512 types.ClientCapabilities(experimental={"advanced_tools": dict()})
1613 ):
17- # Perform advanced tool operations
18- result = await perform_advanced_tool_operation(arguments)
14+ result = await perform_advanced_tool_operation(params.arguments)
1915 else:
20- # Fall back to basic tool operations
21- result = await perform_basic_tool_operation(arguments)
22-
16+ result = await perform_basic_tool_operation(params.arguments)
2317 return result
2418
25- @server.list_prompts()
26- async def handle_list_prompts(ctx: RequestContext) -> list[types.Prompt]:
27- # Access session for any necessary checks or operations
19+ async def handle_list_prompts(ctx: RequestContext, params) -> ListPromptsResult:
2820 if ctx.session.client_params:
29- # Customize prompts based on client initialization parameters
30- return generate_custom_prompts(ctx.session.client_params )
31- else:
32- return default_prompts
21+ return ListPromptsResult( prompts=generate_custom_prompts(ctx.session.client_params))
22+ return ListPromptsResult(prompts=default_prompts )
23+
24+ server = Server(name, on_call_tool=handle_call_tool, on_list_prompts=handle_list_prompts)
3325```
3426
3527The ServerSession class is typically used internally by the Server class and should not
You can’t perform that action at this time.
0 commit comments