Skip to main content
Glama

invoke_agent

Process complex queries requiring reasoning across multiple tools or conversational responses by invoking the full agent with natural language prompts.

Instructions

Invoke the full strands-mcp-cli agent with a natural language prompt. Use this for complex queries that require reasoning across multiple tools or when you need a conversational response from the agent.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesThe prompt or query to send to the agent

Implementation Reference

  • Handler logic within the MCP call_tool function that creates a fresh agent instance, invokes it with the provided prompt, and returns the response as TextContent.
    if name == "invoke_agent" and expose_agent:
        prompt = arguments.get("prompt")
        if not prompt:
            return [
                types.TextContent(
                    type="text",
                    text="❌ Error: 'prompt' parameter is required",
                )
            ]
    
        logger.debug(f"Invoking agent with prompt: {prompt[:100]}...")
    
        # Get the parent agent's configuration
        # Access tools directly from registry dictionary
        tools_for_invocation = [
            agent.tool_registry.registry[tool_name]
            for tool_name in agent_tools.keys()
            if tool_name in agent.tool_registry.registry
        ]
    
        # Prepare extra kwargs for observability and callbacks
        extra_kwargs = {}
        if hasattr(agent, "callback_handler") and agent.callback_handler:
            extra_kwargs["callback_handler"] = agent.callback_handler
    
        # Create fresh agent with same configuration but clean message history
        # Inherits: model, tools, trace_attributes, callback_handler
        fresh_agent = Agent(
            name=f"{agent.name}-invocation",
            model=agent.model,
            messages=[],  # Empty message history (clean state)
            tools=tools_for_invocation,
            system_prompt=agent.system_prompt if hasattr(agent, "system_prompt") else None,
            trace_attributes=agent.trace_attributes if hasattr(agent, "trace_attributes") else {},
            **extra_kwargs,
        )
    
        # Call the fresh agent
        result = fresh_agent(prompt)
    
        # Extract text response from agent result
        response_text = str(result)
    
        logger.debug(f"Agent invocation complete, response length: {len(response_text)}")
    
        return [types.TextContent(type="text", text=response_text)]
  • Defines the MCP Tool schema for 'invoke_agent', including name, description, and input schema requiring a 'prompt' parameter.
    agent_invoke_tool = types.Tool(
        name="invoke_agent",
        description=(
            f"Invoke the full {agent.name} agent with a natural language prompt. "
            "Use this for complex queries that require reasoning across multiple tools "
            "or when you need a conversational response from the agent."
        ),
        inputSchema={
            "type": "object",
            "properties": {
                "prompt": {
                    "type": "string",
                    "description": "The prompt or query to send to the agent",
                }
            },
            "required": ["prompt"],
        },
    )
    mcp_tools.append(agent_invoke_tool)
  • Registers the list_tools handler that includes the 'invoke_agent' tool in the returned list of available tools when expose_agent is True.
    @server.list_tools()
    async def list_tools() -> list[types.Tool]:
        """Return list of available MCP tools.
    
        This handler is called when MCP clients request the available tools.
        It returns the pre-built list of MCP Tool objects converted from
        Strands agent tools.
        """
        logger.debug(f"list_tools called, returning {len(mcp_tools)} tools")
        return mcp_tools
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. It mentions the tool invokes an agent for complex reasoning and conversational responses, but lacks details on behavioral traits such as execution time, error handling, authentication needs, or rate limits. This is a significant gap for a tool that likely involves significant processing.

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 appropriately sized and front-loaded, with two clear sentences that efficiently convey purpose and usage without any wasted words. Every sentence earns its place by providing essential information.

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's complexity (invoking an agent for reasoning) and lack of annotations or output schema, the description is moderately complete. It covers the high-level purpose and usage but lacks details on behavior, response format, or error conditions, leaving gaps for an agent to understand full implications.

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

Parameters3/5

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

The input schema has 100% description coverage, with the 'prompt' parameter well-documented. The description adds minimal value beyond the schema, only implying that the prompt should be 'natural language' for complex queries, which is somewhat redundant. Baseline 3 is appropriate as the schema does the heavy lifting.

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: 'Invoke the full strands-mcp-cli agent with a natural language prompt.' It specifies the action (invoke) and resource (agent), though it doesn't explicitly distinguish it from sibling tools like 'greet' or 'mcp_client' beyond mentioning 'complex queries' and 'conversational response.'

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool: 'for complex queries that require reasoning across multiple tools or when you need a conversational response from the agent.' It gives specific scenarios but does not explicitly state when not to use it or name alternatives among siblings.

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

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/cagataycali/strands-mcp-server'

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