Skip to main content

mcpconn logo

mcpconn: The Missing Connector for AI

mcpconn is a Python library that provides a simple and efficient way to connect your applications to AI models using the Model Context Protocol (MCP). It acts as a wrapper around the mcp library, offering a streamlined client interface for seamless integration with various AI providers and transport protocols.

PyPI version License: MIT Documentation Tests Open In Colab

Table of Contents

✨ Features

  • Simplified Client Interface: A high-level MCPClient for easy interaction with MCP servers.
  • Multi-provider Support: Out-of-the-box support for Anthropic and OpenAI models. Note: OpenAI only supports remote MCP endpoints (not local/stdio/localhost). See: https://platform.openai.com/docs/guides/tools-remote-mcp
  • Flexible Transports: Connect to servers using STDIO, SSE, or Streamable HTTP. OpenAI only supports remote MCP endpoints.
  • Built-in Guardrails: Protect your application with content filtering, PII masking, and injection detection.
  • Conversation Management: Easily manage conversation history, context, and persistence.
  • Asynchronous by Design: Built with asyncio for high-performance, non-blocking I/O.
  • Extensible: Easily add new LLM providers, transports, or guardrails.

🚀 Getting Started

Installation

pip install mcpconn

Quick Start

Here's a simple example of how to use mcpconn to connect to an MCP server and interact with an AI model:

import asyncio
from mcpconn import MCPClient

async def main():
    # Connect to a local server using STDIO (Anthropic only)
    client = MCPClient(llm_provider="anthropic")
    await client.connect("examples/simple_server/weather_stdio.py")

    # ---
    # OpenAI usage example (remote MCP only):
    # client = MCPClient(llm_provider="openai")
    # await client.connect("https://mcp.deepwiki.com/mcp", transport="streamable_http")
    # ---

    # Note: OpenAI does NOT support local/stdio/localhost servers. See: https://platform.openai.com/docs/guides/tools-remote-mcp

    # Start a conversation
    conversation_id = client.start_conversation()
    print(f"Started conversation: {conversation_id}")

    # Send a message and get a response
    response = await client.query("give me list of tools provided")
    print(f"AI: {response}")

    # Disconnect from the server
    await client.disconnect()

if __name__ == "__main__":
    asyncio.run(main())

🧑‍💻 Examples

🟢 Run in Google Colab

Open In Colab

You can try mcpconn directly in your browser using our interactive Google Colab notebook. This notebook demonstrates:

  • Installing mcpconn and dependencies in Colab
  • Setting up your OpenAI API key using Colab's Secrets
  • Making basic queries to OpenAI models via MCP
  • Managing conversation state for contextual chat
  • Using built-in guardrails for safety

Colab Usage Tips:

  • Install dependencies with:
    !pip install mcpconn openai nest_asyncio
    
  • Set your OpenAI API key using the Colab sidebar (🔑 icon → add OPENAI_API_KEY as a secret).
  • The notebook is ready to run cell-by-cell, with code and explanations for each step.

📚 Documentation

For full details on all features and the complete API reference, please visit our documentation site.

🗺️ Roadmap

  • Add support for more LLM providers.
  • Implement a more comprehensive test suite.
  • Add more examples and tutorials.
  • Improve documentation and type hinting.

🤝 Contributing

Contributions are welcome! If you'd like to contribute to mcpconn, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and add tests.
  4. Ensure that the tests pass.
  5. Submit a pull request with a clear description of your changes.

📄 License

mcpconn is licensed under the MIT License.

⚠️ Disclaimer

This project is under active development and may undergo significant changes.

Code of Conduct

We are committed to providing a welcoming and inclusive environment for everyone. Please read and follow our Code of Conduct.

🛡️ Security

If you discover a security vulnerability, please report it to us by emailing 2796gaurav@gmail.com. We will address all reports promptly.

🌟 Showcase

Have you built something cool with mcpconn? Written an article or created a video? We'd love to see it! Please open a pull request to add your project to this list.

💬 Support

If you have questions or need help, please open an issue in the issue tracker.

Metadata

Release files for mcpconn 0.1.3

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

Source distribution (sdist)

Source distribution for mcpconn 0.1.3
File Size Uploaded Provenance
mcpconn-0.1.3.tar.gz 63.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mcpconn 0.1.3
File Interpreter ABI Platform
mcpconn-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 81.9 kB

Release files / mcpconn-0.1.3.tar.gz

Download URL mcpconn-0.1.3.tar.gz
Size 63.2 kB
Tags Source
SHA-256 checksum
How to use checksums
59a083700f2a1b38c2d2af4c280fb3c338b357a2d4054636876d54d9f10a6ea8
BLAKE2b-256 checksum
How to use checksums
0bf7275b9eea0dd2cb66634bb309c550ee640eb1200518d75a60dce3d367815b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.5

Release files / mcpconn-0.1.3-py3-none-any.whl

Download URL mcpconn-0.1.3-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0353b7f81dabcb3127f41de1fb5425b1b4a50fec98581e4d8593cfc12ff9ff6f
BLAKE2b-256 checksum
How to use checksums
159e5208b11378b1d067f6df350f7704868432f80c7e24ae0e2eb031a06a7e42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.5

Security for mcpconn 0.1.3

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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