From 0fd73ec04e8fb9a5d7fa855885274733a52c2994 Mon Sep 17 00:00:00 2001 From: Admin Date: Mon, 17 Mar 2025 14:18:37 -0700 Subject: [PATCH] Add debug info to create_note handler response --- build/index.js | 20 +++++++++++++++++--- index.ts | 27 ++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/build/index.js b/build/index.js index ef785bf..817219f 100755 --- a/build/index.js +++ b/build/index.js @@ -541,10 +541,24 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { try { const args = CreateNoteSchema.parse(request.params.arguments); const { project_id, noteable_type, noteable_iid, body } = args; - const note = await createNote(project_id, noteable_type, noteable_iid, body); - return { - content: [{ type: "text", text: JSON.stringify(note, null, 2) }], + // Debug info that will be included in the response + const debugInfo = { + gitlab_api_url: GITLAB_API_URL, + project_id, + noteable_type, + noteable_iid, + constructed_url: `${GITLAB_API_URL}/projects/${encodeURIComponent(project_id)}/${noteable_type}s/${noteable_iid}/notes` }; + try { + const note = await createNote(project_id, noteable_type, noteable_iid, body); + return { + content: [{ type: "text", text: JSON.stringify(note, null, 2) }], + }; + } + catch (error) { + // Include debug info in the error message + throw new Error(`Error with debug info: ${JSON.stringify(debugInfo)}\n${error instanceof Error ? error.message : String(error)}`); + } } catch (error) { if (error instanceof z.ZodError) { diff --git a/index.ts b/index.ts index 34c075f..37ffeb1 100644 --- a/index.ts +++ b/index.ts @@ -835,15 +835,32 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { try { const args = CreateNoteSchema.parse(request.params.arguments); const { project_id, noteable_type, noteable_iid, body } = args; - const note = await createNote( + + // Debug info that will be included in the response + const debugInfo = { + gitlab_api_url: GITLAB_API_URL, project_id, noteable_type, noteable_iid, - body - ); - return { - content: [{ type: "text", text: JSON.stringify(note, null, 2) }], + constructed_url: `${GITLAB_API_URL}/projects/${encodeURIComponent(project_id)}/${noteable_type}s/${noteable_iid}/notes` }; + + try { + const note = await createNote( + project_id, + noteable_type, + noteable_iid, + body + ); + return { + content: [{ type: "text", text: JSON.stringify(note, null, 2) }], + }; + } catch (error) { + // Include debug info in the error message + throw new Error( + `Error with debug info: ${JSON.stringify(debugInfo)}\n${error instanceof Error ? error.message : String(error)}` + ); + } } catch (error) { if (error instanceof z.ZodError) { throw new Error(