Compare commits

...

7 Commits

Author SHA1 Message Date
a2c2ac185a [main] release: v1.0.47
📝 Details:
- 버전을 1.0.47로 업데이트
- CHANGELOG에 새로운 기능과 버그 수정 사항 추가
  - list_merge_requests 기능 추가 (#56)
  - GitLabUserSchema의 avatar_url nullable 처리 (#55)
  - GitLabPipelineSchema의 illustration nullable 처리 (#58)
2025-05-29 09:13:43 +09:00
2462168697 Merge pull request #58 from zereight/fix/illustration-nullable
fix(schemas): make illustration nullable in GitLabPipelineSchema
2025-05-29 09:09:16 +09:00
88af65fcd0 Merge pull request #56 from jwang-sue/feature/list-merge-requests
feat: implement list_merge_requests functionality
2025-05-29 09:09:05 +09:00
0b55cc3cee Merge pull request #55 from svengt/fix/avatar-url-nullable
fix(schemas): make avatar_url nullable in GitLabUserSchema
2025-05-29 09:08:41 +09:00
40e39d7b36 fix(schemas): make illustration nullable in GitLabPipelineSchema 2025-05-29 04:35:29 +09:00
cc847772f1 feat: implement list_merge_requests functionality
- Add ListMergeRequestsSchema with comprehensive filtering options
- Implement listMergeRequests function following GitLab API
- Add tool definition and switch case handler
- Include in readOnlyTools array
- Update README.md with new tool documentation
2025-05-28 17:22:40 +02:00
ab571d211d fix(schemas): make avatar_url nullable in GitLabUserSchema
Users without profile pictures have null avatar_url values in GitLab API responses.
This change prevents errors when calling get_issue tool.
2025-05-28 15:44:15 +02:00
6 changed files with 164 additions and 5 deletions

View File

@ -1,3 +1,27 @@
## [1.0.47] - 2025-05-29
### Added
- 🔄 **List Merge Requests Tool**: Added functionality to list and filter merge requests in GitLab projects
- `list_merge_requests`: List merge requests with comprehensive filtering options
- Supports filtering by state, scope, author, assignee, reviewer, labels, and more
- Includes pagination support for large result sets
- See: [PR #56](https://github.com/zereight/gitlab-mcp/pull/56)
### Fixed
- Fixed issue where GitLab users without profile pictures would cause JSON-RPC errors
- Changed `avatar_url` field to be nullable in GitLabUserSchema
- This allows proper handling of users without avatars in GitLab API responses
- See: [PR #55](https://github.com/zereight/gitlab-mcp/pull/55)
- Fixed issue where GitLab pipelines without illustrations would cause JSON-RPC errors
- Changed `illustration` field to be nullable in GitLabPipelineSchema
- This allows proper handling of pipelines without illustrations
- See: [PR #58](https://github.com/zereight/gitlab-mcp/pull/58), [Issue #57](https://github.com/zereight/gitlab-mcp/issues/57)
---
## [1.0.46] - 2025-05-27 ## [1.0.46] - 2025-05-27
### Fixed ### Fixed

View File

@ -125,4 +125,5 @@ When using with the Claude App, you need to set up your API key and URLs directl
48. `list_pipeline_jobs` - List all jobs in a specific pipeline 48. `list_pipeline_jobs` - List all jobs in a specific pipeline
49. `get_pipeline_job` - Get details of a GitLab pipeline job number 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 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
<!-- TOOLS-END --> <!-- TOOLS-END -->

View File

@ -134,6 +134,7 @@ import {
type GetRepositoryTreeOptions, type GetRepositoryTreeOptions,
UpdateIssueNoteSchema, UpdateIssueNoteSchema,
CreateIssueNoteSchema, CreateIssueNoteSchema,
ListMergeRequestsSchema,
} from "./schemas.js"; } from "./schemas.js";
/** /**
@ -466,6 +467,11 @@ const allTools = [
description: "Get the output/trace of a GitLab pipeline job number", description: "Get the output/trace of a GitLab pipeline job number",
inputSchema: zodToJsonSchema(GetPipelineJobOutputSchema), inputSchema: zodToJsonSchema(GetPipelineJobOutputSchema),
}, },
{
name: "list_merge_requests",
description: "List merge requests in a GitLab project with filtering options",
inputSchema: zodToJsonSchema(ListMergeRequestsSchema),
},
]; ];
// Define which tools are read-only // Define which tools are read-only
@ -476,6 +482,7 @@ const readOnlyTools = [
"get_merge_request_diffs", "get_merge_request_diffs",
"mr_discussions", "mr_discussions",
"list_issues", "list_issues",
"list_merge_requests",
"get_issue", "get_issue",
"list_issue_links", "list_issue_links",
"list_issue_discussions", "list_issue_discussions",
@ -791,6 +798,43 @@ async function listIssues(
return z.array(GitLabIssueSchema).parse(data); return z.array(GitLabIssueSchema).parse(data);
} }
/**
* List merge requests in a GitLab project with optional filtering
*
* @param {string} projectId - The ID or URL-encoded path of the project
* @param {Object} options - Optional filtering parameters
* @returns {Promise<GitLabMergeRequest[]>} List of merge requests
*/
async function listMergeRequests(
projectId: string,
options: Omit<z.infer<typeof ListMergeRequestsSchema>, "project_id"> = {}
): Promise<GitLabMergeRequest[]> {
projectId = decodeURIComponent(projectId); // Decode project ID
const url = new URL(
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/merge_requests`
);
// Add all query parameters
Object.entries(options).forEach(([key, value]) => {
if (value !== undefined) {
if (key === "labels" && Array.isArray(value)) {
// Handle array of labels
url.searchParams.append(key, value.join(","));
} else {
url.searchParams.append(key, value.toString());
}
}
});
const response = await fetch(url.toString(), {
...DEFAULT_FETCH_CONFIG,
});
await handleGitLabError(response);
const data = await response.json();
return z.array(GitLabMergeRequestSchema).parse(data);
}
/** /**
* Get a single issue from a GitLab project * Get a single issue from a GitLab project
* 단일 이슈 조회 * 단일 이슈 조회
@ -3300,6 +3344,14 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
}; };
} }
case "list_merge_requests": {
const args = ListMergeRequestsSchema.parse(request.params.arguments);
const mergeRequests = await listMergeRequests(args.project_id, args);
return {
content: [{ type: "text", text: JSON.stringify(mergeRequests, null, 2) }],
};
}
default: default:
throw new Error(`Unknown tool: ${request.params.name}`); throw new Error(`Unknown tool: ${request.params.name}`);
} }

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@zereight/mcp-gitlab", "name": "@zereight/mcp-gitlab",
"version": "1.0.38", "version": "1.0.46",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@zereight/mcp-gitlab", "name": "@zereight/mcp-gitlab",
"version": "1.0.38", "version": "1.0.46",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@modelcontextprotocol/sdk": "1.8.0", "@modelcontextprotocol/sdk": "1.8.0",

View File

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

View File

@ -40,7 +40,7 @@ export const GitLabPipelineSchema = z.object({
image: z.string().optional(), image: z.string().optional(),
size: z.string().optional(), size: z.string().optional(),
title: z.string().optional(), title: z.string().optional(),
}).optional(), }).nullable().optional(),
favicon: z.string().optional(), favicon: z.string().optional(),
}).optional(), }).optional(),
}); });
@ -399,7 +399,7 @@ export const GitLabUserSchema = z.object({
username: z.string(), // Changed from login to match GitLab API username: z.string(), // Changed from login to match GitLab API
id: z.number(), id: z.number(),
name: z.string(), name: z.string(),
avatar_url: z.string(), avatar_url: z.string().nullable(),
web_url: z.string(), // Changed from html_url to match GitLab API web_url: z.string(), // Changed from html_url to match GitLab API
}); });
@ -834,6 +834,88 @@ export const ListIssuesSchema = z.object({
per_page: z.number().optional().describe("Number of items per page"), per_page: z.number().optional().describe("Number of items per page"),
}); });
// Merge Requests API operation schemas
export const ListMergeRequestsSchema = z.object({
project_id: z.string().describe("Project ID or URL-encoded path"),
assignee_id: z
.number()
.optional()
.describe("Returns merge requests assigned to the given user ID"),
assignee_username: z
.string()
.optional()
.describe("Returns merge requests assigned to the given username"),
author_id: z
.number()
.optional()
.describe("Returns merge requests created by the given user ID"),
author_username: z
.string()
.optional()
.describe("Returns merge requests created by the given username"),
reviewer_id: z
.number()
.optional()
.describe("Returns merge requests which have the user as a reviewer"),
reviewer_username: z
.string()
.optional()
.describe("Returns merge requests which have the user as a reviewer"),
created_after: z
.string()
.optional()
.describe("Return merge requests created after the given time"),
created_before: z
.string()
.optional()
.describe("Return merge requests created before the given time"),
updated_after: z
.string()
.optional()
.describe("Return merge requests updated after the given time"),
updated_before: z
.string()
.optional()
.describe("Return merge requests updated before the given time"),
labels: z.array(z.string()).optional().describe("Array of label names"),
milestone: z.string().optional().describe("Milestone title"),
scope: z
.enum(["created_by_me", "assigned_to_me", "all"])
.optional()
.describe("Return merge requests from a specific scope"),
search: z.string().optional().describe("Search for specific terms"),
state: z
.enum(["opened", "closed", "locked", "merged", "all"])
.optional()
.describe("Return merge requests with a specific state"),
order_by: z
.enum(["created_at", "updated_at", "priority", "label_priority", "milestone_due", "popularity"])
.optional()
.describe("Return merge requests ordered by the given field"),
sort: z
.enum(["asc", "desc"])
.optional()
.describe("Return merge requests sorted in ascending or descending order"),
target_branch: z
.string()
.optional()
.describe("Return merge requests targeting a specific branch"),
source_branch: z
.string()
.optional()
.describe("Return merge requests from a specific source branch"),
wip: z
.enum(["yes", "no"])
.optional()
.describe("Filter merge requests against their wip status"),
with_labels_details: z
.boolean()
.optional()
.describe("Return more details for each label"),
page: z.number().optional().describe("Page number for pagination"),
per_page: z.number().optional().describe("Number of items per page"),
});
export const GetIssueSchema = z.object({ export const GetIssueSchema = z.object({
project_id: z.string().describe("Project ID or URL-encoded path"), project_id: z.string().describe("Project ID or URL-encoded path"),
issue_iid: z.number().describe("The internal ID of the project issue"), issue_iid: z.number().describe("The internal ID of the project issue"),