6
6
CallToolRequestSchema ,
7
7
CallToolRequest ,
8
8
InitializeRequest ,
9
- InitializeRequestSchema , // <-- Import InitializeRequestSchema
10
- ToolDefinition // <-- Import ToolDefinition
9
+ InitializeRequestSchema
10
+ // Removed ToolDefinition import as it's not found
11
11
} from "@modelcontextprotocol/sdk/types.js" ;
12
12
import { vibeCheckTool } from "./tools/vibeCheck.js" ;
13
13
import { vibeDistillTool } from "./tools/vibeDistill.js" ;
@@ -22,39 +22,33 @@ try {
22
22
const apiKey = process . env . GEMINI_API_KEY ;
23
23
if ( ! apiKey ) {
24
24
console . error ( "MCP Server: WARNING - GEMINI_API_KEY environment variable not found!" ) ;
25
- // Continue without Gemini if key is missing, tools might fail later
26
25
} else {
27
26
initializeGemini ( apiKey ) ;
28
27
console . error ( "MCP Server: Gemini client potentially initialized." ) ;
29
28
}
30
29
} catch ( err : any ) {
31
30
console . error ( "MCP Server: ERROR initializing Gemini client -" , err ) ;
32
- // Continue anyway, tools using it will fail
33
31
}
34
32
// ------------------------------------
35
33
36
- // Define the type for the 'cat' parameter explicitly
37
34
type CategorySummaryItem = {
38
35
category : string ;
39
36
count : number ;
40
37
recentExample : MistakeEntry ;
41
38
} ;
42
39
43
- // Create server instance
44
40
console . error ( "MCP Server: Creating Server instance..." ) ;
45
41
const server = new Server ( {
46
42
name : "vibe-check-mcp" ,
47
43
version : "0.2.0"
48
44
} ) ;
49
45
console . error ( "MCP Server: Server instance created." ) ;
50
46
51
- // --- Add an explicit Initialize handler ---
52
- // Use the Schema as the first argument, not the string "initialize"
47
+ // --- Initialize handler ---
53
48
server . setRequestHandler ( InitializeRequestSchema , async ( request : InitializeRequest ) => {
54
- // Cannot reliably log request.id here based on type errors
55
49
console . error ( `MCP Server: Received initialize request` ) ;
56
50
const response = {
57
- protocolVersion : request . params . protocolVersion , // Echo back client's version
51
+ protocolVersion : request . params . protocolVersion ,
58
52
serverInfo : {
59
53
name : "vibe-check-mcp" ,
60
54
version : "0.2.0" ,
@@ -70,8 +64,8 @@ server.setRequestHandler(InitializeRequestSchema, async (request: InitializeRequ
70
64
console . error ( "MCP Server: Setting ListTools request handler..." ) ;
71
65
server . setRequestHandler ( ListToolsRequestSchema , async ( ) => {
72
66
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 = [
75
69
{
76
70
name : "vibe_check" ,
77
71
description : "Metacognitive check for plan alignment and assumption testing." ,
@@ -80,12 +74,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
80
74
properties : {
81
75
plan : { type : "string" } ,
82
76
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 ...
89
78
confidence : { type : "number" }
90
79
} ,
91
80
required : [ "plan" , "userRequest" ]
@@ -120,7 +109,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
120
109
}
121
110
] ;
122
111
console . error ( "MCP Server: Returning tool list." ) ;
123
- return { tools } ; // Type 'tools' variable here
112
+ return { tools } ;
124
113
} ) ;
125
114
console . error ( "MCP Server: ListTools request handler set." ) ;
126
115
@@ -130,7 +119,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest)
130
119
const toolName = request . params . name ;
131
120
const args = request . params . arguments ?? { } ;
132
121
133
- // Cannot reliably log request.id here based on type errors
134
122
console . error ( `MCP Server: CallToolRequest received for tool: ${ toolName } ` ) ;
135
123
136
124
try {
@@ -176,8 +164,13 @@ console.error("MCP Server: Connecting server to transport...");
176
164
server . connect ( transport ) ;
177
165
console . error ( "MCP Server: Server connected to transport. Ready for messages." ) ;
178
166
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
+
183
176
// Removed listener for non-existent onDidDispose
0 commit comments