55 lines
1.4 KiB
Python
55 lines
1.4 KiB
Python
|
|
"""Pydantic schemas for MCP Server plugin."""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from typing import Any
|
||
|
|
|
||
|
|
from pydantic import BaseModel, Field
|
||
|
|
|
||
|
|
|
||
|
|
class McpToolParameter(BaseModel):
|
||
|
|
"""Single parameter in an MCP tool definition."""
|
||
|
|
name: str
|
||
|
|
type: str
|
||
|
|
description: str
|
||
|
|
required: bool = False
|
||
|
|
default: Any | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class McpToolDefinition(BaseModel):
|
||
|
|
"""MCP tool definition returned by GET /api/v1/mcp/tools."""
|
||
|
|
name: str
|
||
|
|
description: str
|
||
|
|
category: str
|
||
|
|
parameters: list[McpToolParameter]
|
||
|
|
required_permission: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class McpToolExecuteRequest(BaseModel):
|
||
|
|
"""Request body for POST /api/v1/mcp/tools/{tool_name}/execute."""
|
||
|
|
arguments: dict[str, Any] = Field(default_factory=dict)
|
||
|
|
|
||
|
|
|
||
|
|
class McpToolExecuteResponse(BaseModel):
|
||
|
|
"""Response from executing an MCP tool."""
|
||
|
|
tool: str
|
||
|
|
success: bool
|
||
|
|
result: Any | None = None
|
||
|
|
error: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class McpServerConfig(BaseModel):
|
||
|
|
"""MCP server configuration for external clients."""
|
||
|
|
server_name: str = "LeoCRM"
|
||
|
|
server_version: str = "1.0.0"
|
||
|
|
protocol_version: str = "2024-11-05"
|
||
|
|
base_url: str = "/api/v1/mcp"
|
||
|
|
auth_method: str = "api-token"
|
||
|
|
available_tools: list[str] = Field(default_factory=list)
|
||
|
|
|
||
|
|
|
||
|
|
class McpToolListResponse(BaseModel):
|
||
|
|
"""Response listing all MCP tools."""
|
||
|
|
tools: list[McpToolDefinition]
|
||
|
|
count: int
|