MCPcopy
hub / github.com/colbymchenry/codegraph / handleMessage

Method handleMessage

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

Source from the content-addressed store, hash-verified

119 }
120
121 private async handleMessage(message: JsonRpcRequest | JsonRpcNotification): Promise<void> {
122 const isRequest = 'id' in message;
123 switch (message.method) {
124 case 'initialize':
125 if (isRequest) await this.handleInitialize(message as JsonRpcRequest);
126 break;
127 case 'initialized':
128 // Notification that client has finished initialization — no action needed.
129 break;
130 case 'tools/list':
131 if (isRequest) await this.handleToolsList(message as JsonRpcRequest);
132 break;
133 case 'tools/call':
134 if (isRequest) await this.handleToolsCall(message as JsonRpcRequest);
135 break;
136 case 'ping':
137 if (isRequest) this.transport.sendResult((message as JsonRpcRequest).id, {});
138 break;
139 case 'resources/list':
140 // We expose no MCP resources, but some clients (opencode, Codex) probe
141 // for them on connect; reply with an empty list instead of a
142 // MethodNotFound error that surfaces as a scary `-32601` log line. (#621)
143 if (isRequest) this.transport.sendResult((message as JsonRpcRequest).id, { resources: [] });
144 break;
145 case 'resources/templates/list':
146 if (isRequest) this.transport.sendResult((message as JsonRpcRequest).id, { resourceTemplates: [] });
147 break;
148 case 'prompts/list':
149 // Likewise — no prompts exposed, but answer the probe cleanly. (#621)
150 if (isRequest) this.transport.sendResult((message as JsonRpcRequest).id, { prompts: [] });
151 break;
152 default:
153 if (isRequest) {
154 this.transport.sendError(
155 (message as JsonRpcRequest).id,
156 ErrorCodes.MethodNotFound,
157 `Method not found: ${message.method}`,
158 );
159 }
160 }
161 }
162
163 private async handleInitialize(request: JsonRpcRequest): Promise<void> {
164 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