Files
leocrm/app/plugins/builtins/mcp_client/schemas.py
T
Agent Zero 317d5c81f8 feat: MCP Client plugin (Task 5.17) - integrate external MCP servers for AI agents
- New plugin app/plugins/builtins/mcp_client/ with server config CRUD
- Models: McpServerConfig with TenantMixin (name, url, api_token, enabled)
- Routes: GET/POST/PATCH/DELETE /api/v1/mcp-client/servers
- Routes: GET /servers/{id}/tools, POST /servers/{id}/execute
- client.py: async MCP client using httpx for external server calls
- tool_registry_integration.py: registers external MCP tools in AI tool registry
- Migration: 0001_initial.sql for mcp_server_configs table
- Frontend: mcpClient.ts API client with React Query hooks
- Frontend: MCP Client settings UI in SettingsMcp.tsx (server CRUD, tool viewing)
- Tests: 8 tests covering CRUD, auth, tool registry integration
2026-07-23 23:02:07 +02:00

70 lines
1.9 KiB
Python

"""Pydantic schemas for MCP Client plugin."""
from __future__ import annotations
from datetime import datetime
from pydantic import BaseModel, Field
class McpServerConfigCreate(BaseModel):
"""Create a new MCP server configuration."""
name: str = Field(..., min_length=1, max_length=200)
url: str = Field(..., min_length=1, max_length=500)
api_token: str | None = None
enabled: bool = True
description: str | None = None
class McpServerConfigUpdate(BaseModel):
"""Update an existing MCP server configuration."""
name: str | None = Field(None, min_length=1, max_length=200)
url: str | None = Field(None, min_length=1, max_length=500)
api_token: str | None = None
enabled: bool | None = None
description: str | None = None
class McpServerConfigResponse(BaseModel):
"""Response model for MCP server configuration."""
id: str
name: str
url: str
api_token: str | None = None
enabled: bool
description: str | None = None
last_connected_at: datetime | None = None
created_by: str | None = None
created_at: datetime | None = None
updated_at: datetime | None = None
class McpServerToolInfo(BaseModel):
"""Tool info from an external MCP server."""
name: str
description: str = ""
parameters: dict = Field(default_factory=dict)
class McpServerToolsResponse(BaseModel):
"""Response listing tools from an external MCP server."""
server_name: str
server_url: str
tools: list[McpServerToolInfo]
count: int
class McpServerExecuteRequest(BaseModel):
"""Request to execute a tool on an external MCP server."""
tool_name: str
arguments: dict = Field(default_factory=dict)
class McpServerExecuteResponse(BaseModel):
"""Response from executing a tool on an external MCP server."""
server_name: str
tool: str
success: bool
result: dict | str | None = None
error: str | None = None