# mcp-client

> MCP Client

This repository provides a REST API and CLI client for interacting with Model Context Protocol (MCP) servers, leveraging LangChain for LLM prompts and supporting various LLM providers. It enables collaboration

## Overview

- **Category:** AI
- **Language:** Python
- **Stars:** 49
- **Forks:** 11
- **Owner:** rakesh-eltropy
- **GitHub:** https://github.com/rakesh-eltropy/mcp-client
- **Created:** 2024-12-04T15:32:29+00:00
- **Updated:** 2025-03-27T12:19:46+00:00
- **Source:** https://model-context-protocol.com/clients/mcp-client-rest-api-llm-interaction

## Setup

## Setup

1. Clone the repository:
   ```bash
   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:
   ```bash
   cd mcp-client
   ```
   
3. Set the OPENAI_API_KEY environment variable:
   ```bash
   export OPENAI_API_KEY=your-openai-api-key
   ```
   You can also set the `OPENAI_API_KEY` in the [mcp-server-config.json](mcp-server-config.json) file.

   You can also set the `provider` and `model` in the [mcp-server-config.json](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:
   ```bash
   export BRAVE_API_KEY=your-brave-api-key
   ```
   You can also set the `BRAVE_API_KEY` in the [mcp-server-config.json](mcp-server-config.json) file.
   You can get the free `BRAVE_API_KEY` from [Brave Search API](https://brave.com/search/api/).

5. Running from the CLI:
   ```bash
   uv run cli.py
   ```
   To explore the available commands, use the `help` option; you can chat with LLM using `chat` command.
   Sample prompts:
   ```bash
     What is the capital city of India?
    ```
   ```bash
     Search the most expensive product from database and find more details about it from amazon?
    ```

6. Running from the REST API:
   ```bash
   uvicorn app:app --reload
   ```
   You can use the following curl command to chat with llm:
   ```bash
   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:
   ```bash
   curl -X POST -H "Content-Type: application/json" -d '{"message": "list all the products from my local database?", "streaming": true}' http://localhost:8000/chat
   ```

## Tools

## Available Tools

1.  MCP-Compatible Servers (Supports any [MCP-compatible servers](https://github.com/punkpeye/awesome-mcp-servers) servers).
2.  Pre-configured default servers (SQLite and Brave Search).
3.  Additional MCP servers (Can be added in the [mcp-server-config.json](mcp-server-config.json) file).
4.  Integrated with LangChain (Leverages LangChain to execute LLM prompts).
5.  Collaboration of multiple MCP servers (Enables multiple MCP servers to collaborate and respond to a specific query simultaneously).
6.  LLM Provider Support (Compatible with any LLM provider that supports APIs with function capabilities).
7.  CLI client (Allows interaction with MCP servers from the command line).
8.  REST API (Provides an interface to interact with MCP servers programmatically).
