mcp_client
Connect to MCP servers, call their tools, and manage connections within Strands agents for testing and integration purposes.
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.
Args: action: Action to perform - "connect", "disconnect", "list_tools", "call_tool", "list_connections" connection_id: Unique identifier for this connection transport: Transport type - "http", "stdio", or "sse" server_url: URL for HTTP/SSE transport (e.g., "http://localhost:8000/mcp") command: Command for stdio transport (e.g., "python") args: Arguments for stdio command (e.g., ["mcp_server_stdio.py"]) tool_name: Name of tool to call (for call_tool action) tool_args: Arguments to pass to tool (for call_tool action)
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" )
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) |