aira-mcp 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +49 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -142,18 +142,55 @@ app.delete('/download/:gid', async (req, res) => {
|
|
|
142
142
|
function handleMCPRequest(request) {
|
|
143
143
|
process.stderr.write(`Received MCP request: ${JSON.stringify(request)}\n`);
|
|
144
144
|
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
145
|
+
// 根据请求方法返回不同的响应
|
|
146
|
+
if (request.method === 'initialize') {
|
|
147
|
+
// 处理initialize请求,返回符合MCP协议规范的响应
|
|
148
|
+
const response = {
|
|
149
|
+
jsonrpc: '2.0',
|
|
150
|
+
id: request.id,
|
|
151
|
+
result: {
|
|
152
|
+
protocolVersion: '2025-06-18',
|
|
153
|
+
capabilities: {
|
|
154
|
+
// 描述服务支持的功能
|
|
155
|
+
httpServer: {
|
|
156
|
+
port: port,
|
|
157
|
+
endpoints: {
|
|
158
|
+
'/health': 'GET',
|
|
159
|
+
'/download': 'POST',
|
|
160
|
+
'/download/magnet': 'POST',
|
|
161
|
+
'/download/{gid}': 'GET',
|
|
162
|
+
'/download/{gid}/pause': 'POST',
|
|
163
|
+
'/download/{gid}/resume': 'POST',
|
|
164
|
+
'/download/{gid}': 'DELETE'
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
aria2: {
|
|
168
|
+
supportedMethods: ['addUri', 'tellStatus', 'pause', 'unpause', 'remove']
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
serverInfo: {
|
|
172
|
+
name: 'Aira MCP Service',
|
|
173
|
+
version: '1.0.3',
|
|
174
|
+
description: 'Aria2 MCP (Model Context Protocol) Service CLI',
|
|
175
|
+
author: '',
|
|
176
|
+
license: 'ISC'
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
return response;
|
|
181
|
+
} else {
|
|
182
|
+
// 处理其他请求
|
|
183
|
+
const response = {
|
|
184
|
+
jsonrpc: '2.0',
|
|
185
|
+
id: request.id,
|
|
186
|
+
result: {
|
|
187
|
+
message: 'MCP Service is running',
|
|
188
|
+
httpPort: port,
|
|
189
|
+
status: 'ok'
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
return response;
|
|
193
|
+
}
|
|
157
194
|
}
|
|
158
195
|
|
|
159
196
|
// 启动HTTP服务器
|