Files
ZY-Agent/src/server/mcp_request.py
T
Willem Jiang 6b73a53999 fix(config): Add support for MCP server configuration parameters (#812)
* fix(config): Add support for MCP server configuration parameters

* refact: rename the sse_readtimeout to sse_read_timeout

* update the code with review comments

* update the MCP document for the latest change
2026-01-10 15:59:49 +08:00

74 lines
2.3 KiB
Python

# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
# SPDX-License-Identifier: MIT
from typing import Dict, List, Optional
from pydantic import BaseModel, Field
class MCPServerMetadataRequest(BaseModel):
"""Request model for MCP server metadata."""
transport: str = Field(
...,
description=(
"The type of MCP server connection (stdio or sse or streamable_http)"
),
)
command: Optional[str] = Field(
None, description="The command to execute (for stdio type)"
)
args: Optional[List[str]] = Field(
None, description="Command arguments (for stdio type)"
)
url: Optional[str] = Field(
None, description="The URL of the SSE server (for sse type)"
)
env: Optional[Dict[str, str]] = Field(
None, description="Environment variables (for stdio type)"
)
headers: Optional[Dict[str, str]] = Field(
None, description="HTTP headers (for sse/streamable_http type)"
)
timeout_seconds: Optional[int] = Field(
None,
ge=1,
le=3600,
description="Optional custom timeout in seconds for the operation (default: 60, range: 1-3600)"
)
sse_read_timeout: Optional[int] = Field(
None,
ge=1,
le=3600,
description="Optional SSE read timeout in seconds (for sse type, default: 30, range: 1-3600)"
)
class MCPServerMetadataResponse(BaseModel):
"""Response model for MCP server metadata."""
transport: str = Field(
...,
description=(
"The type of MCP server connection (stdio or sse or streamable_http)"
),
)
command: Optional[str] = Field(
None, description="The command to execute (for stdio type)"
)
args: Optional[List[str]] = Field(
None, description="Command arguments (for stdio type)"
)
url: Optional[str] = Field(
None, description="The URL of the SSE server (for sse type)"
)
env: Optional[Dict[str, str]] = Field(
None, description="Environment variables (for stdio type)"
)
headers: Optional[Dict[str, str]] = Field(
None, description="HTTP headers (for sse/streamable_http type)"
)
tools: List = Field(
default_factory=list, description="Available tools from the MCP server"
)