2026-07-23 23:01:59 +02:00
|
|
|
"""MCP Server plugin — exposes LeoCRM data to external MCP clients (Claude Desktop, etc.)."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from app.plugins.base import BasePlugin
|
|
|
|
|
from app.plugins.manifest import PluginManifest, PluginRouteDef
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class McpServerPlugin(BasePlugin):
|
|
|
|
|
"""MCP Server plugin: exposes LeoCRM tools to external AI clients via MCP protocol."""
|
|
|
|
|
|
|
|
|
|
manifest = PluginManifest(
|
|
|
|
|
name="mcp_server",
|
|
|
|
|
version="1.0.0",
|
|
|
|
|
display_name="MCP Server",
|
|
|
|
|
description="Exposes LeoCRM data (contacts, calendar, mail, DMS) to external MCP clients via API-token auth.",
|
|
|
|
|
dependencies=["permissions"],
|
|
|
|
|
routes=[
|
|
|
|
|
PluginRouteDef(
|
|
|
|
|
path="/api/v1/mcp",
|
|
|
|
|
module="app.plugins.builtins.mcp_server.routes",
|
|
|
|
|
router_attr="router",
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
events=[],
|
|
|
|
|
migrations=["0001_initial.sql"],
|
|
|
|
|
permissions=[
|
|
|
|
|
"mcp:read",
|
|
|
|
|
"mcp:write",
|
|
|
|
|
],
|
2026-08-16 01:17:18 +02:00
|
|
|
|
2026-07-26 23:15:34 +02:00
|
|
|
author="LeoCRM Team",
|
|
|
|
|
min_app_version="1.0.0",
|
|
|
|
|
contract_version="1.0.0")
|
|
|
|
|
|
|
|
|
|
async def on_deactivate(
|
|
|
|
|
self, db, service_container, event_bus
|
|
|
|
|
) -> None:
|
|
|
|
|
"""Deactivate plugin: unregister contract and event listeners."""
|
|
|
|
|
# Contract abmelden
|
|
|
|
|
from app.plugins.builtins.contracts import get_contract_registry
|
|
|
|
|
get_contract_registry().unregister(self.manifest.name)
|
|
|
|
|
await super().on_deactivate(db, service_container, event_bus)
|