execute_agent
Execute a Strands agent by providing an agent name and prompt, enabling integration with Amazon Q and MCP-compatible systems for task automation and workflow enhancement.
Instructions
Execute an agent with a given prompt
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_name | Yes | The name of the agent to execute | |
| prompt | Yes | The prompt to execute the agent with |
Implementation Reference
- src/strands_agent_mcp/server.py:30-38 (handler)The execute_agent tool handler function. It is registered via the @mcp.tool decorator, with input schema defined using Annotated and Field for agent_name and prompt parameters. The function retrieves the agent from the registry, executes it with the prompt, and returns the result message as a string.@mcp.tool(description="Execute an agent with a given prompt") def execute_agent(agent_name: Annotated[str, Field(description="The name of the agent to execute")], prompt: Annotated[str, Field(description="The prompt to execute the agent with")]) -> str: """ Execute an agent with the provided name and prompt, return its response """ agent = agent_registry.get(agent_name) result = agent.agent(prompt) return str(result.message)