Skip to content

Commit cd5c324

Browse files
committed
feat: add health_check tool
1 parent 790c150 commit cd5c324

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

index.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ import {
160160
type GetRepositoryTreeOptions,
161161
GetRepositoryTreeSchema,
162162
GetUsersSchema,
163+
HealthCheckSchema,
163164
GetWikiPageSchema,
164165
type GitLabCommit,
165166
GitLabCommitSchema,
@@ -10341,6 +10342,39 @@ async function handleToolCall(params: any) {
1034110342
};
1034210343
}
1034310344

10345+
case "health_check": {
10346+
HealthCheckSchema.parse(params.arguments);
10347+
const url = new URL(`${GITLAB_API_URL}/projects?per_page=1`);
10348+
10349+
try {
10350+
const response = await fetch(url.toString(), {
10351+
...getFetchConfig(),
10352+
});
10353+
10354+
const authenticated = response.ok;
10355+
const result = {
10356+
status: authenticated ? "ok" : "error",
10357+
authenticated,
10358+
gitlab_url: GITLAB_API_URL,
10359+
};
10360+
10361+
return {
10362+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
10363+
};
10364+
} catch (error) {
10365+
const result = {
10366+
status: "error",
10367+
authenticated: false,
10368+
gitlab_url: GITLAB_API_URL,
10369+
error: error instanceof Error ? error.message : "Unknown error",
10370+
};
10371+
10372+
return {
10373+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
10374+
};
10375+
}
10376+
}
10377+
1034410378
default:
1034510379
throw new Error(`Unknown tool: ${params.name}`);
1034610380
}

schemas.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,9 @@ export const GitLabUsersResponseSchema = z.record(
550550
.nullable()
551551
);
552552

553+
// Health check schema
554+
export const HealthCheckSchema = z.object({});
555+
553556
// Namespace related schemas
554557

555558
// Base schema for project-related operations

tools/registry.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ import {
109109
GetTagSignatureSchema,
110110
GetTimelineEventsSchema,
111111
GetUsersSchema,
112+
HealthCheckSchema,
112113
GetWebhookEventSchema,
113114
GetWikiPageSchema,
114115
GetWorkItemSchema,
@@ -594,6 +595,11 @@ export const allTools = [
594595
description: "List projects in a group",
595596
inputSchema: toJSONSchema(ListGroupProjectsSchema),
596597
},
598+
{
599+
name: "health_check",
600+
description: "Verify server status and authentication",
601+
inputSchema: toJSONSchema(HealthCheckSchema),
602+
},
597603
{
598604
name: "list_wiki_pages",
599605
description: "List wiki pages in a project",

0 commit comments

Comments
 (0)