Installation
The CLI client is included with themcp-use package:
Quick Start
Connect to an MCP server and start using it:Command Structure
The CLI client uses scoped commands organized by resource type:- Connection Management:
connect,disconnect - Sessions:
sessions list,sessions switch - Tools:
tools list,tools call,tools describe - Resources:
resources list,resources read,resources subscribe,resources unsubscribe - Prompts:
prompts list,prompts get - Interactive Mode:
interactive
Connection Management
Connect to a Server
Connect to an HTTP MCP server:--name <name>: Session name (optional, auto-generated if not provided)--auth <token>: Authentication token for Bearer auth--stdio: Use stdio connector instead of HTTP (see below)
Connect to a Stdio Server
Connect to a server using stdio transport:--stdio is parsed as: command args...
Disconnect from a Server
Session Management
Sessions are automatically saved to~/.mcp-use/cli-sessions.json and can be restored later.
List Sessions
Switch Sessions
Working with Tools
List Available Tools
Describe a Tool
View detailed information about a tool including its input schema:Call a Tool
Execute a tool with arguments:- Arguments must be valid JSON
- If a tool requires arguments but none are provided, an error will show the schema
- Use single quotes around JSON to avoid shell escaping issues
Working with Resources
List Available Resources
Read a Resource
Subscribe to Resource Updates
Subscribe to notifications when a resource changes:Unsubscribe from Resource
Working with Prompts
List Available Prompts
Get a Prompt
Retrieve a prompt with arguments:Interactive Mode
Start an interactive REPL session for easier exploration:tools list- List available toolstools call <name>- Call a tool (will prompt for arguments)tools describe <name>- Show tool detailsresources list- List available resourcesresources read <uri>- Read a resourceprompts list- List available promptsprompts get <name>- Get a prompt (will prompt for arguments)sessions list- List all sessionsexitorquit- Exit interactive mode
Global Flags
All commands support these global flags:--session <name>: Use a specific session instead of the active one--json: Output results in JSON format--timeout <ms>: Request timeout in milliseconds (for tool calls and resource operations)
Session Storage
Sessions are stored in~/.mcp-use/cli-sessions.json:
- Change session names
- Update connection details
- Remove old sessions
Common Use Cases
Debugging an MCP Server
Working with Multiple Servers
Scripting with the CLI
Use the CLI in shell scripts:Testing Filesystem Server
Error Handling
The CLI provides helpful error messages:No Active Session
Tool Not Found
Invalid Arguments
Tips and Best practices
- Use Named Sessions: Always provide a
--namewhen connecting to make sessions easier to manage - Interactive Mode for Exploration: Use interactive mode when exploring a new server
- JSON Output for Scripts: Use
--jsonflag when using the CLI in scripts - Session Persistence: Sessions are saved automatically, so you can disconnect and reconnect later
- Multiple Terminals: You can have multiple terminal windows with different active sessions
Troubleshooting
Connection Issues
Problem: Can’t connect to HTTP server- The server is running
- The URL is correct
- The server supports HTTP/SSE transport
- Firewall isn’t blocking the connection
Stdio Server Issues
Problem: Stdio server fails to start Solution:- Ensure the command is available (
npx,node, etc.) - Check that the server package is installed or accessible
- Verify the arguments are correct
Session Not Found
Problem: Session disappeared after restart Solution: Sessions are stored in~/.mcp-use/cli-sessions.json. If deleted, you’ll need to reconnect.
Next Steps
- Learn about MCP Agents for programmatic access
- Explore Server Development to create your own MCP servers
- Check out Examples for more use cases