|
1 | 1 | import asyncio |
| 2 | +import json |
2 | 3 | import logging |
3 | 4 | import os |
4 | 5 | from contextlib import asynccontextmanager |
|
8 | 9 | logger = logging.getLogger(__name__) |
9 | 10 |
|
10 | 11 |
|
| 12 | +def print_client_configs(): |
| 13 | + """Print copy-pasteable MCP client configuration snippets.""" |
| 14 | + host = os.getenv("FASTMCP_HOST", "127.0.0.1") |
| 15 | + port = os.getenv("FASTMCP_PORT", "9100") |
| 16 | + auth_provider = os.getenv("AUTH_PROVIDER", "none") |
| 17 | + requires_auth = auth_provider != "none" |
| 18 | + base_url = f"http://{host}:{port}/mcp" |
| 19 | + |
| 20 | + configs = { |
| 21 | + "Opey": { |
| 22 | + "servers": [ |
| 23 | + { |
| 24 | + "name": "obp", |
| 25 | + "url": base_url, |
| 26 | + "transport": "http", |
| 27 | + "requires_auth": requires_auth, |
| 28 | + } |
| 29 | + ] |
| 30 | + }, |
| 31 | + "Claude Desktop / claude_desktop_config.json": { |
| 32 | + "mcpServers": { |
| 33 | + "obp": { |
| 34 | + "url": base_url, |
| 35 | + } |
| 36 | + } |
| 37 | + }, |
| 38 | + "VS Code / settings.json": { |
| 39 | + "mcp": { |
| 40 | + "servers": { |
| 41 | + "obp": { |
| 42 | + "url": base_url, |
| 43 | + } |
| 44 | + } |
| 45 | + } |
| 46 | + }, |
| 47 | + } |
| 48 | + |
| 49 | + separator = "=" * 60 |
| 50 | + print(f"\n{separator}") |
| 51 | + print("MCP Client Configurations") |
| 52 | + print(separator) |
| 53 | + for name, config in configs.items(): |
| 54 | + print(f"\n--- {name} ---\n") |
| 55 | + print(json.dumps(config, indent=2)) |
| 56 | + print(f"\n{separator}\n") |
| 57 | + |
| 58 | + |
11 | 59 | async def periodic_index_refresh(interval_minutes: int): |
12 | 60 | """Periodically check and update the index every N minutes.""" |
13 | 61 | interval_seconds = interval_minutes * 60 |
@@ -42,7 +90,8 @@ async def lifespan(server) -> AsyncIterator[dict[str, Any]]: |
42 | 90 | """ |
43 | 91 | # Startup actions |
44 | 92 | logger.info("Starting MCP server...") |
45 | | - |
| 93 | + print_client_configs() |
| 94 | + |
46 | 95 | # Check and update index on startup |
47 | 96 | success = await update_index_on_startup() |
48 | 97 | if not success: |
|
0 commit comments