44
55import inspect
66import re
7- from collections .abc import (
8- AsyncIterator ,
9- Awaitable ,
10- Callable ,
11- Collection ,
12- Iterable ,
13- Sequence ,
14- )
7+ from collections .abc import AsyncIterator , Awaitable , Callable , Iterable , Sequence
158from contextlib import AbstractAsyncContextManager , asynccontextmanager
169from typing import Any , Generic , Literal
1710
2922from starlette .types import Receive , Scope , Send
3023
3124from mcp .server .auth .middleware .auth_context import AuthContextMiddleware
32- from mcp .server .auth .middleware .bearer_auth import (
33- BearerAuthBackend ,
34- RequireAuthMiddleware ,
35- )
36- from mcp .server .auth .provider import (
37- OAuthAuthorizationServerProvider ,
38- ProviderTokenVerifier ,
39- TokenVerifier ,
40- )
25+ from mcp .server .auth .middleware .bearer_auth import BearerAuthBackend , RequireAuthMiddleware
26+ from mcp .server .auth .provider import OAuthAuthorizationServerProvider , ProviderTokenVerifier , TokenVerifier
4127from mcp .server .auth .settings import AuthSettings
42- from mcp .server .elicitation import (
43- ElicitationResult ,
44- ElicitSchemaModelT ,
45- UrlElicitationResult ,
46- elicit_with_validation ,
47- )
48- from mcp .server .elicitation import (
49- elicit_url as _elicit_url ,
50- )
28+ from mcp .server .elicitation import ElicitationResult , ElicitSchemaModelT , UrlElicitationResult , elicit_with_validation
29+ from mcp .server .elicitation import elicit_url as _elicit_url
5130from mcp .server .fastmcp .exceptions import ResourceError
5231from mcp .server .fastmcp .prompts import Prompt , PromptManager
5332from mcp .server .fastmcp .resources import FunctionResource , Resource , ResourceManager
@@ -116,10 +95,6 @@ class Settings(BaseSettings, Generic[LifespanResultT]):
11695 # prompt settings
11796 warn_on_duplicate_prompts : bool
11897
119- # TODO(Marcelo): Investigate if this is used. If it is, it's probably a good idea to remove it.
120- dependencies : list [str ]
121- """A list of dependencies to install in the server environment."""
122-
12398 lifespan : Callable [[FastMCP [LifespanResultT ]], AbstractAsyncContextManager [LifespanResultT ]] | None
12499 """A async context manager that will be called when the server is started."""
125100
@@ -172,7 +147,6 @@ def __init__( # noqa: PLR0913
172147 warn_on_duplicate_resources : bool = True ,
173148 warn_on_duplicate_tools : bool = True ,
174149 warn_on_duplicate_prompts : bool = True ,
175- dependencies : Collection [str ] = (),
176150 lifespan : (Callable [[FastMCP [LifespanResultT ]], AbstractAsyncContextManager [LifespanResultT ]] | None ) = None ,
177151 auth : AuthSettings | None = None ,
178152 transport_security : TransportSecuritySettings | None = None ,
@@ -199,7 +173,6 @@ def __init__( # noqa: PLR0913
199173 warn_on_duplicate_resources = warn_on_duplicate_resources ,
200174 warn_on_duplicate_tools = warn_on_duplicate_tools ,
201175 warn_on_duplicate_prompts = warn_on_duplicate_prompts ,
202- dependencies = list (dependencies ),
203176 lifespan = lifespan ,
204177 auth = auth ,
205178 transport_security = transport_security ,
@@ -238,7 +211,6 @@ def __init__( # noqa: PLR0913
238211 self ._event_store = event_store
239212 self ._retry_interval = retry_interval
240213 self ._custom_starlette_routes : list [Route ] = []
241- self .dependencies = self .settings .dependencies
242214 self ._session_manager : StreamableHTTPSessionManager | None = None
243215
244216 # Set up MCP protocol handlers
@@ -835,8 +807,6 @@ def _normalize_path(self, mount_path: str, endpoint: str) -> str:
835807
836808 def sse_app (self , mount_path : str | None = None ) -> Starlette :
837809 """Return an instance of the SSE server app."""
838- from starlette .middleware import Middleware
839- from starlette .routing import Mount , Route
840810
841811 # Update mount_path in settings if provided
842812 if mount_path is not None :
@@ -855,11 +825,7 @@ def sse_app(self, mount_path: str | None = None) -> Starlette:
855825 async def handle_sse (scope : Scope , receive : Receive , send : Send ): # pragma: no cover
856826 # Add client ID from auth context into request context if available
857827
858- async with sse .connect_sse (
859- scope ,
860- receive ,
861- send ,
862- ) as streams :
828+ async with sse .connect_sse (scope , receive , send ) as streams :
863829 await self ._mcp_server .run (
864830 streams [0 ],
865831 streams [1 ],
0 commit comments