kabudadada commited on
Commit
ce4dde2
ยท
1 Parent(s): 59e1d30

align(sympy): match esm layout: create_app returns FastMCP; start_mcp runs stdio/http; Docker CMD unchanged

Browse files
sympy/mcp_output/mcp_plugin/mcp_service.py CHANGED
@@ -79,34 +79,9 @@ def calculate_exp(value):
79
 
80
  def create_app():
81
  """
82
- Create and return a FastAPI app with FastMCP mounted.
83
-
84
- Returns:
85
- FastAPI: Custom FastAPI app with MCP service mounted.
86
  """
87
- # Import FastAPI to create a custom app
88
- from fastapi import FastAPI
89
-
90
- # Create a custom FastAPI app
91
- app = FastAPI(title="SymPy MCP Service", description="Symbolic mathematics using SymPy")
92
-
93
-
94
-
95
- _mounted = None
96
- _handle = getattr(mcp, "handle", None)
97
- if callable(_handle):
98
- _mounted = _handle
99
- if _mounted is None:
100
- for name in ("http_app", "asgi_app", "app", "fastapi_app", "router"):
101
- _candidate = getattr(mcp, name, None)
102
- if _candidate is not None:
103
- _mounted = _candidate
104
- break
105
- if _mounted is None:
106
- _mounted = mcp
107
- app.mount("/mcp", _mounted)
108
-
109
- return app
110
 
111
  if __name__ == "__main__":
112
  mcp.run(transport="http", host="0.0.0.0", port=8000)
 
79
 
80
  def create_app():
81
  """
82
+ Return FastMCP instance for launcher to run (stdio/http).
 
 
 
83
  """
84
+ return mcp
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
  if __name__ == "__main__":
87
  mcp.run(transport="http", host="0.0.0.0", port=8000)
sympy/mcp_output/start_mcp.py CHANGED
@@ -1,7 +1,4 @@
1
 
2
- """
3
- MCP Service Startup Entry Point
4
- """
5
  import sys
6
  import os
7
 
@@ -10,55 +7,19 @@ 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
- # Set path to point to source directory
14
  source_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "source")
15
  sys.path.insert(0, source_path)
16
 
17
  from mcp_service import create_app
18
- import uvicorn
19
 
20
  def main():
21
- """Start FastMCP Service"""
22
- # Display FastMCP startup banner
23
- print("โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ")
24
- print("โ”‚ โ”‚")
25
- print("โ”‚ _ __ ___ _____ __ __ _____________ ____ ____ โ”‚")
26
- print("โ”‚ _ __ ___ .'____/___ ______/ /_/ |/ / ____/ __ \\ |___ \\ / __ \\ โ”‚")
27
- print("โ”‚ _ __ ___ / /_ / __ `/ ___/ __/ /|_/ / / / /_/ / ___/ / / / / / โ”‚")
28
- print("โ”‚ _ __ ___ / __/ / /_/ (__ ) /_/ / / / /___/ ____/ / __/_/ /_/ / โ”‚")
29
- print("โ”‚ _ __ ___ /_/ \\____/____/\\__/_/ /_/\\____/_/ /_____(*)____/ โ”‚")
30
- print("โ”‚ โ”‚")
31
- print("โ”‚ โ”‚")
32
- print("โ”‚ FastMCP 2.0 โ”‚")
33
- print("โ”‚ โ”‚")
34
- print("โ”‚ โ”‚")
35
- print("โ”‚ ๐Ÿ–ฅ๏ธ Server name: sympy_service โ”‚")
36
- print("โ”‚ ๐Ÿ“ฆ Transport: Streamable-HTTP โ”‚")
37
- print("โ”‚ ๐Ÿ”— Server URL: http://0.0.0.0:7860/mcp โ”‚")
38
- print("โ”‚ โ”‚")
39
- print("โ”‚ ๐ŸŽ๏ธ FastMCP version: 2.12.2 โ”‚")
40
- print("โ”‚ ๐Ÿค MCP SDK version: 1.13.1 โ”‚")
41
- print("โ”‚ โ”‚")
42
- print("โ”‚ ๐Ÿ“š Docs: https://gofastmcp.com โ”‚")
43
- print("โ”‚ ๐Ÿš€ Deploy: https://fastmcp.cloud โ”‚")
44
- print("โ”‚ โ”‚")
45
- print("โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ")
46
- print()
47
-
48
  app = create_app()
49
- # Use environment variable to configure port, default 7860 for HF Spaces
50
  port = int(os.environ.get("MCP_PORT", "7860"))
51
-
52
- # Select transport mode based on environment variable
53
- transport = os.environ.get("MCP_TRANSPORT", "http") # Changed default to http
54
  if transport == "http":
55
- # Use uvicorn to run FastAPI app
56
- uvicorn.run(app, host="0.0.0.0", port=port)
57
  else:
58
- # For STDIO mode, we need to handle it differently
59
- # This would require a different approach for STDIO transport
60
- print("STDIO mode not supported with custom FastAPI app")
61
- uvicorn.run(app, host="0.0.0.0", port=port)
62
 
63
  if __name__ == "__main__":
64
  main()
 
1
 
 
 
 
2
  import sys
3
  import os
4
 
 
7
  if mcp_plugin_dir not in sys.path:
8
  sys.path.insert(0, mcp_plugin_dir)
9
 
 
10
  source_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "source")
11
  sys.path.insert(0, source_path)
12
 
13
  from mcp_service import create_app
 
14
 
15
  def main():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  app = create_app()
 
17
  port = int(os.environ.get("MCP_PORT", "7860"))
18
+ transport = os.environ.get("MCP_TRANSPORT", "stdio")
 
 
19
  if transport == "http":
20
+ app.run(transport="http", host="0.0.0.0", port=port)
 
21
  else:
22
+ app.run()
 
 
 
23
 
24
  if __name__ == "__main__":
25
  main()