cegers commited on
Commit
ae80cbe
·
1 Parent(s): eaa8eea

accept timeouts in MCPConfig

Browse files
Files changed (1) hide show
  1. src/fastmcp/utilities/mcp_config.py +12 -2
src/fastmcp/utilities/mcp_config.py CHANGED
@@ -3,6 +3,7 @@ from __future__ import annotations
3
  import re
4
  from typing import TYPE_CHECKING, Annotated, Any, Literal
5
  from urllib.parse import urlparse
 
6
 
7
  import httpx
8
  from pydantic import AnyUrl, ConfigDict, Field
@@ -65,6 +66,7 @@ class RemoteMCPServer(FastMCPBaseModel):
65
  description='Either a string representing a Bearer token, the literal "oauth" to use OAuth authentication, or an httpx.Auth instance for custom authentication.',
66
  ),
67
  ] = None
 
68
 
69
  model_config = ConfigDict(arbitrary_types_allowed=True)
70
 
@@ -77,11 +79,19 @@ class RemoteMCPServer(FastMCPBaseModel):
77
  transport = self.transport
78
 
79
  if transport == "sse":
80
- return SSETransport(self.url, headers=self.headers, auth=self.auth)
 
 
 
 
 
81
  else:
82
  # Both "http" and "streamable-http" map to StreamableHttpTransport
83
  return StreamableHttpTransport(
84
- self.url, headers=self.headers, auth=self.auth
 
 
 
85
  )
86
 
87
 
 
3
  import re
4
  from typing import TYPE_CHECKING, Annotated, Any, Literal
5
  from urllib.parse import urlparse
6
+ import datetime
7
 
8
  import httpx
9
  from pydantic import AnyUrl, ConfigDict, Field
 
66
  description='Either a string representing a Bearer token, the literal "oauth" to use OAuth authentication, or an httpx.Auth instance for custom authentication.',
67
  ),
68
  ] = None
69
+ sse_read_timeout: datetime.timedelta | int | float | None = None
70
 
71
  model_config = ConfigDict(arbitrary_types_allowed=True)
72
 
 
79
  transport = self.transport
80
 
81
  if transport == "sse":
82
+ return SSETransport(
83
+ self.url,
84
+ headers=self.headers,
85
+ auth=self.auth,
86
+ sse_read_timeout=self.sse_read_timeout,
87
+ )
88
  else:
89
  # Both "http" and "streamable-http" map to StreamableHttpTransport
90
  return StreamableHttpTransport(
91
+ self.url,
92
+ headers=self.headers,
93
+ auth=self.auth,
94
+ sse_read_timeout=self.sse_read_timeout,
95
  )
96
 
97