Add debug info to create_note handler response
This commit is contained in:
@ -541,11 +541,25 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
try {
|
||||
const args = CreateNoteSchema.parse(request.params.arguments);
|
||||
const { project_id, noteable_type, noteable_iid, body } = args;
|
||||
// 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) {
|
||||
throw new Error(`Invalid arguments: ${error.errors
|
||||
|
17
index.ts
17
index.ts
@ -835,6 +835,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
try {
|
||||
const args = CreateNoteSchema.parse(request.params.arguments);
|
||||
const { project_id, noteable_type, noteable_iid, body } = args;
|
||||
|
||||
// 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,
|
||||
@ -844,6 +855,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
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(
|
||||
|
Reference in New Issue
Block a user