Compare commits

...

7 Commits

Author SHA1 Message Date
74af27f995 FEAT: ci push docker hub 2025-05-30 01:51:07 +09:00
1e0bcb173d [feat/pipeline-support] chore: v1.0.52 버전 업데이트 2025-05-30 00:50:26 +09:00
93b1e47f65 Merge branch 'feat/pipeline-support' 2025-05-30 00:49:41 +09:00
de0b138d80 [feat/pipeline-support] feat: add USE_PIPELINE environment variable for conditional pipeline feature activation
 Breaking Changes:
- Pipeline features are now opt-in via USE_PIPELINE environment variable

📝 Details:
- Pipeline 관련 도구들을 USE_PIPELINE 환경 변수로 제어 가능하도록 변경
- USE_GITLAB_WIKI, USE_MILESTONE과 동일한 패턴으로 구현
- 기본값은 false로 설정되어 pipeline 기능은 명시적으로 활성화해야 함
- README에 USE_PIPELINE 환경 변수 설명 추가
2025-05-30 00:48:53 +09:00
fa19b62300 Merge pull request #64 from zereight/feat/pipeline-support
feat: add pipeline management commands
2025-05-30 00:42:09 +09:00
353638f5d7 [feat/pipeline-support] feat: add pipeline management commands
- Add create_pipeline command to trigger new pipelines
- Add retry_pipeline command to retry failed pipelines
- Add cancel_pipeline command to cancel running pipelines
- Add pipeline tests to validate-api.js
- Update README with new pipeline commands

Closes #46
2025-05-30 00:38:53 +09:00
059ec83cd7 Merge pull request #63 from zereight/test/20250530
[main] docs: update README with comments on GITLAB configuration options
2025-05-30 00:18:21 +09:00
8 changed files with 315 additions and 14 deletions

38
.github/workflows/docker-publish.yml vendored Normal file
View File

@ -0,0 +1,38 @@
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: .
push: true
tags: ${{ steps.meta.outputs.tags }}

3
.secrets Normal file
View File

@ -0,0 +1,3 @@
DOCKERHUB_USERNAME=DOCKERHUB_USERNAME
DOCKERHUB_TOKEN=DOCKERHUB_TOKEN
GITHUB_TOKEN=DOCKERHUB_TOKEN

View File

@ -27,7 +27,8 @@ When using with the Claude App, you need to set up your API key and URLs directl
"GITLAB_API_URL": "your_gitlab_api_url",
"GITLAB_READ_ONLY_MODE": "false",
"USE_GITLAB_WIKI": "false", // use wiki api?
"USE_MILESTONE": "false" // use milestone 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
View File

@ -0,0 +1,6 @@
{
"action": "published",
"release": {
"tag_name": "v1.0.52"
}
}

160
index.ts
View File

@ -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);

View File

@ -1,6 +1,6 @@
{
"name": "@zereight/mcp-gitlab",
"version": "1.0.51",
"version": "1.0.52",
"description": "MCP server for using the GitLab API",
"license": "MIT",
"author": "zereight",

View File

@ -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"),
@ -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>;

View File

@ -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!");