Skip to main content
Glama

add_routing_rule

Add a new routing rule to a strategy by specifying keywords, agent name, and priority to manage communication between ACP agents and MCP clients effectively.

Instructions

Add a new routing rule to a strategy

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_nameYes
descriptionNo
keywordsYes
priorityNo
strategy_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The FastMCP tool handler for 'add_routing_rule'. Parses comma-separated keywords, creates a RoutingRule instance, and appends it to an existing strategy or creates a new RouterStrategy.
    @mcp.tool()
    async def add_routing_rule(
        strategy_name: str,
        keywords: str,  # Comma-separated
        agent_name: str,
        priority: int = 5,
        description: str = ""
    ) -> str:
        """Add a new routing rule to a strategy"""
        
        try:
            keyword_list = [k.strip() for k in keywords.split(",")]
            
            new_rule = RoutingRule(
                keywords=keyword_list,
                agent_name=agent_name,
                priority=priority,
                description=description or f"Route to {agent_name}"
            )
            
            # Get or create strategy
            if strategy_name in router.strategies:
                strategy = router.strategies[strategy_name]
                strategy.rules.append(new_rule)
            else:
                strategy = RouterStrategy(
                    name=strategy_name,
                    description=f"Custom strategy: {strategy_name}",
                    rules=[new_rule]
                )
                router.strategies[strategy_name] = strategy
            
            return f"Successfully added rule: {keyword_list} -> {agent_name}"
            
        except Exception as e:
            return f"Error: {e}"
  • Pydantic model defining the structure of routing rules, directly used in the add_routing_rule handler to instantiate new rules.
    class RoutingRule(BaseModel):
        keywords: List[str]
        agent_name: str
        priority: int = 1
        description: str = ""
  • Registers all router tools, including 'add_routing_rule', by calling register_router_tools during ACPMCPServer initialization in _register_all_tools method.
    register_router_tools(self.mcp, self.router)
  • The registration function that defines and registers the add_routing_rule tool (and others) with the FastMCP instance using @mcp.tool() decorators.
    def register_router_tools(mcp: FastMCP, router: AgentRouter):
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal information. It states the tool adds a rule but doesn't cover permissions needed, whether it's idempotent, what happens on conflicts, or the response format. For a mutation tool with zero annotation coverage, this is inadequate.

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 with zero wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly, which is ideal for conciseness.

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

Completeness2/5

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

Given the tool has 5 parameters with 0% schema coverage, no annotations, and involves mutation (adding rules), the description is incomplete. It doesn't explain parameter meanings, behavioral traits, or usage context, and while an output schema exists, the description lacks even basic operational details needed for effective use.

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 all 5 parameters lack documentation in the schema. The description adds no parameter semantics beyond implying 'strategy_name' is a target and 'keywords' and 'agent_name' are involved. It doesn't explain what 'priority' means, what format 'keywords' uses, or how 'description' is applied, failing to compensate for the coverage gap.

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 action ('add a new routing rule') and target resource ('to a strategy'), which is specific and unambiguous. However, it doesn't differentiate this tool from sibling tools like 'list_routing_strategies' or 'smart_route_request', which would require explicit comparison to earn a 5.

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. It doesn't mention prerequisites (e.g., existing strategies), exclusions, or how it relates to sibling tools like 'list_routing_strategies' or 'smart_route_request', leaving the agent with no contextual usage information.

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