MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / handleMessage

Method handleMessage

src/mcp/session.ts:143–183  ·  view source on GitHub ↗
(message: JsonRpcRequest | JsonRpcNotification)

Source from the content-addressed store, hash-verified

141 }
142
143 private async handleMessage(message: JsonRpcRequest | JsonRpcNotification): Promise<void> {
144 const isRequest = 'id' in message;
145 switch (message.method) {
146 case 'initialize':
147 if (isRequest) await this.handleInitialize(message as JsonRpcRequest);
148 break;
149 case 'initialized':
150 // Notification that client has finished initialization — no action needed.
151 break;
152 case 'tools/list':
153 if (isRequest) await this.handleToolsList(message as JsonRpcRequest);
154 break;
155 case 'tools/call':
156 if (isRequest) await this.handleToolsCall(message as JsonRpcRequest);
157 break;
158 case 'ping':
159 if (isRequest) this.transport.sendResult((message as JsonRpcRequest).id, {});
160 break;
161 case 'resources/list':
162 // We expose no MCP resources, but some clients (opencode, Codex) probe
163 // for them on connect; reply with an empty list instead of a
164 // MethodNotFound error that surfaces as a scary `-32601` log line. (#621)
165 if (isRequest) this.transport.sendResult((message as JsonRpcRequest).id, { resources: [] });
166 break;
167 case 'resources/templates/list':
168 if (isRequest) this.transport.sendResult((message as JsonRpcRequest).id, { resourceTemplates: [] });
169 break;
170 case 'prompts/list':
171 // Likewise — no prompts exposed, but answer the probe cleanly. (#621)
172 if (isRequest) this.transport.sendResult((message as JsonRpcRequest).id, { prompts: [] });
173 break;
174 default:
175 if (isRequest) {
176 this.transport.sendError(
177 (message as JsonRpcRequest).id,
178 ErrorCodes.MethodNotFound,
179 `Method not found: ${message.method}`,
180 );
181 }
182 }
183 }
184
185 private async handleInitialize(request: JsonRpcRequest): Promise<void> {
186 const params = request.params as {

Callers

nothing calls this directly

Calls 5

handleInitializeMethod · 0.95
handleToolsListMethod · 0.95
handleToolsCallMethod · 0.95
sendResultMethod · 0.80
sendErrorMethod · 0.80

Tested by

no test coverage detected