chore: import upstream snapshot with attribution
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
import os
|
||||
import sys
|
||||
from server import server
|
||||
|
||||
if __name__ == "__main__":
|
||||
"""Main entry point"""
|
||||
transport_type = sys.argv[1] if len(sys.argv) > 1 else None
|
||||
server.settings.log_level = os.environ.get("LOG_LEVEL", "DEBUG")
|
||||
if transport_type == "sse":
|
||||
port = int(os.environ.get("PORT", 3001))
|
||||
server.settings.port = port
|
||||
server.settings.host = "127.0.0.1"
|
||||
server.run(transport="sse")
|
||||
elif transport_type == "stdio":
|
||||
server.run(transport="stdio")
|
||||
else:
|
||||
print("Invalid transport type. Use 'sse' or 'stdio'.")
|
||||
sys.exit(1)
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import json
|
||||
import random
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
# Initialize FastMCP server
|
||||
server = FastMCP("weather_mcp")
|
||||
|
||||
@server.tool()
|
||||
async def get_weather(location: str) -> str:
|
||||
"""Get weather for a location.
|
||||
|
||||
Args:
|
||||
location: Location to get weather for, e.g., city name, state, or coordinates
|
||||
|
||||
"""
|
||||
if not location:
|
||||
return "Location is required."
|
||||
|
||||
# mock weather data
|
||||
conditions = [ "Sunny", "Rainy", "Cloudy", "Snowy" ]
|
||||
weather = {
|
||||
"location": location,
|
||||
"temperature": f"{random.randint(10, 90)}°F",
|
||||
"condition": random.choice(conditions),
|
||||
}
|
||||
return json.dumps(weather, ensure_ascii=False)
|
||||
Reference in New Issue
Block a user