Model Context Protocol CLI
- other
About
What is Model Context Protocol CLI?
Model Context Protocol CLI is a command-line client that communicates with an MCP (Model Context Protocol) server, enabling users to send commands, query data, and interact with server resources. It runs on any system with Python 3.8+ and is designed for developers working with MCP-based services.
How to use Model Context Protocol CLI?
Clone the repository, install UV with pip install uv, then run uv sync --reinstall to install dependencies. Start the client with uv run mcp-cli --server sqlite, optionally specifying a JSON configuration file (--config-file), provider (--provider openai or --provider ollama), and model (--model). Use interactive commands like help, chat, list-tools, and list-resources.
Key features of Model Context Protocol CLI
- Protocol-level communication with any MCP server.
- Dynamic exploration of tools, resources, and prompts.
- Support for OpenAI and Ollama providers.
- Interactive and chat modes for live queries.
- Configurable via command-line arguments and JSON files.
Use cases of Model Context Protocol CLI
- Query a SQLite database through an MCP server interactively.
- Explore available tools and resources exposed by an MCP server.
- Integrate with multiple AI model providers (OpenAI, Ollama) for context-based interactions.
FAQ from Model Context Protocol CLI
What prerequisites are needed to run Model Context Protocol CLI?
Python 3.8 or higher. If using OpenAI, set the OPENAI_API_KEY environment variable. If using Ollama, have Ollama installed and running.
Which providers and models are supported?
OpenAI (default model: gpt-4o) and Ollama (default model: llama3.2, also listed as qwen2.5-coder in the README). You can specify a custom model with the --model flag.
How do I set up the OpenAI provider?
Set the OPENAI_API_KEY environment variable (e.g., in a .env file or system variable) before running the client, then use --provider openai.
What is the default model for the Ollama provider?
The default model for Ollama is llama3.2 (the README also mentions qwen2.5-coder earlier; the CLI uses llama3.2 per the usage examples).
Is this project open source?
Yes, it is licensed under the MIT License.
Details
- Author
- shahshrey
- GitHub stars
- 1
- Category
- other
- Repository
- shahshrey/universal-mcp-ui
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 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.
- --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 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
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
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.
