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 handlerPrompt— a prompt template with argumentsResource— a readable data sourceExecHandler— runs a command on the machineHttpHandler— calls a local HTTP endpointMcpDefinitions— container for tools, prompts, and resources
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31811fa999e3a7c702baec67101206197be39353c729a7008a07e2cf8d4432af
|
|
| MD5 |
06d3622d397b96a48427a58ec50b9153
|
|
| BLAKE2b-256 |
383c66b9a3e57a91ceb18ac773f4c82ff0c4791089d5963668792e891d16e987
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
charmlibs_interfaces_mcp-0.1.2.tar.gz -
Subject digest:
31811fa999e3a7c702baec67101206197be39353c729a7008a07e2cf8d4432af - Sigstore transparency entry: 1050034781
- Sigstore integration time:
-
Permalink:
tonyandrewmeyer/mcp-server-operator@c378891f1bb69703590bed2c0d7b9134c4336a10 -
Branch / Tag:
refs/tags/charmlib/v0.1.2 - Owner: https://github.com/tonyandrewmeyer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-charmlib.yaml@c378891f1bb69703590bed2c0d7b9134c4336a10 -
Trigger Event:
push
-
Statement type:
File details
Details for the file charmlibs_interfaces_mcp-0.1.2-py3-none-any.whl.
File metadata
- Download URL: charmlibs_interfaces_mcp-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37abde76b9854b36ddbdbfb60ebb918644d50ade19135d36f89cdcfcb9ecce41
|
|
| MD5 |
c3e34020ce3a687b8b8091f20a4efd14
|
|
| BLAKE2b-256 |
a1bdbb79f9fe0117038dc88bfeae3fb1bbe75c42aabe8b5a90ffc38d149499d1
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
charmlibs_interfaces_mcp-0.1.2-py3-none-any.whl -
Subject digest:
37abde76b9854b36ddbdbfb60ebb918644d50ade19135d36f89cdcfcb9ecce41 - Sigstore transparency entry: 1050034858
- Sigstore integration time:
-
Permalink:
tonyandrewmeyer/mcp-server-operator@c378891f1bb69703590bed2c0d7b9134c4336a10 -
Branch / Tag:
refs/tags/charmlib/v0.1.2 - Owner: https://github.com/tonyandrewmeyer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-charmlib.yaml@c378891f1bb69703590bed2c0d7b9134c4336a10 -
Trigger Event:
push
-
Statement type: