Skip to content

Commit 658e3ed

Browse files
committed
print configs at startup
1 parent 755749a commit 658e3ed

3 files changed

Lines changed: 55 additions & 9 deletions

File tree

.env.example

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
OBP_BASE_URL="http://localhost:8080"
33
OBP_API_VERSION="v6.0.0"
44

5+
# Basic Server Config
6+
FASTMCP_PORT=9101
7+
FASTMCP_HOST=0.0.0.0
8+
59
# OAuth Settings
610
ENABLE_OAUTH="false"
711

812
## this is the url of this mcp application i.e. http://localhost:9100
9-
BASE_URL="http://localhost:9100"
13+
BASE_URL="http://localhost:9101"
1014

1115
# Choose authentication provider:
1216
# - "bearer-only": Simple JWT validation only (recommended for Opey/internal agents)

ai_env

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/mcp_server_obp/lifespan.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
import json
23
import logging
34
import os
45
from contextlib import asynccontextmanager
@@ -8,6 +9,53 @@
89
logger = logging.getLogger(__name__)
910

1011

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+
1159
async def periodic_index_refresh(interval_minutes: int):
1260
"""Periodically check and update the index every N minutes."""
1361
interval_seconds = interval_minutes * 60
@@ -42,7 +90,8 @@ async def lifespan(server) -> AsyncIterator[dict[str, Any]]:
4290
"""
4391
# Startup actions
4492
logger.info("Starting MCP server...")
45-
93+
print_client_configs()
94+
4695
# Check and update index on startup
4796
success = await update_index_on_startup()
4897
if not success:

0 commit comments

Comments
 (0)