Skip to main content

𝔐  mpc-openai  ✧

MCP Client with OpenAI compatible API

Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications.

— https://modelcontextprotocol.io


[!WARNING] This project is still in the early stages of development. Support is not planned.

This is a MCP client (not a server). It is meant to be used as a library for building LLMs UI that support MCP through an OpenAI compatible API. This opens the door to locally runnable inference engines (vLLM, Ollama, TGI, llama.cpp, LMStudio, ...) that support providing support for the OpenAI API (text generation, function calling, etc.).

Usage

It is highly recommended to use uv in your project based on mpc-openai:

  • It manages python installation and virtual environment.
  • It is an executable that can run self-contained python scripts (in our case MCP server)
  • It is used for CI workflows.

Add mcp-openai to your project dependencies with:

uv add mcp-openai

or use classic pip install.

Create a MCP client

Now you can create a MCP client by specifying your custom configuration.

from mcp_openai import MCPClient
from mcp_openai import config

mcp_client_config = config.MCPClientConfig(
    mcpServers={
        "the-name-of-the-server": config.MCPServerConfig(
            command="uv",
            args=["run", "path/to/server/scripts.py/or/github/raw"],
        )
        # add here other servers ...
    }
)

llm_client_config = config.LLMClientConfig(
    api_key="api-key-for-auth",
    base_url="https://api.openai.com/v1",
)

llm_request_config = config.LLMRequestConfig(model=os.environ["MODEL_NAME"])

client = MCPClient(
    mcp_client_config,
    llm_client_config,
    llm_request_config,
)

Connect and process messages with MCP client

async def main():

    # Establish connection between the client and the server.
    await client.connect_to_server(server_name)

    # messages_in are coming from user interacting with the LLM
    # e.g. UI making use of this MCP client.
    messages_in = ...
    messages_out = await client.process_messages(messages_in)

    # messages_out contains the LLM response. If required, the LLM make use of
    # the available tools offered by the connected servers.

Metadata

Release files for mcp-openai 0.2.0

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-openai 0.2.0
File Size Uploaded Provenance
mcp_openai-0.2.0.tar.gz 24.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-openai 0.2.0
File Interpreter ABI Platform
mcp_openai-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.5 kB

Release files / mcp_openai-0.2.0.tar.gz

Download URL mcp_openai-0.2.0.tar.gz
Size 24.7 kB
Tags Source
SHA-256 checksum
How to use checksums
56d7a726ea796ba25240a16b304b1ea1827c110f39c400cd083037d9c717061e
BLAKE2b-256 checksum
How to use checksums
2b87149904ffeb5032af4144f9df7f58f60036daf01376178edb412f7d2d9629
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.11

Release files / mcp_openai-0.2.0-py3-none-any.whl

Download URL mcp_openai-0.2.0-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e8ae6717f315230fb09c8306523af3cc905198f5cefd2c911f4e132faac85396
BLAKE2b-256 checksum
How to use checksums
de278f4b0d9cb16a6e05155c549b7f48ba96476ab94d8ec4d7c31c58a093d3d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.11

Security for mcp-openai 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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