Spaces:
Running
Running
zzstoatzz commited on
Commit ·
731e83f
1
Parent(s): de8e775
try one more thing
Browse files- src/fastmcp/server/server.py +9 -16
src/fastmcp/server/server.py
CHANGED
|
@@ -760,28 +760,24 @@ class FastMCP(Generic[LifespanResultT]):
|
|
| 760 |
path: Path for the endpoint (defaults to settings.streamable_http_path or settings.sse_path)
|
| 761 |
uvicorn_config: Additional configuration for the Uvicorn server
|
| 762 |
"""
|
| 763 |
-
uvicorn_config = uvicorn_config or {}
|
| 764 |
-
uvicorn_config.setdefault("timeout_graceful_shutdown", 0)
|
| 765 |
-
# lifespan is required for streamable http
|
| 766 |
-
uvicorn_config["lifespan"] = "on"
|
| 767 |
-
|
| 768 |
host = host or self.settings.host
|
| 769 |
port = port or self.settings.port
|
| 770 |
-
|
| 771 |
|
| 772 |
app = self.http_app(path=path, transport=transport, middleware=middleware)
|
| 773 |
|
|
|
|
|
|
|
| 774 |
config_kwargs: dict[str, Any] = {
|
| 775 |
-
"
|
| 776 |
-
"
|
| 777 |
-
"port": port,
|
| 778 |
-
**uvicorn_config,
|
| 779 |
}
|
|
|
|
| 780 |
|
| 781 |
-
if "log_config" not in
|
| 782 |
-
config_kwargs["log_level"] =
|
| 783 |
|
| 784 |
-
config = uvicorn.Config(**config_kwargs)
|
| 785 |
server = uvicorn.Server(config)
|
| 786 |
path = app.state.path.lstrip("/") # type: ignore
|
| 787 |
logger.info(
|
|
@@ -1044,9 +1040,6 @@ class FastMCP(Generic[LifespanResultT]):
|
|
| 1044 |
- The prompts are imported with prefixed names using the
|
| 1045 |
prompt_separator Example: If server has a prompt named
|
| 1046 |
"weather_prompt", it will be available as "weather_weather_prompt"
|
| 1047 |
-
- The mounted server's lifespan will be executed when the parent
|
| 1048 |
-
server's lifespan runs, ensuring that any setup needed by the mounted
|
| 1049 |
-
server is performed
|
| 1050 |
|
| 1051 |
Args:
|
| 1052 |
prefix: The prefix to use for the mounted server server: The FastMCP
|
|
|
|
| 760 |
path: Path for the endpoint (defaults to settings.streamable_http_path or settings.sse_path)
|
| 761 |
uvicorn_config: Additional configuration for the Uvicorn server
|
| 762 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 763 |
host = host or self.settings.host
|
| 764 |
port = port or self.settings.port
|
| 765 |
+
default_log_level_to_use = log_level or self.settings.log_level.lower()
|
| 766 |
|
| 767 |
app = self.http_app(path=path, transport=transport, middleware=middleware)
|
| 768 |
|
| 769 |
+
_uvicorn_config_from_user = uvicorn_config or {}
|
| 770 |
+
|
| 771 |
config_kwargs: dict[str, Any] = {
|
| 772 |
+
"timeout_graceful_shutdown": 0,
|
| 773 |
+
"lifespan": "on",
|
|
|
|
|
|
|
| 774 |
}
|
| 775 |
+
config_kwargs.update(_uvicorn_config_from_user)
|
| 776 |
|
| 777 |
+
if "log_config" not in config_kwargs and "log_level" not in config_kwargs:
|
| 778 |
+
config_kwargs["log_level"] = default_log_level_to_use
|
| 779 |
|
| 780 |
+
config = uvicorn.Config(app, host=host, port=port, **config_kwargs)
|
| 781 |
server = uvicorn.Server(config)
|
| 782 |
path = app.state.path.lstrip("/") # type: ignore
|
| 783 |
logger.info(
|
|
|
|
| 1040 |
- The prompts are imported with prefixed names using the
|
| 1041 |
prompt_separator Example: If server has a prompt named
|
| 1042 |
"weather_prompt", it will be available as "weather_weather_prompt"
|
|
|
|
|
|
|
|
|
|
| 1043 |
|
| 1044 |
Args:
|
| 1045 |
prefix: The prefix to use for the mounted server server: The FastMCP
|