Skip to main content

Charm library for the MCP (Model Context Protocol) Juju interface

Project description

charmlibs-interfaces-mcp

Charm library for the MCP (Model Context Protocol) Juju interface.

Provides McpProvider and McpRequirer classes that charm authors can use to integrate with the mcp relation interface.

Installation

pip install charmlibs-interfaces-mcp

Usage

Provider (principal charm)

import ops
from charmlibs.interfaces.mcp import McpProvider, McpDefinitions, Tool, ExecHandler

class MyCharm(ops.CharmBase):
    def __init__(self, framework):
        super().__init__(framework)
        self.mcp = McpProvider(self, "mcp")
        framework.observe(self.on.mcp_relation_joined, self._on_mcp_joined)

    def _on_mcp_joined(self, event):
        self.mcp.set_definitions(McpDefinitions(
            tools=[
                Tool(
                    name="list-files",
                    description="List files in a directory",
                    input_schema={
                        "type": "object",
                        "properties": {
                            "dir": {"type": "string", "description": "Directory path"},
                        },
                        "required": ["dir"],
                    },
                    handler=ExecHandler(command=["ls", "-la", "{{dir}}"]),
                ),
            ],
        ))

Requirer (mcp-server charm)

import ops
from charmlibs.interfaces.mcp import McpRequirer

class McpServerCharm(ops.CharmBase):
    def __init__(self, framework):
        super().__init__(framework)
        self.mcp = McpRequirer(self, "mcp")

    def _on_relation_changed(self, event):
        definitions = self.mcp.collect_definitions()
        # definitions = {"tools": [...], "prompts": [...], "resources": [...]}

Data models

All models are plain dataclasses (no pydantic):

  • Tool — an MCP tool with name, description, input_schema, and handler
  • Prompt — a prompt template with arguments
  • Resource — a readable data source
  • ExecHandler — runs a command on the machine
  • HttpHandler — calls a local HTTP endpoint
  • McpDefinitions — container for tools, prompts, and resources

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

charmlibs_interfaces_mcp-0.1.2.tar.gz (37.0 kB view details)

Uploaded Source

Built Distribution

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

charmlibs_interfaces_mcp-0.1.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file charmlibs_interfaces_mcp-0.1.2.tar.gz.

File metadata

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

File hashes

Hashes for charmlibs_interfaces_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 31811fa999e3a7c702baec67101206197be39353c729a7008a07e2cf8d4432af
MD5 06d3622d397b96a48427a58ec50b9153
BLAKE2b-256 383c66b9a3e57a91ceb18ac773f4c82ff0c4791089d5963668792e891d16e987

See more details on using hashes here.

Provenance

The following attestation bundles were made for charmlibs_interfaces_mcp-0.1.2.tar.gz:

Publisher: publish-charmlib.yaml on tonyandrewmeyer/mcp-server-operator

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

File details

Details for the file charmlibs_interfaces_mcp-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for charmlibs_interfaces_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 37abde76b9854b36ddbdbfb60ebb918644d50ade19135d36f89cdcfcb9ecce41
MD5 c3e34020ce3a687b8b8091f20a4efd14
BLAKE2b-256 a1bdbb79f9fe0117038dc88bfeae3fb1bbe75c42aabe8b5a90ffc38d149499d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for charmlibs_interfaces_mcp-0.1.2-py3-none-any.whl:

Publisher: publish-charmlib.yaml on tonyandrewmeyer/mcp-server-operator

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