Ensure custom routes are respected

This commit is contained in:
Jeremiah Lowin 2025-05-22 12:20:29 -04:00
commit 189389a3a4
5 changed files with 107 additions and 3 deletions

View file

@ -241,6 +241,7 @@ def create_sse_app(
# Add custom routes with lowest precedence
if routes:
server_routes.extend(routes)
server_routes.extend(server._additional_http_routes)
# Add middleware
if middleware:
@ -359,6 +360,7 @@ def create_streamable_http_app(
# Add custom routes with lowest precedence
if routes:
server_routes.extend(routes)
server_routes.extend(server._additional_http_routes)
# Add middleware
if middleware:

View file

@ -854,7 +854,6 @@ class FastMCP(Generic[LifespanResultT]):
auth_server_provider=self._auth_server_provider,
auth_settings=self.settings.auth,
debug=self.settings.debug,
routes=self._additional_http_routes,
middleware=middleware,
)
@ -905,7 +904,6 @@ class FastMCP(Generic[LifespanResultT]):
json_response=self.settings.json_response,
stateless_http=self.settings.stateless_http,
debug=self.settings.debug,
routes=self._additional_http_routes,
middleware=middleware,
)
elif transport == "sse":
@ -916,7 +914,6 @@ class FastMCP(Generic[LifespanResultT]):
auth_server_provider=self._auth_server_provider,
auth_settings=self.settings.auth,
debug=self.settings.debug,
routes=self._additional_http_routes,
middleware=middleware,
)