|
19 | 19 | └─── 消息转发 ───────┴─── 消息转发 ───────┘ |
20 | 20 | ``` |
21 | 21 |
|
22 | | -## 安装依赖 |
| 22 | +## 运行 |
23 | 23 |
|
24 | 24 | ```bash |
25 | | -conda remove -n mcp-endpoint-server --all -y |
26 | | -conda create -n mcp-endpoint-server python=3.10 -y |
27 | | -conda activate mcp-endpoint-server |
28 | 25 |
|
29 | | -pip install -r requirements.txt |
30 | | - |
31 | | -cp mcp-endpoint-server.cfg data/.mcp-endpoint-server.cfg |
32 | | - |
33 | | -``` |
34 | | - |
35 | | -## 配置说明 |
36 | | - |
37 | | -### 配置文件位置 |
38 | | -- 示例配置: `mcp-endpoint-server.cfg` |
39 | | -- 实际配置: `data/.mcp-endpoint-server.cfg` |
40 | | - |
41 | | -### 配置项说明 |
42 | | - |
43 | | -```ini |
44 | | -[server] |
45 | | -host = 127.0.0.1 # 服务器监听地址 |
46 | | -port = 8004 # 服务器监听端口 |
47 | | -debug = false # 调试模式 |
48 | | -log_level = INFO # 日志级别 |
49 | | - |
50 | | -[websocket] |
51 | | -max_connections = 1000 # 最大连接数 |
52 | | -ping_interval = 30 # 心跳间隔(秒) |
53 | | -ping_timeout = 10 # 心跳超时(秒) |
54 | | -close_timeout = 10 # 关闭超时(秒) |
55 | | - |
56 | | -[security] |
57 | | -allowed_origins = * # 允许的源 |
58 | | -enable_cors = true # 启用CORS |
59 | | - |
60 | | -[logging] |
61 | | -log_file = logs/mcp_server.log # 日志文件路径 |
62 | | -max_file_size = 10MB # 日志文件最大大小 |
63 | | -backup_count = 5 # 日志备份数量 |
64 | | -``` |
65 | | - |
66 | | -## 启动服务器 |
67 | | - |
68 | | -```bash |
69 | | -python main.py |
70 | 26 | ``` |
71 | 27 |
|
72 | | -### 测试数据 |
73 | | -```json |
74 | | -{"id":0,"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{"sampling":{},"roots":{"listChanged":false}},"clientInfo":{"name":"xz-mcp-broker","version":"0.0.1"}}} |
75 | | - |
76 | | - |
77 | | -{"jsonrpc":"2.0","method":"notifications/initialized"} |
78 | | - |
79 | | - |
80 | | -{"id":1,"jsonrpc":"2.0","method":"tools/list","params":{}} |
81 | | - |
82 | | - |
83 | | -{"id":2,"jsonrpc":"2.0","method":"ping","params":{}} |
84 | | - |
85 | | - |
86 | | -{"id":10,"jsonrpc":"2.0","method":"tools/call","params":{"name":"calculator","arguments":{"python_expression":"130000 * 130000"},"serialNumber":null}} |
87 | | -``` |
88 | | - |
89 | | -### Docker部署 |
90 | | - |
91 | | -```dockerfile |
92 | | -FROM python:3.9-slim |
93 | | - |
94 | | -WORKDIR /app |
95 | | -COPY requirements.txt . |
96 | | -RUN pip install -r requirements.txt |
97 | | - |
98 | | -COPY . . |
99 | | -EXPOSE 8004 |
100 | | - |
101 | | -CMD ["python", "main.py"] |
102 | | -``` |
103 | | - |
104 | | -## 监控和维护 |
105 | | - |
106 | | -### 日志查看 |
107 | | -```bash |
108 | | -tail -f logs/mcp_server.log |
109 | | -``` |
110 | | - |
111 | | -### 连接状态检查 |
112 | | -```bash |
113 | | -curl http://127.0.0.1:8004/stats |
114 | | -``` |
115 | | - |
116 | | -### 健康检查 |
117 | | -```bash |
118 | | -curl http://127.0.0.1:8004/health |
119 | | -``` |
120 | | - |
121 | | -## 开发说明 |
122 | | - |
123 | | -### 项目结构 |
124 | | -``` |
125 | | -mcp-endpoint-server/ |
126 | | -├── src/ |
127 | | -│ ├── core/ # 核心模块 |
128 | | -│ │ └── connection_manager.py |
129 | | -│ ├── handlers/ # 处理器 |
130 | | -│ │ └── websocket_handler.py |
131 | | -│ ├── utils/ # 工具模块 |
132 | | -│ │ ├── config.py |
133 | | -│ │ └── logger.py |
134 | | -│ └── server.py # 主服务器 |
135 | | -├── data/ # 配置文件目录 |
136 | | -├── logs/ # 日志目录 |
137 | | -├── main.py # 主入口 |
138 | | -├── requirements.txt # 依赖文件 |
139 | | -└── README.md # 说明文档 |
140 | | -``` |
| 28 | +## 技术细节 |
| 29 | +[技术细节](./README_dev.md) |
0 commit comments