-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_mcp.py
More file actions
55 lines (45 loc) · 1.24 KB
/
Copy pathtest_mcp.py
File metadata and controls
55 lines (45 loc) · 1.24 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
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
簡化的 MCP Server 測試版本
"""
import sys
from mcp.server.fastmcp import FastMCP
# 初始化 MCP server
mcp = FastMCP("Test Stock Analysis Server")
@mcp.tool()
def hello_world() -> str:
"""
測試工具:返回 Hello World
Returns:
簡單的問候語
"""
return "Hello from Taiwan Stock Analysis MCP Server!"
@mcp.tool()
def get_server_status() -> dict:
"""
獲取伺服器狀態
Returns:
伺服器狀態信息
"""
return {
"status": "running",
"server": "Taiwan Stock Analysis",
"version": "1.0.0"
}
def main():
"""啟動簡化的 MCP server"""
try:
print("正在啟動簡化的 MCP Server...", file=sys.stderr)
print("Server 名稱: Test Stock Analysis Server", file=sys.stderr)
print("可用工具: hello_world, get_server_status", file=sys.stderr)
print("正在等待連接...", file=sys.stderr)
# 啟動 MCP server
mcp.run(transport="stdio")
except Exception as e:
print(f"MCP Server 啟動失敗: {str(e)}", file=sys.stderr)
import traceback
traceback.print_exc(file=sys.stderr)
return
if __name__ == "__main__":
main()