@@ -94,6 +94,7 @@ const recipes = {
9494const tools = [
9595 {
9696 name : 'get_api_docs' ,
97+ title : 'Get API docs' ,
9798 description : 'Return the compact API notes for @crup/react-timer-hook.' ,
9899 inputSchema : {
99100 type : 'object' ,
@@ -103,6 +104,7 @@ const tools = [
103104 } ,
104105 {
105106 name : 'get_recipe' ,
107+ title : 'Get recipe' ,
106108 description : 'Return guidance for a named recipe or use case.' ,
107109 inputSchema : {
108110 type : 'object' ,
@@ -118,6 +120,7 @@ const tools = [
118120 } ,
119121 {
120122 name : 'search_docs' ,
123+ title : 'Search docs' ,
121124 description : 'Search API and recipe notes for a query.' ,
122125 inputSchema : {
123126 type : 'object' ,
@@ -146,6 +149,12 @@ rl.on('line', line => {
146149 }
147150
148151 const { id, method, params } = request ;
152+ const hasId = Object . hasOwn ( request , 'id' ) ;
153+
154+ if ( ! method ) {
155+ if ( hasId ) respondError ( id , - 32600 , 'Invalid request: missing method.' ) ;
156+ return ;
157+ }
149158
150159 if ( method === 'initialize' ) {
151160 respond ( id , {
@@ -156,6 +165,15 @@ rl.on('line', line => {
156165 return ;
157166 }
158167
168+ if ( method === 'notifications/initialized' || method . startsWith ( 'notifications/' ) ) {
169+ return ;
170+ }
171+
172+ if ( method === 'ping' ) {
173+ if ( hasId ) respond ( id , { } ) ;
174+ return ;
175+ }
176+
159177 if ( method === 'resources/list' ) {
160178 respond ( id , {
161179 resources : Object . entries ( resources ) . map ( ( [ uri , resource ] ) => ( {
@@ -231,7 +249,7 @@ rl.on('line', line => {
231249 return ;
232250 }
233251
234- respondError ( id , - 32601 , `Method not found: ${ method } ` ) ;
252+ if ( hasId ) respondError ( id , - 32601 , `Method not found: ${ method } ` ) ;
235253} ) ;
236254
237255function respond ( id , result ) {
@@ -243,6 +261,7 @@ function respondTool(id, text) {
243261}
244262
245263function respondError ( id , code , message ) {
264+ if ( id === undefined ) return ;
246265 process . stdout . write ( `${ JSON . stringify ( { jsonrpc : '2.0' , id, error : { code, message } } ) } \n` ) ;
247266}
248267
0 commit comments