Skip to main content
Glama

smart_route_request

Route user requests to the optimal ACP agent using the ACP-MCP-Server, ensuring efficient processing and integration with MCP-compatible tools for enhanced AI agent communication.

Instructions

Intelligently route a request to the best ACP agent

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_textYes
modeNosync
session_idNo
strategyNodefault

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler implementation for the 'smart_route_request' tool. This async function, decorated with @mcp.tool(), handles the tool execution by calling the router's execute_routed_request method and returning a JSON-formatted result.
    @mcp.tool()
    async def smart_route_request(
        input_text: str,
        strategy: str = "default",
        mode: str = "sync",
        session_id: str = None
    ) -> str:
        """Intelligently route a request to the best ACP agent"""
        
        try:
            result = await router.execute_routed_request(
                input_text=input_text,
                strategy_name=strategy,
                mode=mode,
                session_id=session_id
            )
            
            return json.dumps(result, indent=2)
            
        except Exception as e:
            return f"Error: {e}"
  • The registration point where register_router_tools is called on the FastMCP instance, which defines and registers the smart_route_request tool using the @mcp.tool() decorator.
    register_router_tools(self.mcp, self.router)
  • Supporting helper method in AgentRouter class that performs the actual routing and execution logic invoked by the smart_route_request tool handler.
    async def execute_routed_request(
        self,
        input_text: str,
        strategy_name: str = "default",
        mode: str = "sync",
        session_id: Optional[str] = None
    ) -> Dict[str, Any]:
        """Route and execute a request"""
        
        try:
            # Route the request
            target_agent, routing_reason = await self.route_request(input_text, strategy_name)
            
            # Execute the agent
            if mode == "sync":
                run = await self.orchestrator.execute_agent_sync(
                    target_agent, 
                    input_text, 
                    session_id
                )
                
                result = {
                    "routed_to": target_agent,
                    "routing_reason": routing_reason,
                    "execution_mode": mode,
                    "status": run.status,
                    "run_id": run.run_id
                }
                
                if run.output:
                    # Handle ACP output format - run.output is already a list of messages
                    output_text = ""
                    for message in run.output:
                        if isinstance(message, dict) and "parts" in message:
                            for part in message["parts"]:
                                if isinstance(part, dict) and "content" in part:
                                    output_text += part["content"] + "\n"
                    result["output"] = output_text.strip() if output_text else "No text content"
                
                if run.error:
                    result["error"] = run.error
                
                return result
                
            else:
                # Async mode
                run_id = await self.orchestrator.execute_agent_async(
                    target_agent,
                    input_text,
                    session_id
                )
                
                return {
                    "routed_to": target_agent,
                    "routing_reason": routing_reason,
                    "execution_mode": mode,
                    "run_id": run_id,
                    "status": "async_started"
                }
                
        except Exception as e:
            return {
                "error": str(e),
                "routed_to": None,
                "routing_reason": "Routing failed"
            }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'intelligently route' but doesn't explain what that entails—whether it's a read-only operation, if it modifies state, what permissions are needed, or how it handles errors. For a tool with 4 parameters and no annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point with no wasted words. It's appropriately sized for a tool with this complexity and is front-loaded with the core purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 4 parameters with 0% schema coverage and no annotations, but does have an output schema, the description is incomplete. It doesn't explain parameter semantics or behavioral traits, though the output schema might cover return values. For a routing tool with multiple parameters, more context is needed to be fully helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning none of the 4 parameters have descriptions in the schema. The tool description doesn't add any meaning beyond the schema—it doesn't explain what 'input_text', 'mode', 'session_id', or 'strategy' do, their formats, or acceptable values. This fails to compensate for the low coverage, leaving parameters largely undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Intelligently route a request to the best ACP agent'. It specifies the verb ('route') and resource ('request'), and distinguishes it from siblings like 'add_routing_rule' or 'run_acp_agent'. However, it doesn't explicitly differentiate from 'list_routing_strategies' or 'test_routing', which keeps it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'run_acp_agent', 'analyze_message_content', and 'list_routing_strategies', there's no indication of context, prerequisites, or exclusions. This leaves the agent guessing about appropriate use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/GongRzhe/ACP-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server