guohanghui commited on
Commit
9c83665
Β·
verified Β·
1 Parent(s): f7c63d2

Update biopython/mcp_output/start_mcp.py

Browse files
Files changed (1) hide show
  1. biopython/mcp_output/start_mcp.py +63 -14
biopython/mcp_output/start_mcp.py CHANGED
@@ -1,30 +1,79 @@
1
-
2
  """
3
  MCP Service Startup Entry
4
  """
5
  import sys
6
  import os
 
 
 
 
 
 
 
7
 
8
  project_root = os.path.dirname(os.path.abspath(__file__))
9
  mcp_plugin_dir = os.path.join(project_root, "mcp_plugin")
 
 
 
 
 
 
 
 
10
  if mcp_plugin_dir not in sys.path:
11
  sys.path.insert(0, mcp_plugin_dir)
12
 
13
- from mcp_service import create_app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  def main():
16
  """Start FastMCP service"""
17
- app = create_app()
18
- # Use environment variable to configure port, default 8000
19
- port = int(os.environ.get("MCP_PORT", "8000"))
20
-
21
- # Choose transport mode based on environment variable
22
- transport = os.environ.get("MCP_TRANSPORT", "stdio")
23
- if transport == "http":
24
- app.run(transport="http", host="0.0.0.0", port=port)
25
- else:
26
- # Default to STDIO mode
27
- app.run()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  if __name__ == "__main__":
30
- main()
 
 
1
  """
2
  MCP Service Startup Entry
3
  """
4
  import sys
5
  import os
6
+ import traceback
7
+
8
+ # 打印调试俑息
9
+ print("=" * 60)
10
+ print("πŸš€ MCP Service Starting...")
11
+ print(f"πŸ“‚ Current directory: {os.getcwd()}")
12
+ print(f"πŸ“„ Script location: {os.path.abspath(__file__)}")
13
 
14
  project_root = os.path.dirname(os.path.abspath(__file__))
15
  mcp_plugin_dir = os.path.join(project_root, "mcp_plugin")
16
+
17
+ print(f"πŸ“ Project root: {project_root}")
18
+ print(f"πŸ“ MCP plugin dir: {mcp_plugin_dir}")
19
+ print(f"πŸ“ Plugin dir exists: {os.path.exists(mcp_plugin_dir)}")
20
+
21
+ if os.path.exists(mcp_plugin_dir):
22
+ print(f"πŸ“‹ Files in mcp_plugin: {os.listdir(mcp_plugin_dir)}")
23
+
24
  if mcp_plugin_dir not in sys.path:
25
  sys.path.insert(0, mcp_plugin_dir)
26
 
27
+ print(f"🐍 Python path (first 3): {sys.path[:3]}")
28
+ print("=" * 60)
29
+
30
+ # 尝试导ε…₯幢提供详细错误俑息
31
+ try:
32
+ print("πŸ“¦ Attempting to import mcp_service...")
33
+ from mcp_service import create_app
34
+ print("βœ… Successfully imported mcp_service")
35
+ except ImportError as e:
36
+ print(f"❌ Failed to import mcp_service: {e}")
37
+ print("\nπŸ” Detailed error:")
38
+ traceback.print_exc()
39
+ print("\nπŸ’‘ Troubleshooting:")
40
+ print("1. Check if mcp_plugin/mcp_service.py exists")
41
+ print("2. Check if mcp_plugin/__init__.py exists")
42
+ print("3. Check for any syntax errors in mcp_service.py")
43
+ sys.exit(1)
44
+ except Exception as e:
45
+ print(f"❌ Unexpected error during import: {e}")
46
+ traceback.print_exc()
47
+ sys.exit(1)
48
 
49
  def main():
50
  """Start FastMCP service"""
51
+ try:
52
+ print("\nπŸ”§ Creating MCP app...")
53
+ app = create_app()
54
+ print("βœ… App created successfully")
55
+
56
+ # Use environment variable to configure port, default 8000
57
+ port = int(os.environ.get("MCP_PORT", "8000"))
58
+
59
+ # Choose transport mode based on environment variable
60
+ transport = os.environ.get("MCP_TRANSPORT", "stdio")
61
+
62
+ print(f"🌐 Transport mode: {transport}")
63
+ print(f"πŸ”Œ Port: {port}")
64
+
65
+ if transport == "http":
66
+ print(f"πŸš€ Starting HTTP server on 0.0.0.0:{port}")
67
+ app.run(transport="http", host="0.0.0.0", port=port)
68
+ else:
69
+ # Default to STDIO mode
70
+ print("πŸš€ Starting STDIO server")
71
+ app.run()
72
+
73
+ except Exception as e:
74
+ print(f"\n❌ Error starting service: {e}")
75
+ traceback.print_exc()
76
+ sys.exit(1)
77
 
78
  if __name__ == "__main__":
79
+ main()