MCPcopy Create free account
hub / github.com/echoVic/blade-code / handleMessage

Method handleMessage

src/mcp/server/MCPServer.ts:156–189  ·  view source on GitHub ↗

* 处理消息

(clientId: string, message: MCPMessage)

Source from the content-addressed store, hash-verified

154 * 处理消息
155 */
156 private async handleMessage(clientId: string, message: MCPMessage): Promise<void> {
157 try {
158 switch (message.method) {
159 case 'initialize':
160 await this.handleInitialize(clientId, message);
161 break;
162 case 'notifications/initialized':
163 // 客户端初始化完成
164 break;
165 case 'resources/list':
166 await this.handleListResources(clientId, message);
167 break;
168 case 'resources/read':
169 await this.handleReadResource(clientId, message);
170 break;
171 case 'tools/list':
172 await this.handleListTools(clientId, message);
173 break;
174 case 'tools/call':
175 await this.handleCallTool(clientId, message);
176 break;
177 case 'prompts/list':
178 await this.handleListPrompts(clientId, message);
179 break;
180 case 'prompts/get':
181 await this.handleGetPrompt(clientId, message);
182 break;
183 default:
184 this.sendError(clientId, -32601, `Unknown method: ${message.method}`);
185 }
186 } catch (error) {
187 this.sendError(clientId, -32603, 'Internal error', error);
188 }
189 }
190
191 /**
192 * 处理初始化请求

Callers 2

handleConnectionMethod · 0.95
handleStdioConnectionMethod · 0.95

Calls 8

handleInitializeMethod · 0.95
handleListResourcesMethod · 0.95
handleReadResourceMethod · 0.95
handleListToolsMethod · 0.95
handleCallToolMethod · 0.95
handleListPromptsMethod · 0.95
handleGetPromptMethod · 0.95
sendErrorMethod · 0.95

Tested by

no test coverage detected