MCP REST API and CLI Client
- agent-framework
About
What is MCP REST API and CLI Client?
A simple REST API and CLI client to interact with Model Context Protocol (MCP) servers. It runs on any platform supporting Python and is designed for developers who want to query MCP‑compatible servers using natural language via a language model.
How to use MCP REST API and CLI Client?
Clone the repository, set the OPENAI_API_KEY and optionally BRAVE_API_KEY environment variables (or configure them in mcp-server-config.json), then run the CLI with uv run cli.py or start the REST API with uvicorn app:app --reload. Use the chat command or send a POST request to /chat to interact with LLMs and connected MCP servers.
Key features of MCP REST API and CLI Client
- Supports any MCP‑compatible server (SQLite, Brave Search pre‑configured)
- Integrates with LangChain for executing LLM prompts
- Enables multiple MCP servers to collaborate on a single query
- Works with any LLM provider offering a function‑based API
- Provides both a CLI and a REST API for flexible usage
- Customizable via the mcp-server-config.json configuration file
Use cases of MCP REST API and CLI Client
- Query a local SQLite database using natural language commands
- Combine database results with web search for enriched answers
- Ask general knowledge questions to an LLM via CLI or REST endpoint
FAQ from MCP REST API and CLI Client
What MCP servers are supported?
Any MCP‑compatible server can be used. The client comes pre‑configured with SQLite (using a sample test.db) and Brave Search.
How do I add additional MCP servers?
Add the server configuration to the mcp-server-config.json file located in the project root.
Which LLM providers can I use?
Any provider with a function‑based API is supported, including OpenAI, Claude, Gemini, AWS Nova, Groq, and Ollama. See the LangChain documentation for more options.
Can I run it as a REST API?
Yes. Start the server with uvicorn app:app --reload and send a POST request to http://localhost:8000/chat with a JSON body containing a message field.
Does it support streaming responses?
Yes. Add "streaming": true to the request body when using the REST API.
Details
- Author
- rakesh-eltropy
- GitHub stars
- 46
- Category
- agent-framework
- Repository
- rakesh-eltropy/mcp-client
MCP REST API and CLI Client
A simple REST API and CLI client to interact with Model Context Protocol (MCP) servers.
Key Features
1. MCP-Compatible Servers
- Supports any MCP-compatible servers servers. - Pre-configured default servers: - SQLite (test.db has been provided with sample products data) - Brave Search - Additional MCP servers can be added in the mcp-server-config.json file2. Integrated with LangChain
- Leverages LangChain to execute LLM prompts. - Enables multiple MCP servers to collaborate and respond to a specific query simultaneously.3. LLM Provider Support
- Compatible with any LLM provider that supports APIs with function capabilities. - Examples: - OpenAI - Claude - Gemini - AWS Nova - Groq - Ollama - Essentially all LLM providers are supported as long as they provide a function-based API. Please refer langchain documentation for more details.Setup
1. Clone the repository:
git clone https://github.com/rakesh-eltropy/mcp-client.git
2. Navigate to the Project Directory
After cloning the repository, move to the project directory:
cd mcp-client
3. Set the OPENAI_API_KEY environment variable:
export OPENAI_API_KEY=your-openai-api-key
You can also set the
OPENAI_API_KEY in the mcp-server-config.json file.
You can also set the provider and model in the mcp-server-config.json file.
e.g. provider can be ollama and model can be llama3.2:3b.
4.Set the BRAVE_API_KEY environment variable:
export BRAVE_API_KEY=your-brave-api-key
You can also set the
BRAVE_API_KEY in the mcp-server-config.json file.You can get the free
BRAVE_API_KEY from Brave Search API.
5. Running from the CLI:
uv run cli.py
To explore the available commands, use the
help option. You can chat with LLM using chat command.Sample prompts:
What is the capital city of India?
Search the most expensive product from database and find more details about it from amazon?
6. Running from the REST API:
uvicorn app:app --reload
You can use the following curl command to chat with llm:
curl -X POST -H "Content-Type: application/json" -d '{"message": "list all the products from my local database?"}' http://localhost:8000/chat
You can use the following curl command to chat with llm with streaming:
curl -X POST -H "Content-Type: application/json" -d '{"message": "list all the products from my local database?", "streaming": true}' http://localhost:8000/chat
Contributing
Feel free to submit issues and pull requests for improvements or bug fixes.