Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

MCP LLM client

alt text

License: MIT Version Last commit Commit activity Stars Forks Watchers Contributors

Python client, based on "mcp[cli]", for connecting to MCP servers through multiple protocols, specifically designed to work with integrated language models.

Table of Contents

Overview

This package provides a Python interface to connect to MCP servers in an easy, intuitive, and configurable way. It offers a modular architecture that allows for easy extension of new transfer protocols and language models. Currently includes support for HTTPStream and GPT-4 mini, with expansion capability for more options in the future.

Installation

To install the MCP client, you can use pip:

pip install mcp-llm-client

Implemented Models

The client currently supports the following language models:

Model Technical Description
gpt4o-mini Optimized implementation of the GPT-4 model that provides a balance between computational performance and resource efficiency. This model is specifically designed to operate in environments with memory constraints while maintaining superior predictive quality.

🚨 CRITICAL CONFIGURATION NOTE Currently, this project only work with gpt4o-mini llm model.

Implemented Transfer Protocols

Protocols for communication with MCP servers:

Protocol Status Technical Characteristics
HTTPStream Implemented Asynchronous HTTP-based protocol that enables continuous data streaming. Characterized by low memory consumption and real-time processing capability for partial responses.
SSE (Server-Sent Events) Not Implemented Unidirectional protocol that allows the server to send multiple updated events through a single HTTP connection. Designed specifically for applications requiring real-time updates from the server.
stdio Not Implemented Standard input/output interface that facilitates direct communication between processes. Will provide a lightweight alternative for local environments and unit testing.

🚨 CRITICAL CONFIGURATION NOTE Currently, this project only work with HTTPStream protocol.

Future Development Planning

Pending Language Models

  • Integration of additional language models
  • Implementation of dynamic model selection system
  • Optimization of model loading and management

Pending Protocols

  • Complete implementation of SSE for better real-time event handling
  • Development of stdio interface for local environments
  • Performance optimization across all protocols

System Requirements

Environmental Configuration

  • .env file: The .env file contains the authentication credentials necessary for integration with external services. This file must be created in the project root directory with the following format:

    # .env
    # OpenAI Authentication
    OPENAI_API_KEY=<YOUR OPENAI-API-KEY>
    
  • config.json file: The config.json file defines the configuration of available MCP servers. It must be created in the project root directory with the following structure:

    {
        "app_name": "mcp-llm-client",
        "mcp_servers": {
            "example_public_server": {
                "transport": "httpstream",
                "httpstream-url": "http://127.0.0.1:8000/public-example-server/mcp",
                "name": "example-public-server",
                "description": "Example public server."
            },
            "example_private_mcp": {
                "transport": "httpstream",
                "httpstream-url": "http://127.0.0.1:8000/private-example-server/mcp",
                "name": "example-private-server",
                "description": "Example private server with oauth required.",
                "auth": {
                    "required": true,
                    "post_body": {
                        "username": "user",
                        "password": "password"
                    }
                }
            },
            "github": {
                "transport": "httpstream",
                "httpstream-url": "https://api.githubcopilot.com/mcp",
                "name": "github",
                "description": "This server specializes in github operations.",
                "auth": {
                    "required": false,
                    "post_body": null
                },
                "headers": {
                    "Authorization": "Bearer {access_token}"
                }
            }
        }
    }
    

    If you need an MCP server to test the code, you can use simple-mcp-server.

Dependencies

  • Python = ">=3.11"
  • openai = "^1.68.2"
  • mcp[cli]
  • mcp-oauth

Usage Example

#example1.py
from mcpclient import open_local_chat
open_local_chat()
#example2.py
from mcpclient import Chat
chat: Chat = Chat()
while True:
    query = input("> ")
    if query == "":
        break
    for step in chat(query):
        print(f"<< {step.json}")

Alternatively, you may test this service using the following template available on GitHub:

# clone repo
git clone https://github.com/rb58853/template_mcp_llm_client.git

# change to project dir
cd template_mcp_llm_client

# install dependencies
pip install -r requirements.txt

# open in vscode
code .

Version History

Last Version Features

  • 💬 Fully functional chat by passing a query; see Chat.
  • ⚙️ Integration with Tools, Resources, and Prompts from MCP servers, achieving a well-integrated client workflow with each of these services.
  • 🔐 Simple authentication system using mcp-oauth and this environmental configuration. Also integrate headers authorization.
  • 👾 OpenAI GPT as an integrated LLM using the model "gpt4o-mini".
  • 📡 Support for the httpstream transport protocol.
  • 💻 Easy console usage via open_local_chat(); see example1 for the use case.

See more in changelog

Project Status

⚠️ Important Notice: This project is currently in active development phase. As a result, errors or unexpected behaviors may occur during usage

License

MIT License. See license.

Metadata

Release files for mcp-llm-client 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-llm-client 0.1.2
File Size Uploaded
mcp_llm_client-0.1.2.tar.gz 17.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-llm-client 0.1.2
File Interpreter ABI Platform
mcp_llm_client-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 38.3 kB

Release files / mcp_llm_client-0.1.2.tar.gz

Download URL mcp_llm_client-0.1.2.tar.gz
Size 17.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3b8cba2a0d1374092b321eb8c99fcff0b1c35b81bbf433c601816f789c464119
BLAKE2b-256 checksum
How to use checksums
23be8083e6df2ea75b9cdff855fd79ad86b05e7cbcbbf1427484af385fc4d344
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / mcp_llm_client-0.1.2-py3-none-any.whl

Download URL mcp_llm_client-0.1.2-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5e3134843893ec73715a389c28ba9f4745a77b4ec18611544f14c087fff677e
BLAKE2b-256 checksum
How to use checksums
2f5baf242b0a8d1c278d5b94dd97279d5c56cfd9b3ab82a88ec23f78cc558d10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page