feat: Add configurable timeout support for MCP server operations with improved defaults

This commit is contained in:
Wang Hao
2025-05-01 23:16:57 +08:00
parent aeca7a5707
commit f30ec77d6f
3 changed files with 18 additions and 4 deletions

View File

@@ -283,6 +283,13 @@ async def generate_prose(request: GenerateProseRequest):
async def mcp_server_metadata(request: MCPServerMetadataRequest):
"""Get information about an MCP server."""
try:
# Set default timeout with a longer value for this endpoint
timeout = 300 # Default to 300 seconds for this endpoint
# Use custom timeout from request if provided
if request.timeout_seconds is not None:
timeout = request.timeout_seconds
# Load tools from the MCP server using the utility function
tools = await load_mcp_tools(
server_type=request.transport,
@@ -290,6 +297,7 @@ async def mcp_server_metadata(request: MCPServerMetadataRequest):
args=request.args,
url=request.url,
env=request.env,
timeout_seconds=timeout,
)
# Create the response with tools