fix: mcp server tool discovery
Rafael Uzarowski committed
May 2, 2025 at 11:17 UTC
4a63c39b90a383f6ab928b19ca2717fa77ac61b9
1 file changed
+14
-13
python/helpers/mcp.py
+14
-13
@@ -297,14 +297,15 @@ class MCPConfig(BaseModel):
297
properties: dict[str, Any] = tool["input_schema"]["properties"]
298
for key, value in properties.items():
299
tool_args += f" \"{key}\": \"...\",\n"
300
+ examples = ""
301
+ description = ""
302
if "examples" in value:
301
- prompt += (
302
- f" * {key} ({value['type']}): {value['description']} (examples: {value['examples']})\n"
303
- )
304
- else:
305
- prompt += (
306
- f" * {key} ({value['type']}): {value['description']}\n"
307
- )
303
+ examples = f"(examples: {value['examples']})"
304
+ if "description" in value:
305
+ description = f": {value['description']}"
306
+ prompt += (
307
+ f" * {key} ({value['type']}){description} {examples}\n"
308
+ )
309
prompt += "\n"
310
311
prompt += (
@@ -450,12 +451,12 @@ class MCPClientLocal(MCPClientBase):
451
if not which(server.command):
452
raise ValueError(f"Command {server.command} not found")
453
453
- which_args = 0
454
- for arg in server.args:
455
- if which(arg):
456
- which_args = which_args + 1
457
- if which_args == 0:
458
- raise ValueError(f"None of the arguments {server.args} is a file")
454
+ # which_args = 0
455
+ # for arg in server.args:
456
+ # if which(arg):
457
+ # which_args = which_args + 1
458
+ # if which_args == 0:
459
+ # raise ValueError(f"None of the arguments {server.args} is a file")
460
461
server_params = StdioServerParameters(
462
command=server.command,