mcp_client
Test and interact with MCP servers by connecting via HTTP or stdio transport, listing available tools, and calling tools from within a Strands Agent.
Instructions
Test and interact with MCP servers.
This tool provides a complete MCP client implementation for testing and using MCP servers from within a Strands Agent.
Returns: Result dictionary with status and content
Examples: # Connect to HTTP server mcp_client( action="connect", connection_id="my-server", transport="http", server_url="http://localhost:8000/mcp" )
# Connect to stdio server
mcp_client(
action="connect",
connection_id="stdio-server",
transport="stdio",
command="python",
args=["mcp_server_stdio.py"]
)
# List tools from connection
mcp_client(action="list_tools", connection_id="my-server")
# Call a tool
mcp_client(
action="call_tool",
connection_id="my-server",
tool_name="calculator",
tool_args={"expression": "2 + 2"}
)
# List all connections
mcp_client(action="list_connections")
# Disconnect
mcp_client(action="disconnect", connection_id="my-server")Notes: - stdio transport: Server must be launchable as subprocess - HTTP transport: Server must be already running - Connections are maintained in global state for reuse
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to perform - "connect", "disconnect", "list_tools", "call_tool", "list_connections" | |
| connection_id | No | Unique identifier for this connection | |
| transport | No | Transport type - "http", "stdio", or "sse" | |
| server_url | No | URL for HTTP/SSE transport (e.g., "http://localhost:8000/mcp") | |
| command | No | Command for stdio transport (e.g., "python") | |
| args | No | Arguments for stdio command (e.g., ["mcp_server_stdio.py"]) | |
| tool_name | No | Name of tool to call (for call_tool action) | |
| tool_args | No | Arguments to pass to tool (for call_tool action) |