MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / Settings

Class Settings

src/mcp/server/mcpserver/server.py:81–115  ·  view source on GitHub ↗

MCPServer settings. All settings can be configured via environment variables with the prefix MCP_. For example, MCP_DEBUG=true will set debug=True.

Source from the content-addressed store, hash-verified

79
80
81class Settings(BaseSettings, Generic[LifespanResultT]):
82 """MCPServer settings.
83
84 All settings can be configured via environment variables with the prefix MCP_.
85 For example, MCP_DEBUG=true will set debug=True.
86 """
87
88 model_config = SettingsConfigDict(
89 env_prefix="MCP_",
90 env_file=".env",
91 env_nested_delimiter="__",
92 nested_model_default_partial_update=True,
93 extra="ignore",
94 )
95
96 # Server settings
97 debug: bool
98 log_level: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
99
100 # resource settings
101 warn_on_duplicate_resources: bool
102
103 # tool settings
104 warn_on_duplicate_tools: bool
105
106 # prompt settings
107 warn_on_duplicate_prompts: bool
108
109 dependencies: list[str]
110 """List of dependencies to install in the server environment. Used by the `mcp install` and `mcp dev` CLI."""
111
112 lifespan: Callable[[MCPServer[LifespanResultT]], AbstractAsyncContextManager[LifespanResultT]] | None
113 """An async context manager that will be called when the server is started."""
114
115 auth: AuthSettings | None
116
117
118def lifespan_wrapper(

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected