2026-07-23 23:02:07 +02:00
|
|
|
"""MCP Client plugin — allows LeoCRM agents to use external MCP servers."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from app.plugins.base import BasePlugin
|
|
|
|
|
from app.plugins.manifest import PluginManifest, PluginRouteDef
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class McpClientPlugin(BasePlugin):
|
|
|
|
|
"""MCP Client plugin: integrates external MCP servers into the AI tool registry."""
|
|
|
|
|
|
|
|
|
|
manifest = PluginManifest(
|
|
|
|
|
name="mcp_client",
|
|
|
|
|
version="1.0.0",
|
|
|
|
|
display_name="MCP Client",
|
|
|
|
|
description="Allows LeoCRM AI agents to use external MCP servers (web search, code execution, etc.).",
|
|
|
|
|
dependencies=["permissions"],
|
|
|
|
|
routes=[
|
|
|
|
|
PluginRouteDef(
|
|
|
|
|
path="/api/v1/mcp-client",
|
|
|
|
|
module="app.plugins.builtins.mcp_client.routes",
|
|
|
|
|
router_attr="router",
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
events=[],
|
2026-07-24 10:37:44 +02:00
|
|
|
migrations=["0001_initial.sql", "0002_add_deleted_at.sql"],
|
2026-07-23 23:02:07 +02:00
|
|
|
permissions=[
|
|
|
|
|
"mcp-client:read",
|
|
|
|
|
"mcp-client:write",
|
|
|
|
|
"mcp-client:admin",
|
|
|
|
|
],
|
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")
|
|
|
|
|
|
2026-08-16 01:17:18 +02:00
|
|
|
def get_entity_models(self) -> dict[str, type]:
|
|
|
|
|
from app.plugins.builtins.mcp_client.models import McpServerConfig
|
|
|
|
|
return {"mcp_server_config": McpServerConfig}
|
|
|
|
|
|
2026-07-26 23:15:34 +02:00
|
|
|
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)
|