-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathaicc_server.py
More file actions
44 lines (31 loc) · 1.12 KB
/
aicc_server.py
File metadata and controls
44 lines (31 loc) · 1.12 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
# -*- coding: utf-8 -*-
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates
# SPDX-License-Identifier: MIT
import asyncio
import uvicorn
from pathlib import Path
from bytedance.jeddak_trusted_mcp import TrustedMCP
aicc_config_path = Path(__file__).parent / "server_config.json"
weather_mcp = TrustedMCP(name="Weather service", aicc_config_path=aicc_config_path)
@weather_mcp.tool()
def get_weather(city: str) -> dict:
"""Get current weather for a city (e.g. "beijing")."""
import httpx
return (
httpx.get(f"https://wttr.in/{city}?format=j1")
.json()
.get("current_condition")[0]
)
async def main() -> None:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--host", type=str, default="0.0.0.0")
parser.add_argument("--port", type=int, default=8000)
args = parser.parse_args()
uvicorn_config = uvicorn.Config(
weather_mcp.streamable_http_app(), host=args.host, port=args.port
)
server = uvicorn.Server(uvicorn_config)
await server.serve()
if __name__ == "__main__":
asyncio.run(main())