MCPcopy Create free account
hub / github.com/c4pt0r/pie / handle_request

Function handle_request

examples/mcp-notify-python/notify-server.py:59–86  ·  view source on GitHub ↗
(method: str, params: dict, request_id)

Source from the content-addressed store, hash-verified

57
58
59def handle_request(method: str, params: dict, request_id) -> None:
60 if method == "initialize":
61 send_response(
62 request_id,
63 result={
64 "protocolVersion": PROTOCOL_VERSION,
65 "capabilities": {"tools": {"listChanged": False}},
66 "serverInfo": {"name": SERVER_NAME, "version": SERVER_VERSION},
67 },
68 )
69 log("initialize -> ok")
70 return
71
72 if method == "tools/list":
73 send_response(request_id, result={"tools": []})
74 return
75
76 if method == "tools/call":
77 send_response(
78 request_id,
79 error={"code": -32601, "message": "no tools available on this server"},
80 )
81 return
82
83 send_response(
84 request_id,
85 error={"code": -32601, "message": f"method not found: {method}"},
86 )
87
88
89def handle_notification(method: str, params: dict) -> None:

Callers 1

mainFunction · 0.70

Calls 2

send_responseFunction · 0.70
logFunction · 0.70

Tested by

no test coverage detected