mirror of https://github.com/aliasrobotics/cai.git
Fix MCP command tool assignment and improve CLI error messaging (#222)
* fix(mcp): correct server param access and agent tool registration - Use getattr() instead of .get() for accessing server.params attributes - Fix tool registration logic to properly add tools to Agent * fix(cli): improve fallback message for failed or unknown commands - Replaced misleading "Unknown command" message with "Command failed or unknown"
This commit is contained in:
parent
dbe0436477
commit
b270cf246d
|
|
@ -1290,7 +1290,7 @@ def run_cai_cli(
|
||||||
|
|
||||||
# If command wasn't recognized, show error (skip for /shell or /s)
|
# If command wasn't recognized, show error (skip for /shell or /s)
|
||||||
if command not in ("/shell", "/s"):
|
if command not in ("/shell", "/s"):
|
||||||
console.print(f"[red]Unknown command: {command}[/red]")
|
console.print(f"[red]Command failed or unknown: {command}[/red]")
|
||||||
continue
|
continue
|
||||||
from rich.text import Text
|
from rich.text import Text
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,11 +116,11 @@ class GlobalMCPUtil(MCPUtil):
|
||||||
elif isinstance(server, MCPServerStdio):
|
elif isinstance(server, MCPServerStdio):
|
||||||
server_config["command"] = server.params.command
|
server_config["command"] = server.params.command
|
||||||
server_config["args"] = server.params.args
|
server_config["args"] = server.params.args
|
||||||
server_config["env"] = server.params.get("env")
|
server_config["env"] = getattr(server.params, "env")
|
||||||
server_config["cwd"] = server.params.get("cwd")
|
server_config["cwd"] = getattr(server.params, "cwd")
|
||||||
server_config["encoding"] = server.params.get("encoding", "utf-8")
|
server_config["encoding"] = getattr(server.params, "encoding", "utf-8")
|
||||||
server_config["encoding_error_handler"] = server.params.get(
|
server_config["encoding_error_handler"] = getattr(
|
||||||
"encoding_error_handler", "strict"
|
server.params, "encoding_error_handler", "strict"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create a custom invoke function that creates a new connection each time
|
# Create a custom invoke function that creates a new connection each time
|
||||||
|
|
@ -810,9 +810,9 @@ Example: `/mcp add burp 13`
|
||||||
|
|
||||||
# Get the agent
|
# Get the agent
|
||||||
try:
|
try:
|
||||||
agent = get_agent_by_name(agent_identifier)
|
agent = get_available_agents()[agent_identifier]
|
||||||
agent_display_name = getattr(agent, "name", agent_identifier)
|
agent_display_name = getattr(agent, "name", agent_identifier)
|
||||||
except ValueError:
|
except KeyError:
|
||||||
# Try by index
|
# Try by index
|
||||||
try:
|
try:
|
||||||
agents = get_available_agents()
|
agents = get_available_agents()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue