Pyjo.MCP - Model Context Protocol for Pyjoyment¶
import Pyjo.MCP
print(Pyjo.MCP.PROTOCOL_VERSION)
# Pyjoyment.Lite
from Pyjo.MCP.Server import Server
from Pyjoyment.Lite import *
server = Server(name='calculator', version='1.0.0')
@server.tool
def add(a: int, b: int) -> int:
"""Add two numbers."""
return a + b
plugin('AllowedHosts')
any('/mcp', server.to_action())
app.start()
Pyjo.MCP is the namespace of the Model Context Protocol for Pyjoyment, a server and a client
made with Pyjoyment, of the revision PROTOCOL_VERSION of the
specification, whose core is stateless: every request carries its version and
the capabilities of its client in its _meta, without a session.
Pyjo.MCP.Server is the server, whose tools, prompts, resources and
resource templates are Pyjo.MCP.Tool, Pyjo.MCP.Prompt,
Pyjo.MCP.Resource and Pyjo.MCP.ResourceTemplate objects,
Pyjo.MCP.Client is the client, Pyjo.MCP.Test tests a server
with its requests, and the messages are those of Pyjo.JSON.RPC.
See also¶
Pyjo.MCP.Server, Pyjo.MCP.Tool, Pyjo.MCP.Prompt,
Pyjo.MCP.Resource, Pyjo.MCP.ResourceTemplate,
Pyjo.MCP.Client, Pyjo.MCP.Test, Pyjoyment,
https://github.com/pyjoyment/Pyjoyment.
It is inspired by the distribution MCP of CPAN, built on Mojolicious.
- Pyjo.MCP.HEADER_MISMATCH = -32020¶
The code of the error of a header of HTTP that does not match the body of the request, or that is missing.
- Pyjo.MCP.META_CLIENT_CAPABILITIES = 'io.modelcontextprotocol/clientCapabilities'¶
The key of
_metaof a request with the capabilities of its client.
- Pyjo.MCP.META_CLIENT_INFO = 'io.modelcontextprotocol/clientInfo'¶
The key of
_metaof a request with the name and the version of its client.
- Pyjo.MCP.META_LOG_LEVEL = 'io.modelcontextprotocol/logLevel'¶
The key of
_metaof a request with the level of the log messages that its client wants.
- Pyjo.MCP.META_PROTOCOL_VERSION = 'io.modelcontextprotocol/protocolVersion'¶
The key of
_metaof a request with its revision of the specification.
- Pyjo.MCP.META_SERVER_INFO = 'io.modelcontextprotocol/serverInfo'¶
The key of
_metaof a result with the name and the version of its server.
- Pyjo.MCP.META_SUBSCRIPTION_ID = 'io.modelcontextprotocol/subscriptionId'¶
The key of
_metaof a message of a subscription with theidof its requestsubscriptions/listen.
- Pyjo.MCP.MISSING_REQUIRED_CLIENT_CAPABILITY = -32021¶
The code of the error of a request that needs a capability that its client does not declare.
- Pyjo.MCP.PROTOCOL_VERSION = '2026-07-28'¶
The revision of the specification of the Model Context Protocol, as
MCP-Protocol-Versionnames it.
- Pyjo.MCP.SUPPORTED_VERSIONS = ('2026-07-28',)¶
The revisions that the server supports, as
server/discovergives them.
- Pyjo.MCP.UNSUPPORTED_PROTOCOL_VERSION = -32022¶
The code of the error of a request of a revision that the server does not support.
Guides
API