Skip to content

Commit da0aa42

Browse files
authored
Update index.ts
1 parent b9a631c commit da0aa42

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

src/index.ts

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {
66
CallToolRequestSchema,
77
CallToolRequest,
88
InitializeRequest,
9-
InitializeRequestSchema, // <-- Import InitializeRequestSchema
10-
ToolDefinition // <-- Import ToolDefinition
9+
InitializeRequestSchema
10+
// Removed ToolDefinition import as it's not found
1111
} from "@modelcontextprotocol/sdk/types.js";
1212
import { vibeCheckTool } from "./tools/vibeCheck.js";
1313
import { vibeDistillTool } from "./tools/vibeDistill.js";
@@ -22,39 +22,33 @@ try {
2222
const apiKey = process.env.GEMINI_API_KEY;
2323
if (!apiKey) {
2424
console.error("MCP Server: WARNING - GEMINI_API_KEY environment variable not found!");
25-
// Continue without Gemini if key is missing, tools might fail later
2625
} else {
2726
initializeGemini(apiKey);
2827
console.error("MCP Server: Gemini client potentially initialized.");
2928
}
3029
} catch (err: any) {
3130
console.error("MCP Server: ERROR initializing Gemini client -", err);
32-
// Continue anyway, tools using it will fail
3331
}
3432
// ------------------------------------
3533

36-
// Define the type for the 'cat' parameter explicitly
3734
type CategorySummaryItem = {
3835
category: string;
3936
count: number;
4037
recentExample: MistakeEntry;
4138
};
4239

43-
// Create server instance
4440
console.error("MCP Server: Creating Server instance...");
4541
const server = new Server({
4642
name: "vibe-check-mcp",
4743
version: "0.2.0"
4844
});
4945
console.error("MCP Server: Server instance created.");
5046

51-
// --- Add an explicit Initialize handler ---
52-
// Use the Schema as the first argument, not the string "initialize"
47+
// --- Initialize handler ---
5348
server.setRequestHandler(InitializeRequestSchema, async (request: InitializeRequest) => {
54-
// Cannot reliably log request.id here based on type errors
5549
console.error(`MCP Server: Received initialize request`);
5650
const response = {
57-
protocolVersion: request.params.protocolVersion, // Echo back client's version
51+
protocolVersion: request.params.protocolVersion,
5852
serverInfo: {
5953
name: "vibe-check-mcp",
6054
version: "0.2.0",
@@ -70,8 +64,8 @@ server.setRequestHandler(InitializeRequestSchema, async (request: InitializeRequ
7064
console.error("MCP Server: Setting ListTools request handler...");
7165
server.setRequestHandler(ListToolsRequestSchema, async () => {
7266
console.error("MCP Server: ListTools request received.");
73-
// Explicitly type the tools array
74-
const tools: ToolDefinition[] = [
67+
// Remove explicit ToolDefinition[] type, let TypeScript infer
68+
const tools = [
7569
{
7670
name: "vibe_check",
7771
description: "Metacognitive check for plan alignment and assumption testing.",
@@ -80,12 +74,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
8074
properties: {
8175
plan: { type: "string" },
8276
userRequest: { type: "string" },
83-
thinkingLog: { type: "string" },
84-
availableTools: { type: "array", items: { type: "string" } },
85-
focusAreas: { type: "array", items: { type: "string" } },
86-
sessionId: { type: "string" },
87-
previousAdvice: { type: "string" },
88-
phase: { type: "string", enum: ["planning", "implementation", "review"] },
77+
// ... other properties ...
8978
confidence: { type: "number" }
9079
},
9180
required: ["plan", "userRequest"]
@@ -120,7 +109,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
120109
}
121110
];
122111
console.error("MCP Server: Returning tool list.");
123-
return { tools }; // Type 'tools' variable here
112+
return { tools };
124113
});
125114
console.error("MCP Server: ListTools request handler set.");
126115

@@ -130,7 +119,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest)
130119
const toolName = request.params.name;
131120
const args = request.params.arguments ?? {};
132121

133-
// Cannot reliably log request.id here based on type errors
134122
console.error(`MCP Server: CallToolRequest received for tool: ${toolName}`);
135123

136124
try {
@@ -176,8 +164,13 @@ console.error("MCP Server: Connecting server to transport...");
176164
server.connect(transport);
177165
console.error("MCP Server: Server connected to transport. Ready for messages.");
178166

179-
// Use the corrected event name 'onclose'
180-
transport.onclose(() => { // <-- Corrected event name
181-
console.error("MCP Server: Transport closed event received.");
182-
});
167+
// Assign callback to 'onclose' property instead of calling it
168+
if (transport.onclose) { // Check if property exists
169+
transport.onclose = () => { // Assign the callback function
170+
console.error("MCP Server: Transport closed event received.");
171+
};
172+
} else {
173+
console.error("MCP Server: transport.onclose property not found.");
174+
}
175+
183176
// Removed listener for non-existent onDidDispose

0 commit comments

Comments
 (0)