MCPcopy
hub / github.com/modelcontextprotocol/python-sdk / call_tool

Function call_tool

tests/interaction/transports/_stdio_server.py:41–48  ·  view source on GitHub ↗
(ctx: ServerRequestContext, params: CallToolRequestParams)

Source from the content-addressed store, hash-verified

39
40
41async def call_tool(ctx: ServerRequestContext, params: CallToolRequestParams) -> CallToolResult:
42 assert params.name == "echo"
43 assert params.arguments is not None
44 text = params.arguments["text"]
45 with warnings.catch_warnings():
46 warnings.simplefilter("ignore", MCPDeprecationWarning)
47 await ctx.session.send_log_message(level="info", data=f"echoing {text}", logger="echo") # pyright: ignore[reportDeprecated]
48 return CallToolResult(content=[TextContent(text=text)])
49
50
51async def set_logging_level(ctx: ServerRequestContext, params: SetLevelRequestParams) -> EmptyResult:

Callers

nothing calls this directly

Calls 3

CallToolResultClass · 0.90
TextContentClass · 0.90
send_log_messageMethod · 0.80

Tested by

no test coverage detected