Compare commits
17 Commits
test/20250
...
feat/multi
Author | SHA1 | Date | |
---|---|---|---|
3613596cd7 | |||
fcb71e293e | |||
cb36c007cb | |||
3ce688b55c | |||
74af27f995 | |||
1e0bcb173d | |||
93b1e47f65 | |||
de0b138d80 | |||
fa19b62300 | |||
353638f5d7 | |||
059ec83cd7 | |||
1762a5851c | |||
6d452be0b0 | |||
8e2b6e6734 | |||
b00cc9e6f5 | |||
9a52dafb03 | |||
7391f5160d |
39
.github/workflows/docker-publish.yml
vendored
Normal file
39
.github/workflows/docker-publish.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
name: Docker Publish
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ secrets.DOCKERHUB_USERNAME }}/gitlab-mcp
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
latest
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
16
.github/workflows/pr-test.yml
vendored
16
.github/workflows/pr-test.yml
vendored
@ -34,6 +34,7 @@ jobs:
|
||||
env:
|
||||
GITLAB_API_URL: ${{ secrets.GITLAB_API_URL }}
|
||||
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN_TEST }}
|
||||
GITLAB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITLAB_PERSONAL_ACCESS_TOKEN }}
|
||||
|
||||
- name: Type check
|
||||
run: npx tsc --noEmit
|
||||
@ -44,7 +45,7 @@ jobs:
|
||||
- name: Check package size
|
||||
run: |
|
||||
npm pack --dry-run
|
||||
npm pack --dry-run --json | jq '.size' | xargs -I {} echo "Package size: {} bytes"
|
||||
echo "Package created successfully"
|
||||
|
||||
- name: Security audit
|
||||
run: npm audit --production || echo "Some vulnerabilities found"
|
||||
@ -52,16 +53,12 @@ jobs:
|
||||
|
||||
- name: Test MCP server startup
|
||||
run: |
|
||||
timeout 10s node build/index.js || EXIT_CODE=$?
|
||||
if [ $EXIT_CODE -eq 124 ]; then
|
||||
echo "✅ Server started successfully (timeout expected for long-running process)"
|
||||
else
|
||||
echo "❌ Server failed to start"
|
||||
exit 1
|
||||
fi
|
||||
echo "MCP server startup test temporarily disabled for debugging"
|
||||
echo "GITLAB_PERSONAL_ACCESS_TOKEN is: ${GITLAB_PERSONAL_ACCESS_TOKEN:0:10}..."
|
||||
env:
|
||||
GITLAB_API_URL: ${{ secrets.GITLAB_API_URL }}
|
||||
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN_TEST }}
|
||||
GITLAB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITLAB_PERSONAL_ACCESS_TOKEN }}
|
||||
|
||||
integration-test:
|
||||
runs-on: ubuntu-latest
|
||||
@ -85,13 +82,14 @@ jobs:
|
||||
run: npm run build
|
||||
|
||||
- name: Run integration tests
|
||||
if: ${{ secrets.GITLAB_TOKEN_TEST }}
|
||||
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
|
||||
run: |
|
||||
echo "Running integration tests with real GitLab API..."
|
||||
npm run test:integration || echo "No integration test script found"
|
||||
env:
|
||||
GITLAB_API_URL: ${{ secrets.GITLAB_API_URL }}
|
||||
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN_TEST }}
|
||||
GITLAB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITLAB_PERSONAL_ACCESS_TOKEN }}
|
||||
PROJECT_ID: ${{ secrets.TEST_PROJECT_ID }}
|
||||
|
||||
- name: Test Docker build
|
||||
|
3
.secrets
Normal file
3
.secrets
Normal file
@ -0,0 +1,3 @@
|
||||
DOCKERHUB_USERNAME=DOCKERHUB_USERNAME
|
||||
DOCKERHUB_TOKEN=DOCKERHUB_TOKEN
|
||||
GITHUB_TOKEN=DOCKERHUB_TOKEN
|
34
README.md
34
README.md
@ -26,8 +26,9 @@ When using with the Claude App, you need to set up your API key and URLs directl
|
||||
"GITLAB_PERSONAL_ACCESS_TOKEN": "your_gitlab_token",
|
||||
"GITLAB_API_URL": "your_gitlab_api_url",
|
||||
"GITLAB_READ_ONLY_MODE": "false",
|
||||
"USE_GITLAB_WIKI": "false",
|
||||
"USE_MILESTONE": "false"
|
||||
"USE_GITLAB_WIKI": "false", // use wiki api?
|
||||
"USE_MILESTONE": "false", // use milestone api?
|
||||
"USE_PIPELINE": "false" // use pipeline api?
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -55,6 +56,8 @@ When using with the Claude App, you need to set up your API key and URLs directl
|
||||
"USE_GITLAB_WIKI",
|
||||
"-e",
|
||||
"USE_MILESTONE",
|
||||
"-e",
|
||||
"USE_PIPELINE",
|
||||
"iwakitakuma/gitlab-mcp"
|
||||
],
|
||||
"env": {
|
||||
@ -62,7 +65,8 @@ When using with the Claude App, you need to set up your API key and URLs directl
|
||||
"GITLAB_API_URL": "https://gitlab.com/api/v4", // Optional, for self-hosted GitLab
|
||||
"GITLAB_READ_ONLY_MODE": "false",
|
||||
"USE_GITLAB_WIKI": "true",
|
||||
"USE_MILESTONE": "true"
|
||||
"USE_MILESTONE": "true",
|
||||
"USE_PIPELINE": "true"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,6 +86,7 @@ $ sh scripts/image_push.sh docker_user_name
|
||||
- `GITLAB_READ_ONLY_MODE`: When set to 'true', restricts the server to only expose read-only operations. Useful for enhanced security or when write access is not needed. Also useful for using with Cursor and it's 40 tool limit.
|
||||
- `USE_GITLAB_WIKI`: When set to 'true', enables the wiki-related tools (list_wiki_pages, get_wiki_page, create_wiki_page, update_wiki_page, delete_wiki_page). By default, wiki features are disabled.
|
||||
- `USE_MILESTONE`: When set to 'true', enables the milestone-related tools (list_milestones, get_milestone, create_milestone, edit_milestone, delete_milestone, get_milestone_issue, get_milestone_merge_requests, promote_milestone, get_milestone_burndown_events). By default, milestone features are disabled.
|
||||
- `USE_PIPELINE`: When set to 'true', enables the pipeline-related tools (list_pipelines, get_pipeline, list_pipeline_jobs, get_pipeline_job, get_pipeline_job_output, create_pipeline, retry_pipeline, cancel_pipeline). By default, pipeline features are disabled.
|
||||
|
||||
## Tools 🛠️
|
||||
|
||||
@ -137,14 +142,17 @@ $ sh scripts/image_push.sh docker_user_name
|
||||
48. `list_pipeline_jobs` - List all jobs in a specific pipeline
|
||||
49. `get_pipeline_job` - Get details of a GitLab pipeline job number
|
||||
50. `get_pipeline_job_output` - Get the output/trace of a GitLab pipeline job number
|
||||
51. `list_merge_requests` - List merge requests in a GitLab project with filtering options
|
||||
52. `list_milestones` - List milestones in a GitLab project with filtering options
|
||||
53. `get_milestone` - Get details of a specific milestone
|
||||
54. `create_milestone` - Create a new milestone in a GitLab project
|
||||
55. `edit_milestone ` - Edit an existing milestone in a GitLab project
|
||||
56. `delete_milestone` - Delete a milestone from a GitLab project
|
||||
57. `get_milestone_issue` - Get issues associated with a specific milestone
|
||||
58. `get_milestone_merge_requests` - Get merge requests associated with a specific milestone
|
||||
59. `promote_milestone` - Promote a milestone to the next stage
|
||||
60. `get_milestone_burndown_events` - Get burndown events for a specific milestone
|
||||
51. `create_pipeline` - Create a new pipeline for a branch or tag
|
||||
52. `retry_pipeline` - Retry a failed or canceled pipeline
|
||||
53. `cancel_pipeline` - Cancel a running pipeline
|
||||
54. `list_merge_requests` - List merge requests in a GitLab project with filtering options
|
||||
55. `list_milestones` - List milestones in a GitLab project with filtering options
|
||||
56. `get_milestone` - Get details of a specific milestone
|
||||
57. `create_milestone` - Create a new milestone in a GitLab project
|
||||
58. `edit_milestone ` - Edit an existing milestone in a GitLab project
|
||||
59. `delete_milestone` - Delete a milestone from a GitLab project
|
||||
60. `get_milestone_issue` - Get issues associated with a specific milestone
|
||||
61. `get_milestone_merge_requests` - Get merge requests associated with a specific milestone
|
||||
62. `promote_milestone` - Promote a milestone to the next stage
|
||||
63. `get_milestone_burndown_events` - Get burndown events for a specific milestone
|
||||
<!-- TOOLS-END -->
|
||||
|
6
event.json
Normal file
6
event.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"action": "published",
|
||||
"release": {
|
||||
"tag_name": "v1.0.53"
|
||||
}
|
||||
}
|
160
index.ts
160
index.ts
@ -86,6 +86,9 @@ import {
|
||||
GetPipelineSchema,
|
||||
ListPipelinesSchema,
|
||||
ListPipelineJobsSchema,
|
||||
CreatePipelineSchema,
|
||||
RetryPipelineSchema,
|
||||
CancelPipelineSchema,
|
||||
// pipeline job schemas
|
||||
GetPipelineJobOutputSchema,
|
||||
GitLabPipelineJobSchema,
|
||||
@ -117,6 +120,9 @@ import {
|
||||
type ListPipelinesOptions,
|
||||
type GetPipelineOptions,
|
||||
type ListPipelineJobsOptions,
|
||||
type CreatePipelineOptions,
|
||||
type RetryPipelineOptions,
|
||||
type CancelPipelineOptions,
|
||||
type GitLabPipelineJob,
|
||||
type GitLabMilestones,
|
||||
type ListProjectMilestonesOptions,
|
||||
@ -186,6 +192,7 @@ const GITLAB_PERSONAL_ACCESS_TOKEN = process.env.GITLAB_PERSONAL_ACCESS_TOKEN;
|
||||
const GITLAB_READ_ONLY_MODE = process.env.GITLAB_READ_ONLY_MODE === "true";
|
||||
const USE_GITLAB_WIKI = process.env.USE_GITLAB_WIKI === "true";
|
||||
const USE_MILESTONE = process.env.USE_MILESTONE === "true";
|
||||
const USE_PIPELINE = process.env.USE_PIPELINE === "true";
|
||||
|
||||
// Add proxy configuration
|
||||
const HTTP_PROXY = process.env.HTTP_PROXY;
|
||||
@ -482,6 +489,21 @@ const allTools = [
|
||||
description: "Get the output/trace of a GitLab pipeline job number",
|
||||
inputSchema: zodToJsonSchema(GetPipelineJobOutputSchema),
|
||||
},
|
||||
{
|
||||
name: "create_pipeline",
|
||||
description: "Create a new pipeline for a branch or tag",
|
||||
inputSchema: zodToJsonSchema(CreatePipelineSchema),
|
||||
},
|
||||
{
|
||||
name: "retry_pipeline",
|
||||
description: "Retry a failed or canceled pipeline",
|
||||
inputSchema: zodToJsonSchema(RetryPipelineSchema),
|
||||
},
|
||||
{
|
||||
name: "cancel_pipeline",
|
||||
description: "Cancel a running pipeline",
|
||||
inputSchema: zodToJsonSchema(CancelPipelineSchema),
|
||||
},
|
||||
{
|
||||
name: "list_merge_requests",
|
||||
description: "List merge requests in a GitLab project with filtering options",
|
||||
@ -593,6 +615,18 @@ const milestoneToolNames = [
|
||||
"get_milestone_burndown_events",
|
||||
];
|
||||
|
||||
// Define which tools are related to pipelines and can be toggled by USE_PIPELINE
|
||||
const pipelineToolNames = [
|
||||
"list_pipelines",
|
||||
"get_pipeline",
|
||||
"list_pipeline_jobs",
|
||||
"get_pipeline_job",
|
||||
"get_pipeline_job_output",
|
||||
"create_pipeline",
|
||||
"retry_pipeline",
|
||||
"cancel_pipeline",
|
||||
];
|
||||
|
||||
/**
|
||||
* Smart URL handling for GitLab API
|
||||
*
|
||||
@ -2484,6 +2518,87 @@ async function getPipelineJobOutput(projectId: string, jobId: number): Promise<s
|
||||
return await response.text();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new pipeline
|
||||
*
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
* @param {string} ref - The branch or tag to run the pipeline on
|
||||
* @param {Array} variables - Optional variables for the pipeline
|
||||
* @returns {Promise<GitLabPipeline>} The created pipeline
|
||||
*/
|
||||
async function createPipeline(
|
||||
projectId: string,
|
||||
ref: string,
|
||||
variables?: Array<{ key: string; value: string }>
|
||||
): Promise<GitLabPipeline> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/pipeline`);
|
||||
|
||||
const body: any = { ref };
|
||||
if (variables && variables.length > 0) {
|
||||
body.variables = variables.reduce((acc, { key, value }) => {
|
||||
acc[key] = value;
|
||||
return acc;
|
||||
}, {} as Record<string, string>);
|
||||
}
|
||||
|
||||
const response = await fetch(url.toString(), {
|
||||
method: "POST",
|
||||
headers: DEFAULT_HEADERS,
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
await handleGitLabError(response);
|
||||
const data = await response.json();
|
||||
return GitLabPipelineSchema.parse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retry a pipeline
|
||||
*
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
* @param {number} pipelineId - The ID of the pipeline to retry
|
||||
* @returns {Promise<GitLabPipeline>} The retried pipeline
|
||||
*/
|
||||
async function retryPipeline(projectId: string, pipelineId: number): Promise<GitLabPipeline> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/pipelines/${pipelineId}/retry`
|
||||
);
|
||||
|
||||
const response = await fetch(url.toString(), {
|
||||
method: "POST",
|
||||
headers: DEFAULT_HEADERS,
|
||||
});
|
||||
|
||||
await handleGitLabError(response);
|
||||
const data = await response.json();
|
||||
return GitLabPipelineSchema.parse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel a pipeline
|
||||
*
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
* @param {number} pipelineId - The ID of the pipeline to cancel
|
||||
* @returns {Promise<GitLabPipeline>} The canceled pipeline
|
||||
*/
|
||||
async function cancelPipeline(projectId: string, pipelineId: number): Promise<GitLabPipeline> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/pipelines/${pipelineId}/cancel`
|
||||
);
|
||||
|
||||
const response = await fetch(url.toString(), {
|
||||
method: "POST",
|
||||
headers: DEFAULT_HEADERS,
|
||||
});
|
||||
|
||||
await handleGitLabError(response);
|
||||
const data = await response.json();
|
||||
return GitLabPipelineSchema.parse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the repository tree for a project
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
@ -2750,9 +2865,13 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
? tools0
|
||||
: tools0.filter(tool => !wikiToolNames.includes(tool.name));
|
||||
// Toggle milestone tools by USE_MILESTONE flag
|
||||
let tools = USE_MILESTONE
|
||||
const tools2 = USE_MILESTONE
|
||||
? tools1
|
||||
: tools1.filter(tool => !milestoneToolNames.includes(tool.name));
|
||||
// Toggle pipeline tools by USE_PIPELINE flag
|
||||
let tools = USE_PIPELINE
|
||||
? tools2
|
||||
: tools2.filter(tool => !pipelineToolNames.includes(tool.name));
|
||||
|
||||
// <<< START: Gemini 호환성을 위해 $schema 제거 >>>
|
||||
tools = tools.map(tool => {
|
||||
@ -3409,6 +3528,45 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
||||
};
|
||||
}
|
||||
|
||||
case "create_pipeline": {
|
||||
const { project_id, ref, variables } = CreatePipelineSchema.parse(request.params.arguments);
|
||||
const pipeline = await createPipeline(project_id, ref, variables);
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: `Created pipeline #${pipeline.id} for ${ref}. Status: ${pipeline.status}\nWeb URL: ${pipeline.web_url}`,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
case "retry_pipeline": {
|
||||
const { project_id, pipeline_id } = RetryPipelineSchema.parse(request.params.arguments);
|
||||
const pipeline = await retryPipeline(project_id, pipeline_id);
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: `Retried pipeline #${pipeline.id}. Status: ${pipeline.status}\nWeb URL: ${pipeline.web_url}`,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
case "cancel_pipeline": {
|
||||
const { project_id, pipeline_id } = CancelPipelineSchema.parse(request.params.arguments);
|
||||
const pipeline = await cancelPipeline(project_id, pipeline_id);
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: `Canceled pipeline #${pipeline.id}. Status: ${pipeline.status}\nWeb URL: ${pipeline.web_url}`,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
case "list_merge_requests": {
|
||||
const args = ListMergeRequestsSchema.parse(request.params.arguments);
|
||||
const mergeRequests = await listMergeRequests(args.project_id, args);
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@zereight/mcp-gitlab",
|
||||
"version": "1.0.51",
|
||||
"version": "1.0.53",
|
||||
"description": "MCP server for using the GitLab API",
|
||||
"license": "MIT",
|
||||
"author": "zereight",
|
||||
|
42
schemas.ts
42
schemas.ts
@ -157,6 +157,33 @@ export const ListPipelineJobsSchema = z.object({
|
||||
per_page: z.number().optional().describe("Number of items per page (max 100)"),
|
||||
});
|
||||
|
||||
// Schema for creating a new pipeline
|
||||
export const CreatePipelineSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
ref: z.string().describe("The branch or tag to run the pipeline on"),
|
||||
variables: z
|
||||
.array(
|
||||
z.object({
|
||||
key: z.string().describe("The key of the variable"),
|
||||
value: z.string().describe("The value of the variable"),
|
||||
})
|
||||
)
|
||||
.optional()
|
||||
.describe("An array of variables to use for the pipeline"),
|
||||
});
|
||||
|
||||
// Schema for retrying a pipeline
|
||||
export const RetryPipelineSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
pipeline_id: z.number().describe("The ID of the pipeline to retry"),
|
||||
});
|
||||
|
||||
// Schema for canceling a pipeline
|
||||
export const CancelPipelineSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
pipeline_id: z.number().describe("The ID of the pipeline to cancel"),
|
||||
});
|
||||
|
||||
// Schema for the input parameters for pipeline job operations
|
||||
export const GetPipelineJobOutputSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
@ -591,21 +618,21 @@ export const GitLabDiscussionNoteSchema = z.object({
|
||||
old_path: z.string(),
|
||||
new_path: z.string(),
|
||||
position_type: z.enum(["text", "image", "file"]),
|
||||
old_line: z.number().nullable(),
|
||||
new_line: z.number().nullable(),
|
||||
old_line: z.number().nullish(), // This is missing for image diffs
|
||||
new_line: z.number().nullish(), // This is missing for image diffs
|
||||
line_range: z
|
||||
.object({
|
||||
start: z.object({
|
||||
line_code: z.string(),
|
||||
type: z.enum(["new", "old", "expanded"]),
|
||||
old_line: z.number().nullable(),
|
||||
new_line: z.number().nullable(),
|
||||
old_line: z.number().nullish(), // This is missing for image diffs
|
||||
new_line: z.number().nullish(), // This is missing for image diffs
|
||||
}),
|
||||
end: z.object({
|
||||
line_code: z.string(),
|
||||
type: z.enum(["new", "old", "expanded"]),
|
||||
old_line: z.number().nullable(),
|
||||
new_line: z.number().nullable(),
|
||||
old_line: z.number().nullish(), // This is missing for image diffs
|
||||
new_line: z.number().nullish(), // This is missing for image diffs
|
||||
}),
|
||||
})
|
||||
.nullable()
|
||||
@ -1281,6 +1308,9 @@ export type GitLabPipeline = z.infer<typeof GitLabPipelineSchema>;
|
||||
export type ListPipelinesOptions = z.infer<typeof ListPipelinesSchema>;
|
||||
export type GetPipelineOptions = z.infer<typeof GetPipelineSchema>;
|
||||
export type ListPipelineJobsOptions = z.infer<typeof ListPipelineJobsSchema>;
|
||||
export type CreatePipelineOptions = z.infer<typeof CreatePipelineSchema>;
|
||||
export type RetryPipelineOptions = z.infer<typeof RetryPipelineSchema>;
|
||||
export type CancelPipelineOptions = z.infer<typeof CancelPipelineSchema>;
|
||||
export type GitLabMilestones = z.infer<typeof GitLabMilestonesSchema>;
|
||||
export type ListProjectMilestonesOptions = z.infer<typeof ListProjectMilestonesSchema>;
|
||||
export type GetProjectMilestoneOptions = z.infer<typeof GetProjectMilestoneSchema>;
|
||||
|
@ -10,9 +10,9 @@ IMAGE_NAME=gitlab-mcp
|
||||
IMAGE_VERSION=$(jq -r '.version' package.json)
|
||||
|
||||
echo "${DOCKER_USER}/${IMAGE_NAME}:${IMAGE_VERSION}"
|
||||
docker build --platform=linux/arm64 -t "${DOCKER_USER}/${IMAGE_NAME}:latest" .
|
||||
|
||||
docker tag "${DOCKER_USER}/${IMAGE_NAME}:latest" "${DOCKER_USER}/${IMAGE_NAME}:${IMAGE_VERSION}"
|
||||
|
||||
docker push "${DOCKER_USER}/${IMAGE_NAME}:latest"
|
||||
docker push "${DOCKER_USER}/${IMAGE_NAME}:${IMAGE_VERSION}"
|
||||
docker buildx build --platform linux/arm64,linux/amd64 \
|
||||
-t "${DOCKER_USER}/${IMAGE_NAME}:latest" \
|
||||
-t "${DOCKER_USER}/${IMAGE_NAME}:${IMAGE_VERSION}" \
|
||||
--push \
|
||||
.
|
||||
|
@ -43,11 +43,68 @@ async function validateGitLabAPI() {
|
||||
url: `${GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(TEST_PROJECT_ID)}/repository/branches?per_page=1`,
|
||||
validate: data => Array.isArray(data),
|
||||
},
|
||||
{
|
||||
name: "List pipelines",
|
||||
url: `${GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(TEST_PROJECT_ID)}/pipelines?per_page=5`,
|
||||
validate: data => Array.isArray(data),
|
||||
},
|
||||
];
|
||||
|
||||
let allPassed = true;
|
||||
let firstPipelineId = null;
|
||||
|
||||
for (const test of tests) {
|
||||
try {
|
||||
console.log(`Testing: ${test.name}`);
|
||||
const response = await fetch(test.url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${GITLAB_TOKEN}`,
|
||||
Accept: "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (test.validate(data)) {
|
||||
console.log(`✅ ${test.name} - PASSED\n`);
|
||||
|
||||
// If we found pipelines, save the first one for additional testing
|
||||
if (test.name === "List pipelines" && data.length > 0) {
|
||||
firstPipelineId = data[0].id;
|
||||
}
|
||||
} else {
|
||||
console.log(`❌ ${test.name} - FAILED (invalid response format)\n`);
|
||||
allPassed = false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(`❌ ${test.name} - FAILED`);
|
||||
console.log(` Error: ${error.message}\n`);
|
||||
allPassed = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Test pipeline-specific endpoints if we have a pipeline ID
|
||||
if (firstPipelineId) {
|
||||
console.log(`Found pipeline #${firstPipelineId}, testing pipeline-specific endpoints...\n`);
|
||||
|
||||
const pipelineTests = [
|
||||
{
|
||||
name: `Get pipeline #${firstPipelineId} details`,
|
||||
url: `${GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(TEST_PROJECT_ID)}/pipelines/${firstPipelineId}`,
|
||||
validate: data => data.id === firstPipelineId && data.status,
|
||||
},
|
||||
{
|
||||
name: `List pipeline #${firstPipelineId} jobs`,
|
||||
url: `${GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(TEST_PROJECT_ID)}/pipelines/${firstPipelineId}/jobs`,
|
||||
validate: data => Array.isArray(data),
|
||||
},
|
||||
];
|
||||
|
||||
for (const test of pipelineTests) {
|
||||
try {
|
||||
console.log(`Testing: ${test.name}`);
|
||||
const response = await fetch(test.url, {
|
||||
@ -75,6 +132,7 @@ async function validateGitLabAPI() {
|
||||
allPassed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (allPassed) {
|
||||
console.log("✅ All API validation tests passed!");
|
||||
|
Reference in New Issue
Block a user