|
27 | 27 | - TOOL_TIMEOUT: Tool invocation timeout (default: 60)
|
28 | 28 | - PROMPT_CACHE_SIZE: Max cached prompts (default: 100)
|
29 | 29 | - HEALTH_CHECK_INTERVAL: Gateway health check interval (default: 60)
|
| 30 | +
|
| 31 | +Examples: |
| 32 | + >>> from mcpgateway.config import Settings |
| 33 | + >>> s = Settings(basic_auth_user='admin', basic_auth_password='secret') |
| 34 | + >>> s.api_key |
| 35 | + 'admin:secret' |
| 36 | + >>> s2 = Settings(transport_type='http') |
| 37 | + >>> s2.validate_transport() # no error |
| 38 | + >>> s3 = Settings(transport_type='invalid') |
| 39 | + >>> try: |
| 40 | + ... s3.validate_transport() |
| 41 | + ... except ValueError as e: |
| 42 | + ... print('error') |
| 43 | + error |
| 44 | + >>> s4 = Settings(database_url='sqlite:///./test.db') |
| 45 | + >>> isinstance(s4.database_settings, dict) |
| 46 | + True |
30 | 47 | """
|
31 | 48 |
|
32 | 49 | # Standard
|
|
46 | 63 |
|
47 | 64 |
|
48 | 65 | class Settings(BaseSettings):
|
49 |
| - """MCP Gateway configuration settings.""" |
| 66 | + """ |
| 67 | + MCP Gateway configuration settings. |
| 68 | +
|
| 69 | + Examples: |
| 70 | + >>> from mcpgateway.config import Settings |
| 71 | + >>> s = Settings(basic_auth_user='admin', basic_auth_password='secret') |
| 72 | + >>> s.api_key |
| 73 | + 'admin:secret' |
| 74 | + >>> s2 = Settings(transport_type='http') |
| 75 | + >>> s2.validate_transport() # no error |
| 76 | + >>> s3 = Settings(transport_type='invalid') |
| 77 | + >>> try: |
| 78 | + ... s3.validate_transport() |
| 79 | + ... except ValueError as e: |
| 80 | + ... print('error') |
| 81 | + error |
| 82 | + >>> s4 = Settings(database_url='sqlite:///./test.db') |
| 83 | + >>> isinstance(s4.database_settings, dict) |
| 84 | + True |
| 85 | + """ |
50 | 86 |
|
51 | 87 | # Basic Settings
|
52 | 88 | app_name: str = "MCP_Gateway"
|
@@ -207,12 +243,14 @@ def _parse_federation_peers(cls, v):
|
207 | 243 |
|
208 | 244 | @property
|
209 | 245 | def api_key(self) -> str:
|
210 |
| - """Generate API key from auth credentials. |
| 246 | + """ |
| 247 | + Generate API key from auth credentials. |
211 | 248 |
|
212 | 249 | Returns:
|
213 | 250 | str: API key string in the format "username:password".
|
214 | 251 |
|
215 | 252 | Examples:
|
| 253 | + >>> from mcpgateway.config import Settings |
216 | 254 | >>> settings = Settings(basic_auth_user="admin", basic_auth_password="secret")
|
217 | 255 | >>> settings.api_key
|
218 | 256 | 'admin:secret'
|
@@ -284,10 +322,17 @@ def supports_sse(self) -> bool:
|
284 | 322 |
|
285 | 323 | @property
|
286 | 324 | def database_settings(self) -> dict:
|
287 |
| - """Get SQLAlchemy database settings. |
| 325 | + """ |
| 326 | + Get SQLAlchemy database settings. |
288 | 327 |
|
289 | 328 | Returns:
|
290 | 329 | dict: Dictionary containing SQLAlchemy database configuration options.
|
| 330 | +
|
| 331 | + Examples: |
| 332 | + >>> from mcpgateway.config import Settings |
| 333 | + >>> s = Settings(database_url='sqlite:///./test.db') |
| 334 | + >>> isinstance(s.database_settings, dict) |
| 335 | + True |
291 | 336 | """
|
292 | 337 | return {
|
293 | 338 | "pool_size": self.db_pool_size,
|
@@ -316,10 +361,22 @@ def cors_settings(self) -> dict:
|
316 | 361 | )
|
317 | 362 |
|
318 | 363 | def validate_transport(self) -> None:
|
319 |
| - """Validate transport configuration. |
| 364 | + """ |
| 365 | + Validate transport configuration. |
320 | 366 |
|
321 | 367 | Raises:
|
322 | 368 | ValueError: If the transport type is not one of the valid options.
|
| 369 | +
|
| 370 | + Examples: |
| 371 | + >>> from mcpgateway.config import Settings |
| 372 | + >>> s = Settings(transport_type='http') |
| 373 | + >>> s.validate_transport() # no error |
| 374 | + >>> s2 = Settings(transport_type='invalid') |
| 375 | + >>> try: |
| 376 | + ... s2.validate_transport() |
| 377 | + ... except ValueError as e: |
| 378 | + ... print('error') |
| 379 | + error |
323 | 380 | """
|
324 | 381 | valid_types = {"http", "ws", "sse", "all"}
|
325 | 382 | if self.transport_type not in valid_types:
|
|
0 commit comments