MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / call_tool

Method call_tool

examples/MCP Client/client.py:139–151  ·  view source on GitHub ↗

Call a tool

(self, name, arguments=None)

Source from the content-addressed store, hash-verified

137 return []
138
139 def call_tool(self, name, arguments=None):
140 """Call a tool"""
141 response = self.send_request(
142 "tools/call", {"name": name, "arguments": arguments or {}}
143 )
144
145 if "result" in response:
146 print(f"\n✓ Tool '{name}' executed successfully")
147 return response["result"]
148 else:
149 error = response.get("error", {})
150 print(f"✗ Tool '{name}' failed: {error.get('message', 'Unknown error')}")
151 return None
152
153 def list_resources(self):
154 """List available resources"""

Callers 1

mainFunction · 0.95

Calls 2

send_requestMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected