cloudflare-mcp-smart-proxy 1.0.1 → 1.0.2

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 CHANGED
@@ -7,7 +7,12 @@
7
7
 
8
8
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
9
9
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
10
- import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
10
+ import {
11
+ ListToolsRequestSchema,
12
+ CallToolRequestSchema,
13
+ ListPromptsRequestSchema,
14
+ GetPromptRequestSchema
15
+ } from '@modelcontextprotocol/sdk/types.js';
11
16
  import { SmartRouter } from './src/router.js';
12
17
  import { LocalToolExecutor } from './src/local-tools.js';
13
18
 
@@ -38,6 +43,7 @@ const server = new Server(
38
43
  {
39
44
  capabilities: {
40
45
  tools: {},
46
+ prompts: {},
41
47
  },
42
48
  }
43
49
  );
@@ -103,6 +109,85 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
103
109
  }
104
110
  });
105
111
 
112
+ // 提示词列表处理器 - 转发到云端
113
+ server.setRequestHandler(ListPromptsRequestSchema, async () => {
114
+ try {
115
+ const response = await fetch(`${CLOUD_URL}/mcp`, {
116
+ method: 'POST',
117
+ headers: {
118
+ 'Authorization': `Bearer ${CLOUD_API_KEY}`,
119
+ 'Content-Type': 'application/json'
120
+ },
121
+ body: JSON.stringify({
122
+ jsonrpc: '2.0',
123
+ id: Date.now(),
124
+ method: 'prompts/list',
125
+ params: {}
126
+ })
127
+ });
128
+
129
+ if (!response.ok) {
130
+ throw new Error(`Cloud request failed: ${response.status}`);
131
+ }
132
+
133
+ const result = await response.json();
134
+
135
+ if (result.error) {
136
+ throw new Error(result.error.message || 'Failed to list prompts');
137
+ }
138
+
139
+ return result.result || { prompts: [] };
140
+ } catch (error) {
141
+ console.error('Error listing prompts:', error);
142
+ return { prompts: [] };
143
+ }
144
+ });
145
+
146
+ // 获取提示词处理器 - 转发到云端
147
+ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
148
+ try {
149
+ const { name, arguments: promptArgs } = request.params || {};
150
+
151
+ const response = await fetch(`${CLOUD_URL}/mcp`, {
152
+ method: 'POST',
153
+ headers: {
154
+ 'Authorization': `Bearer ${CLOUD_API_KEY}`,
155
+ 'Content-Type': 'application/json'
156
+ },
157
+ body: JSON.stringify({
158
+ jsonrpc: '2.0',
159
+ id: Date.now(),
160
+ method: 'prompts/get',
161
+ params: {
162
+ name,
163
+ arguments: promptArgs
164
+ }
165
+ })
166
+ });
167
+
168
+ if (!response.ok) {
169
+ throw new Error(`Cloud request failed: ${response.status}`);
170
+ }
171
+
172
+ const result = await response.json();
173
+
174
+ if (result.error) {
175
+ throw new Error(result.error.message || 'Failed to get prompt');
176
+ }
177
+
178
+ return result.result || {
179
+ description: '',
180
+ messages: []
181
+ };
182
+ } catch (error) {
183
+ console.error(`Error getting prompt:`, error);
184
+ return {
185
+ description: '',
186
+ messages: []
187
+ };
188
+ }
189
+ });
190
+
106
191
  // 启动服务器
107
192
  async function main() {
108
193
  try {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-mcp-smart-proxy",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Smart proxy for Cloudflare MCP - routes tools to cloud or local execution",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -26,4 +26,3 @@
26
26
  "node": ">=18.0.0"
27
27
  }
28
28
  }
29
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-mcp-smart-proxy",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Smart proxy for Cloudflare MCP - routes tools to cloud or local execution",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/src/router.js CHANGED
@@ -56,7 +56,11 @@ export class SmartRouter {
56
56
  'sequentialthinking',
57
57
  'get_config',
58
58
  'set_config',
59
- 'codebase_search' // R2 存储的代码库搜索
59
+ 'codebase_search', // R2 存储的代码库搜索
60
+ 'read_r2_file', // R2 存储文件读取
61
+ 'write_r2_file', // R2 存储文件写入
62
+ 'list_r2_dir', // R2 存储目录列表
63
+ 'execute_cloud_command' // 云端命令执行
60
64
  ]
61
65
  };
62
66
  }