Add debug info to create_note handler response

This commit is contained in:
Admin
2025-03-17 14:18:37 -07:00
parent 51641d7b9b
commit 0fd73ec04e
2 changed files with 39 additions and 8 deletions

View File

@ -541,10 +541,24 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
try { try {
const args = CreateNoteSchema.parse(request.params.arguments); const args = CreateNoteSchema.parse(request.params.arguments);
const { project_id, noteable_type, noteable_iid, body } = args; const { project_id, noteable_type, noteable_iid, body } = args;
const note = await createNote(project_id, noteable_type, noteable_iid, body); // Debug info that will be included in the response
return { const debugInfo = {
content: [{ type: "text", text: JSON.stringify(note, null, 2) }], 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) { catch (error) {
if (error instanceof z.ZodError) { if (error instanceof z.ZodError) {

View File

@ -835,15 +835,32 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
try { try {
const args = CreateNoteSchema.parse(request.params.arguments); const args = CreateNoteSchema.parse(request.params.arguments);
const { project_id, noteable_type, noteable_iid, body } = args; 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, project_id,
noteable_type, noteable_type,
noteable_iid, noteable_iid,
body constructed_url: `${GITLAB_API_URL}/projects/${encodeURIComponent(project_id)}/${noteable_type}s/${noteable_iid}/notes`
);
return {
content: [{ type: "text", text: JSON.stringify(note, null, 2) }],
}; };
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) { } catch (error) {
if (error instanceof z.ZodError) { if (error instanceof z.ZodError) {
throw new Error( throw new Error(