Model Context Protocol CLI
- agent-framework
About
What is Model Context Protocol CLI?
The Model Context Protocol CLI is a protocol-level command-line client that interacts with an MCP (Model Context Protocol) server. It lets users send commands, query data, and explore server resources. It runs on any system with Python 3.8+ and the UV package manager. It is intended for developers and technical users who need direct, scriptable access to MCP servers.
How to use Model Context Protocol CLI?
1. Clone the repository and install UV (pip install uv).
2. Run uv sync --reinstall inside the cloned directory.
3. Start the client with uv run mcp-cli --server <server> (e.g., sqlite).
4. Pass optional arguments for provider (--provider openai or ollama), model (--model), config file (--config-file), or use all servers (--all).
5. Once running, type chat to enter interactive chat mode, or use commands like ping or list-tools directly.
Key features of Model Context Protocol CLI
- Protocol-level communication with an MCP server.
- Dynamic tool, resource, and prompt exploration.
- Support for OpenAI and Ollama providers.
- Default models: gpt-4o-mini (OpenAI) and llama3.2 (Ollama).
- Interactive chat mode with tool invocation.
- Configurable via JSON file and command‑line arguments.
Use cases of Model Context Protocol CLI
- Querying data from an MCP‑enabled SQLite server.
- Discovering and inspecting available tools and resources.
- Interacting with multiple MCP servers concurrently (e.g., SQLite + Exa + filesystem).
- Building automated workflows that chain MCP commands.
- Testing and debugging MCP server implementations.
FAQ from Model Context Protocol CLI
What does Model Context Protocol CLI do?
It is a command-line client for MCP servers that allows you to send commands, query resources, and use tools—either interactively or via scripted commands.
What providers and models are supported?
Two providers: OpenAI (default model gpt-4o-mini) and Ollama (default model llama3.2). You can override the model with the --model flag.
How do I install Model Context Protocol CLI?
Clone the repository, install UV (pip install uv), then run uv sync --reinstall in the cloned directory. No additional system dependencies are required beyond Python 3.8+.
What commands are available?
ping, list-tools, list-resources, list-prompts, chat, clear, help,
Details
- Author
- sansan4ez
- Category
- agent-framework
- Repository
- sansan4ez/mcp-cli
Model Context Protocol CLI
This repository contains a protocol-level CLI designed to interact with a Model Context Protocol server. The client allows users to send commands, query data, and interact with various resources provided by the server.Features
- Protocol-level communication with the MCP Server. - Dynamic tool and resource exploration. - Support for multiple providers and models: - Providers: OpenAI, Ollama. - Default models:gpt-4o-mini for OpenAI, qwen2.5-coder for Ollama.
Prerequisites
- Python 3.8 or higher. - Required dependencies (see Installation) - If using ollama you should have ollama installed and running. - If using openai you should have an api key set in your environment variables (OPENAI_API_KEY=yourkey)Installation
1. Clone the repository:git clone https://github.com/chrishayuk/mcp-cli
cd mcp-cli
2. Install UV:
pip install uv
3. Resynchronize dependencies:
uv sync --reinstall
Usage
To start the client and interact with the SQLite server, run the following command:uv run mcp-cli --server sqlite
Command-line Arguments
---server: Specifies the server configuration to use. Required.
- --config-file: (Optional) Path to the JSON configuration file. Defaults to server_config.json.
- --all: (Optional) Use all the servers provided in the config
- --provider: (Optional) Specifies the provider to use (openai or ollama). Defaults to openai.
- --model: (Optional) Specifies the model to use. Defaults depend on the provider:
- gpt-4o-mini for OpenAI.
- llama3.2 for Ollama.
Examples
Run the client with the default OpenAI provider and model:uv run mcp-cli --server sqlite
Run the client with a specific configuration and Ollama provider:
uv run mcp-cli --server sqlite --provider ollama --model llama3.2
Run the client with the default OpenAI provider and model, with all the servers in the config provided:
uv run mcp-cli --config "path to your server_config.json" --all
Interactive Mode
The client supports interactive mode, allowing you to execute commands dynamically. Typehelp for a list of available commands or quit to exit the program.
Supported Commands
-ping: Check if the server is responsive.
- list-tools: Display available tools.
- list-resources: Display available resources.
- list-prompts: Display available prompts.
- chat: Enter interactive chat mode.
- clear: Clear the terminal screen.
- help: Show a list of supported commands.
- quit/exit: Exit the client.
Chat Mode
To enter chat mode and interact with the server:uv run mcp-cli --server sqlite
or for multiple servers:
uv run mcp-cli --server sqlite --server exa --server filesystem --server sequential-thinking --server memory
and then use 'chat' command to enter chat mode.
In chat mode, you can use tools and query the server interactively. The provider and model used are specified during startup and displayed as follows:
Entering chat mode using provider 'ollama' and model 'llama3.2'...
Using OpenAI Provider:
If you wish to use openai models, you should- set the OPENAI_API_KEY environment variable before running the client, either in .env or as an environment variable.
