update
Browse files
app.py
CHANGED
|
@@ -1,29 +1,18 @@
|
|
| 1 |
-
# app.py
|
| 2 |
from mcp.server.fastmcp import FastMCP
|
| 3 |
|
| 4 |
-
# Create an MCP server
|
| 5 |
# mcp = FastMCP("Demo", root_path="/app01", message_path="/messages", sse_path="/sse")
|
| 6 |
-
mcp = FastMCP("Demo", root_path="/app01
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
# Add an addition tool
|
| 10 |
@mcp.tool()
|
| 11 |
def add(a: int, b: int) -> int:
|
| 12 |
-
"""Add two numbers"""
|
| 13 |
return a + b
|
| 14 |
|
| 15 |
-
|
| 16 |
-
# Add a dynamic greeting resource
|
| 17 |
@mcp.resource("greeting://{name}")
|
| 18 |
def get_greeting(name: str) -> str:
|
| 19 |
-
"""Get a personalized greeting"""
|
| 20 |
return f"Hello, {name}!"
|
| 21 |
|
| 22 |
-
if
|
| 23 |
-
# mcp.run(transport='stdio')
|
| 24 |
-
# mcp.run(mount_path="/app01/", transport='sse')
|
| 25 |
-
|
| 26 |
mcp.settings.host = '0.0.0.0'
|
| 27 |
mcp.settings.port = 7860
|
| 28 |
-
# mcp.run(transport='sse', allowed_methods=["POST"])
|
| 29 |
mcp.run(transport='sse')
|
|
|
|
|
|
|
| 1 |
from mcp.server.fastmcp import FastMCP
|
| 2 |
|
|
|
|
| 3 |
# mcp = FastMCP("Demo", root_path="/app01", message_path="/messages", sse_path="/sse")
|
| 4 |
+
# mcp = FastMCP("Demo", root_path="/app01", message_path="/messages", sse_path="/app01/sse")
|
| 5 |
+
mcp = FastMCP("Demo", message_path="/messages/", sse_path="/app01/sse")
|
| 6 |
|
|
|
|
|
|
|
| 7 |
@mcp.tool()
|
| 8 |
def add(a: int, b: int) -> int:
|
|
|
|
| 9 |
return a + b
|
| 10 |
|
|
|
|
|
|
|
| 11 |
@mcp.resource("greeting://{name}")
|
| 12 |
def get_greeting(name: str) -> str:
|
|
|
|
| 13 |
return f"Hello, {name}!"
|
| 14 |
|
| 15 |
+
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
| 16 |
mcp.settings.host = '0.0.0.0'
|
| 17 |
mcp.settings.port = 7860
|
|
|
|
| 18 |
mcp.run(transport='sse')
|