Jeremiah Lowin commited on
Commit
18ebe37
·
1 Parent(s): dc4ddbc

Add client_kwargs to be passed to from_fastapi

Browse files
Files changed (1) hide show
  1. src/fastmcp/server/server.py +7 -1
src/fastmcp/server/server.py CHANGED
@@ -1186,6 +1186,7 @@ class FastMCP(Generic[LifespanResultT]):
1186
  route_map_fn: OpenAPIRouteMapFn | None = None,
1187
  mcp_component_fn: OpenAPIComponentFn | None = None,
1188
  all_routes_as_tools: bool = False,
 
1189
  **settings: Any,
1190
  ) -> FastMCPOpenAPI:
1191
  """
@@ -1209,8 +1210,13 @@ class FastMCP(Generic[LifespanResultT]):
1209
  elif all_routes_as_tools:
1210
  route_maps = [RouteMap(methods="*", pattern=r".*", mcp_type=MCPType.TOOL)]
1211
 
 
 
 
 
1212
  client = httpx.AsyncClient(
1213
- transport=httpx.ASGITransport(app=app), base_url="http://fastapi"
 
1214
  )
1215
 
1216
  name = name or app.title
 
1186
  route_map_fn: OpenAPIRouteMapFn | None = None,
1187
  mcp_component_fn: OpenAPIComponentFn | None = None,
1188
  all_routes_as_tools: bool = False,
1189
+ httpx_client_kwargs: dict[str, Any] | None = None,
1190
  **settings: Any,
1191
  ) -> FastMCPOpenAPI:
1192
  """
 
1210
  elif all_routes_as_tools:
1211
  route_maps = [RouteMap(methods="*", pattern=r".*", mcp_type=MCPType.TOOL)]
1212
 
1213
+ if httpx_client_kwargs is None:
1214
+ httpx_client_kwargs = {}
1215
+ httpx_client_kwargs.setdefault("base_url", "http://fastapi")
1216
+
1217
  client = httpx.AsyncClient(
1218
+ transport=httpx.ASGITransport(app=app),
1219
+ **httpx_client_kwargs,
1220
  )
1221
 
1222
  name = name or app.title