mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-04-29 04:00:09 +00:00
update
This commit is contained in:
parent
c8a0a21ef2
commit
3f21c2b2c2
83 changed files with 6355 additions and 0 deletions
33
server/app/component/validator/McpServer.py
Normal file
33
server/app/component/validator/McpServer.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
from pydantic import BaseModel, ValidationError, field_validator
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
|
||||
class McpServerItem(BaseModel):
|
||||
command: str
|
||||
args: List[str]
|
||||
env: Optional[Dict[str, str]] = None
|
||||
|
||||
|
||||
class McpServersModel(BaseModel):
|
||||
mcpServers: Dict[str, McpServerItem]
|
||||
|
||||
|
||||
class McpRemoteServer(BaseModel):
|
||||
server_name: str
|
||||
server_url: str
|
||||
|
||||
|
||||
def validate_mcp_servers(data: dict):
|
||||
try:
|
||||
model = McpServersModel.model_validate(data)
|
||||
return True, model
|
||||
except ValidationError as e:
|
||||
return False, e.errors()
|
||||
|
||||
|
||||
def validate_mcp_remote_servers(data: dict):
|
||||
try:
|
||||
model = McpRemoteServer.model_validate(data)
|
||||
return True, model
|
||||
except ValidationError as e:
|
||||
return False, e.errors()
|
||||
Loading…
Add table
Add a link
Reference in a new issue