Skip to main content

Standardizes external data access using the Model Context Protocol.

Project description

coreason-mcp

The Complete Gateway for the Model Context Protocol (MCP).

coreason-mcp serves as the Universal Interface Layer for the CoReason ecosystem. It replaces ad-hoc API wrappers with a standardized Model Context Protocol (MCP) Gateway, acting as an MCP Host that connects to both remote services (via SSE) and local sidecars (via Stdio).

Organization License Build Status Code Style: ruff Documentation

Installation

pip install coreason-mcp

Features

  • Hybrid Transport: Support for both SSE (remote microservices) and Stdio (local sidecars) transports.
  • Tool Aggregation: Merges tools from multiple servers into a unified namespace with automatic conflict resolution.
  • Secure Credential Injection: Manages API keys and headers securely in the transport layer, keeping them out of the agent's context.
  • Async/High Concurrency: Built on httpx and asyncio to ensure non-blocking operations across the mesh.
  • Robust Error Handling: Maps connection and protocol errors to standardized exceptions.

For detailed requirements and architecture, see Product Requirements.

Usage

Here is how to initialize and use the library to connect to a local filesystem tool and a remote database.

import asyncio
from coreason_mcp.config import McpServerConfig, TransportType
from coreason_mcp.manager import McpManager

# 1. Configure your servers (Mesh Topology)
# A local sidecar (Stdio) - e.g., for secure filesystem access
local_fs = McpServerConfig(
    name="local_fs",
    transport=TransportType.STDIO,
    command="npx",
    args=["-y", "@modelcontextprotocol/server-filesystem", "/home/user/docs"]
)

# A remote microservice (SSE) - e.g., for clinical data
clinical_db = McpServerConfig(
    name="clinical_db",
    transport=TransportType.SSE,
    url="http://db-service.internal:8080/sse",
    auth_headers={"Authorization": "Bearer s3cr3t-t0k3n"}
)

# 2. Initialize the manager
manager = McpManager([local_fs, clinical_db])

async def main():
    # 3. Connect to all servers
    await manager.connect_all()

    try:
        # 4. List aggregated tools (converted to OpenAI format)
        tools = await manager.get_openai_tools()
        print(f"Available tools: {[t['function']['name'] for t in tools]}")

        # 5. Call a tool
        # The manager handles routing and error mapping
        result = await manager.call_tool(
            tool_name="clinical_db_get_patient",
            arguments={"patient_id": "PT-12345"}
        )
        print("Result:", result.content[0].text)

    finally:
        # 6. Cleanup connections
        await manager.close()

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coreason_mcp-0.6.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coreason_mcp-0.6.0-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file coreason_mcp-0.6.0.tar.gz.

File metadata

  • Download URL: coreason_mcp-0.6.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for coreason_mcp-0.6.0.tar.gz
Algorithm Hash digest
SHA256 8e15a1cecb43818f635a84e912d98855b68fb8d73c43bdb6395ed6d653da22ae
MD5 8a17156c6eb4a241c66fa5b0c98b84c5
BLAKE2b-256 a814c8d8039508058ec7079b637fe3ec5063349f6895326473231ab976b9443e

See more details on using hashes here.

Provenance

The following attestation bundles were made for coreason_mcp-0.6.0.tar.gz:

Publisher: publish.yml on CoReason-AI/coreason-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file coreason_mcp-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: coreason_mcp-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for coreason_mcp-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8716f580ba70d0f76d4d44dffcdcc102ddfa8b426fbd98b520abf43b7934502e
MD5 5aea4532ea9863556aa6417e88c367bf
BLAKE2b-256 e1cec838a78caa48aca3068f81f063025f177d4504a4ed9849ac3eb0b7242eae

See more details on using hashes here.

Provenance

The following attestation bundles were made for coreason_mcp-0.6.0-py3-none-any.whl:

Publisher: publish.yml on CoReason-AI/coreason-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page