MCPServer settings. All settings can be configured via environment variables with the prefix MCP_. For example, MCP_DEBUG=true will set debug=True.
| 79 | |
| 80 | |
| 81 | class 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 | |
| 118 | def lifespan_wrapper( |