@@ -17,6 +17,15 @@ export class MCPDevlogAdapter {
1717 this . devlogManager = new DevlogManager ( ) ;
1818 }
1919
20+ // Helper function to parse string ID to number
21+ private parseId ( idStr : string ) : number {
22+ const id = parseInt ( idStr , 10 ) ;
23+ if ( isNaN ( id ) ) {
24+ throw new Error ( `Invalid devlog ID "${ idStr } ". Must be a number.` ) ;
25+ }
26+ return id ;
27+ }
28+
2029 /**
2130 * Initialize the adapter with appropriate storage configuration
2231 */
@@ -63,7 +72,8 @@ export class MCPDevlogAdapter {
6372 async getDevlog ( args : { id : string } ) : Promise < CallToolResult > {
6473 await this . ensureInitialized ( ) ;
6574
66- const entry = await this . devlogManager . getDevlog ( args . id ) ;
75+ const id = this . parseId ( args . id ) ;
76+ const entry = await this . devlogManager . getDevlog ( id ) ;
6777
6878 if ( ! entry ) {
6979 return {
@@ -156,8 +166,9 @@ export class MCPDevlogAdapter {
156166 async addDevlogNote ( args : { id : string ; note : string ; category ?: string } ) : Promise < CallToolResult > {
157167 await this . ensureInitialized ( ) ;
158168
169+ const id = this . parseId ( args . id ) ;
159170 const category = args . category as any || "progress" ;
160- const entry = await this . devlogManager . addNote ( args . id , args . note , category ) ;
171+ const entry = await this . devlogManager . addNote ( id , args . note , category ) ;
161172
162173 return {
163174 content : [
@@ -172,7 +183,8 @@ export class MCPDevlogAdapter {
172183 async addDecision ( args : { id : string ; decision : string ; rationale : string ; decisionMaker : string ; alternatives ?: string [ ] } ) : Promise < CallToolResult > {
173184 await this . ensureInitialized ( ) ;
174185
175- const entry = await this . devlogManager . getDevlog ( args . id ) ;
186+ const id = this . parseId ( args . id ) ;
187+ const entry = await this . devlogManager . getDevlog ( id ) ;
176188 if ( ! entry ) {
177189 return {
178190 content : [
@@ -198,7 +210,7 @@ export class MCPDevlogAdapter {
198210
199211 // Update the entry to trigger save
200212 const updated = await this . devlogManager . updateDevlog ( {
201- id : args . id ,
213+ id : id ,
202214 // Use a field that exists in UpdateDevlogRequest to trigger save
203215 tags : entry . tags
204216 } ) ;
@@ -216,7 +228,8 @@ export class MCPDevlogAdapter {
216228 async completeDevlog ( args : { id : string ; summary ?: string } ) : Promise < CallToolResult > {
217229 await this . ensureInitialized ( ) ;
218230
219- const entry = await this . devlogManager . completeDevlog ( args . id , args . summary ) ;
231+ const id = this . parseId ( args . id ) ;
232+ const entry = await this . devlogManager . completeDevlog ( id , args . summary ) ;
220233
221234 return {
222235 content : [
@@ -271,7 +284,8 @@ export class MCPDevlogAdapter {
271284 async getContextForAI ( args : { id : string } ) : Promise < CallToolResult > {
272285 await this . ensureInitialized ( ) ;
273286
274- const entry = await this . devlogManager . getContextForAI ( args . id ) ;
287+ const id = this . parseId ( args . id ) ;
288+ const entry = await this . devlogManager . getContextForAI ( id ) ;
275289
276290 if ( ! entry ) {
277291 return {
@@ -320,6 +334,7 @@ export class MCPDevlogAdapter {
320334 } ) : Promise < CallToolResult > {
321335 await this . ensureInitialized ( ) ;
322336
337+ const id = this . parseId ( args . id ) ;
323338 const contextUpdate : any = { } ;
324339
325340 if ( args . summary ) contextUpdate . currentSummary = args . summary ;
@@ -331,7 +346,7 @@ export class MCPDevlogAdapter {
331346 contextUpdate . lastAIUpdate = new Date ( ) . toISOString ( ) ;
332347 contextUpdate . contextVersion = ( contextUpdate . contextVersion || 0 ) + 1 ;
333348
334- const entry = await this . devlogManager . updateAIContext ( args . id , contextUpdate ) ;
349+ const entry = await this . devlogManager . updateAIContext ( id , contextUpdate ) ;
335350
336351 return {
337352 content : [
0 commit comments