Skip to main content

Python SDK for MCP Mesh — build distributed AI agents with auto-discovery, dependency injection, and LLM integration

Project description

MCP Mesh Python Runtime

Python runtime for the MCP Mesh service mesh framework.

Installation

pip install mcp-mesh

Quick Start

import mesh

# Import types from public API
from mesh.types import McpMeshTool

# Define your agent
@mesh.agent(name="hello-world", http_port=9090)
class HelloWorldAgent:
    """Hello World agent demonstrating MCP Mesh features."""
    pass

# Create a greeting function with dependency injection
@mesh.tool(
    capability="greeting",
    dependencies=["date_service"],
    description="Greeting function with date dependency injection"
)
def greet(name: str = "World", date_tool: McpMeshTool = None) -> str:
    """Greeting function with automatic dependency injection."""
    if date_tool is not None:
        try:
            current_date = date_tool()
            return f"Hello, {name}! Today is {current_date}"
        except Exception:
            pass

    return f"Hello, {name}!"

# The runtime auto-initializes when you import mcp_mesh
# Your functions are automatically registered with the mesh registry

Features

  • Automatic Registration: Functions are automatically registered with the Go registry
  • Health Monitoring: Built-in health checks and heartbeats
  • Dependency Injection: Inject dependencies into your functions
  • Service Discovery: Find and use other services in the mesh
  • Graceful Degradation: Works even if registry is unavailable

Configuration

The runtime can be configured via environment variables:

  • MCP_MESH_ENABLED: Enable/disable runtime (default: "true")
  • MCP_MESH_REGISTRY_URL: Registry URL (default: "http://localhost:8080")
  • MCP_MESH_AGENT_NAME: Custom agent name (auto-generated if not set)

API Architecture

MCP Mesh uses a clear separation between public and private APIs:

  • mesh - Public user API for decorators and types
  • _mcp_mesh - Private internal implementation (do not import directly)

The underscore prefix on _mcp_mesh follows Python conventions to indicate internal/private packages. Users should only import from the mesh package to ensure compatibility across versions.

Documentation

See the main repository for complete documentation.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

mcp_mesh-2.0.0.tar.gz (441.7 kB view details)

Uploaded Source

Built Distribution

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

mcp_mesh-2.0.0-py3-none-any.whl (523.0 kB view details)

Uploaded Python 3

File details

Details for the file mcp_mesh-2.0.0.tar.gz.

File metadata

  • Download URL: mcp_mesh-2.0.0.tar.gz
  • Upload date:
  • Size: 441.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mcp_mesh-2.0.0.tar.gz
Algorithm Hash digest
SHA256 6c9d29a3b3b26a137a9323d43106e8177f1be51636f3251de0565c28271c8ae7
MD5 a2c4f9bd76dd5b6712a6a5f872c0c37f
BLAKE2b-256 63f37f556241e5d9202b8a1a5b703315ce69d63cd399727ee0f2bb90014074fc

See more details on using hashes here.

File details

Details for the file mcp_mesh-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_mesh-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 523.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mcp_mesh-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 522362f448843ef833d4e900c6ad4f464ec2196d1ba4bd312f0f6e5f966b2008
MD5 a9ddad81e67409e9d45b2b2bc42f4724
BLAKE2b-256 a6b9a7d393c92fc0be21f20016728958773728e677952ba07dd3cfc553d27025

See more details on using hashes here.

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