MCP-CLI is a command-line tool for interacting with and testing Model Context Protocol (MCP) servers. It provides a user-friendly terminal user interface (TUI) for selecting and executing tools offered by an MCP server.
- Multiple Transports: Connect to MCP servers using
stdio,sse(Server-Sent Events), orhttp(streamable HTTP). - Interactive TUI: A terminal user interface built with
bubbleteathat allows you to:- Select a tool from a list of available tools.
- Browse and query MCP resources.
- Enter arguments for the selected tool in a form.
- View the results of the tool execution.
- Resource Browser: A new tab in the TUI for listing and querying MCP resources.
- Prompt Browser: A new tab in the TUI for listing MCP prompts.
- Debug Panel: A scrollable debug panel on the right side of the TUI that shows:
- Informational logs (key presses, state changes).
- The arguments sent to the tool in a pretty-printed JSON format.
- The results of tool calls.
- Verbose Logging: Use the
-vflag to enable verbose logging to adebug.logfile for troubleshooting.
You can install mcp-cli using go install:
go install mcp-cliAlternatively, you can build it from source.
- Clone the repository:
git clone <repository-url> cd mcp-cli
- Build the executable:
This will create an
go build
mcp-cliexecutable in the current directory.
The mcp-cli tool has three main commands, one for each transport protocol.
Connect to an MCP server that communicates over standard input/output.
mcp-cli stdio --env "VAR=value" --env "ANOTHER_VAR=another_value" "<command-to-start-server>"The --env (or -e) flag can be used multiple times to pass environment variables to the server process.
Example:
mcp-cli stdio -e "API_KEY=12345" "python /path/to/mcp/server.py"Connect to an MCP server that uses Server-Sent Events (SSE).
mcp-cli sse --header "Header-Name: header-value" <server-url>The --header (or -H) flag can be used multiple times to pass custom HTTP headers to the server.
Example:
mcp-cli sse -H "Authorization: Bearer my-token" http://localhost:8080/mcpConnect to an MCP server that uses streamable HTTP.
mcp-cli http --header "Header-Name: header-value" <server-url>The --header (or -H) flag can be used multiple times to pass custom HTTP headers to the server.
Example:
mcp-cli http -H "Authorization: Bearer my-token" http://localhost:8080/mcp-v,--verbose: Enable verbose logging todebug.log.
When you connect to an MCP server, you will be presented with a terminal user interface.
- Tool Selection View: A list of available tools. Use the arrow keys to navigate and press
Enterto select a tool. Pressrto switch to the resource browser orpto switch to the prompt browser. - Resource Browser View: A list of available resources. Use the arrow keys to navigate and press
Enterto view the resource details. Presstto switch back to the tool selection view orpto switch to the prompt browser. - Prompt Browser View: A list of available prompts. Use the arrow keys to navigate. Press
tto switch back to the tool selection view orrto switch to the resource browser. - Argument Input View: A form for entering the arguments for the selected tool. Use
Tabto switch between fields andEnterto submit the tool call. - Resource Detail View: Shows the content of the selected resource. Press
Escto return to the resource list. - Debug Panel: The right-hand panel shows a scrollable log of events, tool calls, and results. Use the up and down arrow keys to scroll through the log.
- Navigation:
-
t: Switch to the tool selection view.
-
r: Switch to the resource browser view.
-
p: Switch to the prompt browser view.
-
Esc: Return to the previous view. -Ctrl+C: Exit the application.