-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
56 lines (43 loc) · 1.64 KB
/
Copy pathserver.py
File metadata and controls
56 lines (43 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import asyncio
import os
from dotenv import load_dotenv
from log_config import logger
# Import feature registry and discovery
from pipedrive.api.features.tool_registry import registry
from pipedrive.api.features import discover_features
from pipedrive.feature_config import FeatureConfig
from pipedrive.api.pipedrive_context import pipedrive_lifespan
from pipedrive.mcp_instance import mcp
load_dotenv()
# Discover and register all features
discover_features()
# Load feature configuration
feature_config = FeatureConfig()
async def main():
transport = os.getenv("TRANSPORT", "sse")
server_host = os.getenv("HOST", "0.0.0.0")
server_port = int(os.getenv("PORT", "8152"))
# Log enabled features
enabled_features = feature_config.get_enabled_features()
logger.info(f"Enabled features: {', '.join(enabled_features.keys())}")
# Log registered tools
tool_count = registry.get_tool_count()
logger.info(f"Registered tools: {tool_count}")
logger.info(
f"Starting Pipedrive MCP server. Transport: {transport}, Host: {server_host}, Port: {server_port}"
)
if transport == "sse":
await mcp.run_sse_async()
else:
logger.info(
"Stdio transport selected. Ensure your FastMCP setup supports this or modify."
)
if hasattr(mcp, "run_stdio_async"):
await mcp.run_stdio_async()
else:
logger.warning(
"run_stdio_async method not found on mcp object. Defaulting to SSE behavior for this example if stdio is chosen."
)
await mcp.run_sse_async()
if __name__ == "__main__":
asyncio.run(main())