Compare commits

...

8 Commits

Author SHA1 Message Date
cdf4697ef1 FEAT: get list commits
issue: #92
2025-06-11 03:51:32 +09:00
3c23675eec [version-update] fix: correct Private-Token header authentication for GitLab API 🔐
🚀 Breaking Changes:
- Removed incorrect `Bearer ` prefix from Private-Token header in legacy authentication mode
- Fixed authentication issues for older GitLab instances with private tokens

📝 Details:
- Ensures proper API authentication for both new and legacy GitLab configurations
2025-06-10 09:51:54 +09:00
8df87c67d2 [version-update] feat: bump version to 1.0.62 🎉
🚀 Breaking Changes:
- Updated version from 1.0.61 to 1.0.62
2025-06-10 09:49:22 +09:00
d318f9ea5e FIX: private token auth (#91)
issue: #88
2025-06-10 09:48:57 +09:00
ed032bad48 feat: bump version to 1.0.61 🎉
🚀 Breaking Changes:
- Updated version number in package.json
2025-06-09 14:22:51 +09:00
5200cc526c FEAT: private token auth (#89)
* FEAT: private token auth

issue: #88

* FIX
2025-06-09 14:21:52 +09:00
1ba54342bc style: format code for consistency and readability
🚀 Breaking Changes:
- None

📝 Details:
- Adjusted import statements for consistency
- Reformatted code for better readability
- Removed unnecessary console.error statements
2025-06-07 10:20:21 +09:00
29659db0b7 [version-update] feat: bump version to 1.0.60 🎉
🚀 Breaking Changes:
- Updated merge request functionality with new options
- Improved handling of assignee usernames in issue listings

📝 Details:
- Added support for `remove_source_branch` and `squash` options for merge requests
- Fixed issue with assignee username handling in issue listing
- Generated RELEASE_NOTES.md from CHANGELOG.md
2025-06-07 09:20:19 +09:00
7 changed files with 541 additions and 65 deletions

View File

@ -1,8 +1,40 @@
## [1.0.62] - 2025-06-10
### Fixed
- 🔐 **Private Token Authentication Fix**: Fixed Private-Token header authentication for GitLab API
- Removed incorrect `Bearer ` prefix from Private-Token header in legacy authentication mode
- Fixed authentication issues when using older GitLab instances with private tokens
- Ensures proper API authentication for both new and legacy GitLab configurations
- See: [PR #91](https://github.com/zereight/gitlab-mcp/pull/91), [Issue #88](https://github.com/zereight/gitlab-mcp/issues/88)
---
## [1.0.60] - 2025-06-07
### Added
- 📄 **Merge Request Enhancement**: Added support for `remove_source_branch` and `squash` options for merge requests
- Enhanced merge request functionality with additional configuration options
- Allows automatic source branch removal after merge
- Supports squash commits for cleaner Git history
- See: [PR #86](https://github.com/zereight/gitlab-mcp/pull/86)
### Fixed
- 🔧 **Issue Assignment Fix**: Fixed list issues assignee username handling
- Corrected assignee username field in issue listing functionality
- Improved user assignment data processing for GitLab issues
- See: [PR #87](https://github.com/zereight/gitlab-mcp/pull/87), [Issue #74](https://github.com/zereight/gitlab-mcp/issues/74)
---
## [1.0.54] - 2025-05-31 ## [1.0.54] - 2025-05-31
### Added ### Added
- 🌐 **Multi-Platform Support**: Added support for multiple platforms to improve compatibility across different environments - 🌐 **Multi-Platform Support**: Added support for multiple platforms to improve compatibility across different environments
- Enhanced platform detection and configuration handling - Enhanced platform detection and configuration handling
- Improved cross-platform functionality for GitLab MCP server - Improved cross-platform functionality for GitLab MCP server
- See: [PR #71](https://github.com/zereight/gitlab-mcp/pull/71), [Issue #69](https://github.com/zereight/gitlab-mcp/issues/69) - See: [PR #71](https://github.com/zereight/gitlab-mcp/pull/71), [Issue #69](https://github.com/zereight/gitlab-mcp/issues/69)

11
RELEASE_NOTES.md Normal file
View File

@ -0,0 +1,11 @@
## [1.0.62] - 2025-06-10
### Fixed
- 🔐 **Private Token Authentication Fix**: Fixed Private-Token header authentication for GitLab API
- Removed incorrect `Bearer ` prefix from Private-Token header in legacy authentication mode
- Fixed authentication issues when using older GitLab instances with private tokens
- Ensures proper API authentication for both new and legacy GitLab configurations
- See: [PR #91](https://github.com/zereight/gitlab-mcp/pull/91), [Issue #88](https://github.com/zereight/gitlab-mcp/issues/88)
---

278
index.ts
View File

@ -17,7 +17,7 @@ import path from "path";
import express, { Request, Response } from "express"; import express, { Request, Response } from "express";
// Add type imports for proxy agents // Add type imports for proxy agents
import { Agent } from "http"; import { Agent } from "http";
import { Agent as HttpsAgent } from 'https'; import { Agent as HttpsAgent } from "https";
import { URL } from "url"; import { URL } from "url";
import { import {
@ -172,6 +172,12 @@ import {
GitLabCompareResultSchema, GitLabCompareResultSchema,
GetBranchDiffsSchema, GetBranchDiffsSchema,
ListWikiPagesOptions, ListWikiPagesOptions,
ListCommitsSchema,
GetCommitSchema,
GetCommitDiffSchema,
type ListCommitsOptions,
type GetCommitOptions,
type GetCommitDiffOptions,
} from "./schemas.js"; } from "./schemas.js";
/** /**
@ -187,7 +193,7 @@ try {
SERVER_VERSION = packageJson.version || SERVER_VERSION; SERVER_VERSION = packageJson.version || SERVER_VERSION;
} }
} catch (error) { } catch (error) {
console.error("Warning: Could not read version from package.json:", error); // Warning: Could not read version from package.json - silently continue
} }
const server = new Server( const server = new Server(
@ -203,6 +209,7 @@ const server = new Server(
); );
const GITLAB_PERSONAL_ACCESS_TOKEN = process.env.GITLAB_PERSONAL_ACCESS_TOKEN; const GITLAB_PERSONAL_ACCESS_TOKEN = process.env.GITLAB_PERSONAL_ACCESS_TOKEN;
const IS_OLD = process.env.GITLAB_IS_OLD === "true";
const GITLAB_READ_ONLY_MODE = process.env.GITLAB_READ_ONLY_MODE === "true"; const GITLAB_READ_ONLY_MODE = process.env.GITLAB_READ_ONLY_MODE === "true";
const USE_GITLAB_WIKI = process.env.USE_GITLAB_WIKI === "true"; const USE_GITLAB_WIKI = process.env.USE_GITLAB_WIKI === "true";
const USE_MILESTONE = process.env.USE_MILESTONE === "true"; const USE_MILESTONE = process.env.USE_MILESTONE === "true";
@ -215,12 +222,12 @@ const HTTPS_PROXY = process.env.HTTPS_PROXY;
const NODE_TLS_REJECT_UNAUTHORIZED = process.env.NODE_TLS_REJECT_UNAUTHORIZED; const NODE_TLS_REJECT_UNAUTHORIZED = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
const GITLAB_CA_CERT_PATH = process.env.GITLAB_CA_CERT_PATH; const GITLAB_CA_CERT_PATH = process.env.GITLAB_CA_CERT_PATH;
let sslOptions= undefined; let sslOptions = undefined;
if (NODE_TLS_REJECT_UNAUTHORIZED === '0') { if (NODE_TLS_REJECT_UNAUTHORIZED === "0") {
sslOptions = { rejectUnauthorized: false }; sslOptions = { rejectUnauthorized: false };
} else if (GITLAB_CA_CERT_PATH) { } else if (GITLAB_CA_CERT_PATH) {
const ca = fs.readFileSync(GITLAB_CA_CERT_PATH); const ca = fs.readFileSync(GITLAB_CA_CERT_PATH);
sslOptions = { ca }; sslOptions = { ca };
} }
// Configure proxy agents if proxies are set // Configure proxy agents if proxies are set
@ -245,11 +252,15 @@ httpsAgent = httpsAgent || new HttpsAgent(sslOptions);
httpAgent = httpAgent || new Agent(); httpAgent = httpAgent || new Agent();
// Modify DEFAULT_HEADERS to include agent configuration // Modify DEFAULT_HEADERS to include agent configuration
const DEFAULT_HEADERS = { const DEFAULT_HEADERS: Record<string, string> = {
Accept: "application/json", Accept: "application/json",
"Content-Type": "application/json", "Content-Type": "application/json",
Authorization: `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`,
}; };
if (IS_OLD) {
DEFAULT_HEADERS["Private-Token"] = `${GITLAB_PERSONAL_ACCESS_TOKEN}`;
} else {
DEFAULT_HEADERS["Authorization"] = `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`;
}
// Create a default fetch configuration object that includes proxy agents if set // Create a default fetch configuration object that includes proxy agents if set
const DEFAULT_FETCH_CONFIG = { const DEFAULT_FETCH_CONFIG = {
@ -323,8 +334,7 @@ const allTools = [
}, },
{ {
name: "get_branch_diffs", name: "get_branch_diffs",
description: description: "Get the changes/diffs between two branches or commits in a GitLab project",
"Get the changes/diffs between two branches or commits in a GitLab project",
inputSchema: zodToJsonSchema(GetBranchDiffsSchema), inputSchema: zodToJsonSchema(GetBranchDiffsSchema),
}, },
{ {
@ -592,6 +602,21 @@ const allTools = [
description: "Get GitLab user details by usernames", description: "Get GitLab user details by usernames",
inputSchema: zodToJsonSchema(GetUsersSchema), inputSchema: zodToJsonSchema(GetUsersSchema),
}, },
{
name: "list_commits",
description: "List repository commits with filtering options",
inputSchema: zodToJsonSchema(ListCommitsSchema),
},
{
name: "get_commit",
description: "Get details of a specific commit",
inputSchema: zodToJsonSchema(GetCommitSchema),
},
{
name: "get_commit_diff",
description: "Get changes/diffs of a specific commit",
inputSchema: zodToJsonSchema(GetCommitDiffSchema),
},
]; ];
// Define which tools are read-only // Define which tools are read-only
@ -630,6 +655,9 @@ const readOnlyTools = [
"list_wiki_pages", "list_wiki_pages",
"get_wiki_page", "get_wiki_page",
"get_users", "get_users",
"list_commits",
"get_commit",
"get_commit_diff",
]; ];
// Define which tools are related to wiki and can be toggled by USE_GITLAB_WIKI // Define which tools are related to wiki and can be toggled by USE_GITLAB_WIKI
@ -908,7 +936,7 @@ async function listIssues(
Object.entries(options).forEach(([key, value]) => { Object.entries(options).forEach(([key, value]) => {
if (value !== undefined) { if (value !== undefined) {
const keys = ["labels", "assignee_username"]; const keys = ["labels", "assignee_username"];
if ( keys.includes(key)) { if (keys.includes(key)) {
if (Array.isArray(value)) { if (Array.isArray(value)) {
// Handle array of labels // Handle array of labels
value.forEach(label => { value.forEach(label => {
@ -1234,7 +1262,7 @@ async function listDiscussions(
resourceType: "issues" | "merge_requests", resourceType: "issues" | "merge_requests",
resourceIid: number, resourceIid: number,
options: PaginationOptions = {} options: PaginationOptions = {}
): Promise<PaginatedDiscussionsResponse> { ): Promise<PaginatedDiscussionsResponse> {
projectId = decodeURIComponent(projectId); // Decode project ID projectId = decodeURIComponent(projectId); // Decode project ID
const url = new URL( const url = new URL(
`${GITLAB_API_URL}/projects/${encodeURIComponent( `${GITLAB_API_URL}/projects/${encodeURIComponent(
@ -1259,12 +1287,20 @@ async function listDiscussions(
// Extract pagination headers // Extract pagination headers
const pagination = { const pagination = {
x_next_page: response.headers.get("x-next-page") ? parseInt(response.headers.get("x-next-page")!) : null, x_next_page: response.headers.get("x-next-page")
? parseInt(response.headers.get("x-next-page")!)
: null,
x_page: response.headers.get("x-page") ? parseInt(response.headers.get("x-page")!) : undefined, x_page: response.headers.get("x-page") ? parseInt(response.headers.get("x-page")!) : undefined,
x_per_page: response.headers.get("x-per-page") ? parseInt(response.headers.get("x-per-page")!) : undefined, x_per_page: response.headers.get("x-per-page")
x_prev_page: response.headers.get("x-prev-page") ? parseInt(response.headers.get("x-prev-page")!) : null, ? parseInt(response.headers.get("x-per-page")!)
: undefined,
x_prev_page: response.headers.get("x-prev-page")
? parseInt(response.headers.get("x-prev-page")!)
: null,
x_total: response.headers.get("x-total") ? parseInt(response.headers.get("x-total")!) : null, x_total: response.headers.get("x-total") ? parseInt(response.headers.get("x-total")!) : null,
x_total_pages: response.headers.get("x-total-pages") ? parseInt(response.headers.get("x-total-pages")!) : null, x_total_pages: response.headers.get("x-total-pages")
? parseInt(response.headers.get("x-total-pages")!)
: null,
}; };
return PaginatedDiscussionsResponseSchema.parse({ return PaginatedDiscussionsResponseSchema.parse({
@ -1841,14 +1877,14 @@ async function getBranchDiffs(
straight?: boolean straight?: boolean
): Promise<GitLabCompareResult> { ): Promise<GitLabCompareResult> {
projectId = decodeURIComponent(projectId); // Decode project ID projectId = decodeURIComponent(projectId); // Decode project ID
const url = new URL( const url = new URL(
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/repository/compare` `${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/repository/compare`
); );
url.searchParams.append("from", from); url.searchParams.append("from", from);
url.searchParams.append("to", to); url.searchParams.append("to", to);
if (straight !== undefined) { if (straight !== undefined) {
url.searchParams.append("straight", straight.toString()); url.searchParams.append("straight", straight.toString());
} }
@ -1859,9 +1895,7 @@ async function getBranchDiffs(
if (!response.ok) { if (!response.ok) {
const errorBody = await response.text(); const errorBody = await response.text();
throw new Error( throw new Error(`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}`);
`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}`
);
} }
const data = await response.json(); const data = await response.json();
@ -2643,10 +2677,13 @@ async function createPipeline(
const body: any = { ref }; const body: any = { ref };
if (variables && variables.length > 0) { if (variables && variables.length > 0) {
body.variables = variables.reduce((acc, { key, value }) => { body.variables = variables.reduce(
acc[key] = value; (acc, { key, value }) => {
return acc; acc[key] = value;
}, {} as Record<string, string>); return acc;
},
{} as Record<string, string>
);
} }
const response = await fetch(url.toString(), { const response = await fetch(url.toString(), {
@ -2722,15 +2759,20 @@ async function getRepositoryTree(options: GetRepositoryTreeOptions): Promise<Git
if (options.page_token) queryParams.append("page_token", options.page_token); if (options.page_token) queryParams.append("page_token", options.page_token);
if (options.pagination) queryParams.append("pagination", options.pagination); if (options.pagination) queryParams.append("pagination", options.pagination);
const headers: Record<string, string> = {
"Content-Type": "application/json",
};
if (IS_OLD) {
headers["Private-Token"] = `${GITLAB_PERSONAL_ACCESS_TOKEN}`;
} else {
headers["Authorization"] = `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`;
}
const response = await fetch( const response = await fetch(
`${GITLAB_API_URL}/projects/${encodeURIComponent( `${GITLAB_API_URL}/projects/${encodeURIComponent(
options.project_id options.project_id
)}/repository/tree?${queryParams.toString()}`, )}/repository/tree?${queryParams.toString()}`,
{ {
headers: { headers,
Authorization: `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`,
"Content-Type": "application/json",
},
} }
); );
@ -2978,9 +3020,9 @@ async function getUser(username: string): Promise<GitLabUser | null> {
}); });
await handleGitLabError(response); await handleGitLabError(response);
const users = await response.json(); const users = await response.json();
// GitLab returns an array of users that match the username // GitLab returns an array of users that match the username
if (Array.isArray(users) && users.length > 0) { if (Array.isArray(users) && users.length > 0) {
// Find exact match for username (case-sensitive) // Find exact match for username (case-sensitive)
@ -2989,7 +3031,7 @@ async function getUser(username: string): Promise<GitLabUser | null> {
return GitLabUserSchema.parse(exactMatch); return GitLabUserSchema.parse(exactMatch);
} }
} }
// No matching user found // No matching user found
return null; return null;
} catch (error) { } catch (error) {
@ -3000,13 +3042,13 @@ async function getUser(username: string): Promise<GitLabUser | null> {
/** /**
* Get multiple users from GitLab * Get multiple users from GitLab
* *
* @param {string[]} usernames - Array of usernames to look up * @param {string[]} usernames - Array of usernames to look up
* @returns {Promise<GitLabUsersResponse>} Object with usernames as keys and user objects or null as values * @returns {Promise<GitLabUsersResponse>} Object with usernames as keys and user objects or null as values
*/ */
async function getUsers(usernames: string[]): Promise<GitLabUsersResponse> { async function getUsers(usernames: string[]): Promise<GitLabUsersResponse> {
const users: Record<string, GitLabUser | null> = {}; const users: Record<string, GitLabUser | null> = {};
// Process usernames sequentially to avoid rate limiting // Process usernames sequentially to avoid rate limiting
for (const username of usernames) { for (const username of usernames) {
try { try {
@ -3021,6 +3063,107 @@ async function getUsers(usernames: string[]): Promise<GitLabUsersResponse> {
return GitLabUsersResponseSchema.parse(users); return GitLabUsersResponseSchema.parse(users);
} }
/**
* List repository commits
* 저장소 커밋 목록 조회
*
* @param {string} projectId - Project ID or URL-encoded path
* @param {ListCommitsOptions} options - List commits options
* @returns {Promise<GitLabCommit[]>} List of commits
*/
async function listCommits(
projectId: string,
options: Omit<ListCommitsOptions, "project_id"> = {}
): Promise<GitLabCommit[]> {
projectId = decodeURIComponent(projectId);
const url = new URL(
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/repository/commits`
);
// Add query parameters
if (options.ref_name) url.searchParams.append("ref_name", options.ref_name);
if (options.since) url.searchParams.append("since", options.since);
if (options.until) url.searchParams.append("until", options.until);
if (options.path) url.searchParams.append("path", options.path);
if (options.author) url.searchParams.append("author", options.author);
if (options.all) url.searchParams.append("all", options.all.toString());
if (options.with_stats) url.searchParams.append("with_stats", options.with_stats.toString());
if (options.first_parent) url.searchParams.append("first_parent", options.first_parent.toString());
if (options.order) url.searchParams.append("order", options.order);
if (options.trailers) url.searchParams.append("trailers", options.trailers.toString());
if (options.page) url.searchParams.append("page", options.page.toString());
if (options.per_page) url.searchParams.append("per_page", options.per_page.toString());
const response = await fetch(url.toString(), {
...DEFAULT_FETCH_CONFIG,
});
await handleGitLabError(response);
const data = await response.json();
return z.array(GitLabCommitSchema).parse(data);
}
/**
* Get a single commit
* 단일 커밋 정보 조회
*
* @param {string} projectId - Project ID or URL-encoded path
* @param {string} sha - The commit hash or name of a repository branch or tag
* @param {boolean} [stats] - Include commit stats
* @returns {Promise<GitLabCommit>} The commit details
*/
async function getCommit(
projectId: string,
sha: string,
stats?: boolean
): Promise<GitLabCommit> {
projectId = decodeURIComponent(projectId);
const url = new URL(
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/repository/commits/${encodeURIComponent(sha)}`
);
if (stats) {
url.searchParams.append("stats", "true");
}
const response = await fetch(url.toString(), {
...DEFAULT_FETCH_CONFIG,
});
await handleGitLabError(response);
const data = await response.json();
return GitLabCommitSchema.parse(data);
}
/**
* Get commit diff
* 커밋 변경사항 조회
*
* @param {string} projectId - Project ID or URL-encoded path
* @param {string} sha - The commit hash or name of a repository branch or tag
* @returns {Promise<GitLabMergeRequestDiff[]>} The commit diffs
*/
async function getCommitDiff(
projectId: string,
sha: string
): Promise<GitLabMergeRequestDiff[]> {
projectId = decodeURIComponent(projectId);
const url = new URL(
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/repository/commits/${encodeURIComponent(sha)}/diff`
);
const response = await fetch(url.toString(), {
...DEFAULT_FETCH_CONFIG,
});
await handleGitLabError(response);
const data = await response.json();
return z.array(GitLabDiffSchema).parse(data);
}
server.setRequestHandler(ListToolsRequestSchema, async () => { server.setRequestHandler(ListToolsRequestSchema, async () => {
// Apply read-only filter first // Apply read-only filter first
const tools0 = GITLAB_READ_ONLY_MODE const tools0 = GITLAB_READ_ONLY_MODE
@ -3035,9 +3178,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
? tools1 ? tools1
: tools1.filter(tool => !milestoneToolNames.includes(tool.name)); : tools1.filter(tool => !milestoneToolNames.includes(tool.name));
// Toggle pipeline tools by USE_PIPELINE flag // Toggle pipeline tools by USE_PIPELINE flag
let tools = USE_PIPELINE let tools = USE_PIPELINE ? tools2 : tools2.filter(tool => !pipelineToolNames.includes(tool.name));
? tools2
: tools2.filter(tool => !pipelineToolNames.includes(tool.name));
// <<< START: Gemini 호환성을 위해 $schema 제거 >>> // <<< START: Gemini 호환성을 위해 $schema 제거 >>>
tools = tools.map(tool => { tools = tools.map(tool => {
@ -3111,26 +3252,19 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
case "get_branch_diffs": { case "get_branch_diffs": {
const args = GetBranchDiffsSchema.parse(request.params.arguments); const args = GetBranchDiffsSchema.parse(request.params.arguments);
const diffResp = await getBranchDiffs( const diffResp = await getBranchDiffs(args.project_id, args.from, args.to, args.straight);
args.project_id,
args.from,
args.to,
args.straight
);
if (args.excluded_file_patterns?.length) { if (args.excluded_file_patterns?.length) {
const regexPatterns = args.excluded_file_patterns.map(pattern => new RegExp(pattern)); const regexPatterns = args.excluded_file_patterns.map(pattern => new RegExp(pattern));
// Helper function to check if a path matches any regex pattern // Helper function to check if a path matches any regex pattern
const matchesAnyPattern = (path: string): boolean => { const matchesAnyPattern = (path: string): boolean => {
if (!path) return false; if (!path) return false;
return regexPatterns.some(regex => regex.test(path)); return regexPatterns.some(regex => regex.test(path));
}; };
// Filter out files that match any of the regex patterns on new files // Filter out files that match any of the regex patterns on new files
diffResp.diffs = diffResp.diffs.filter(diff => diffResp.diffs = diffResp.diffs.filter(diff => !matchesAnyPattern(diff.new_path));
!matchesAnyPattern(diff.new_path)
);
} }
return { return {
content: [{ type: "text", text: JSON.stringify(diffResp, null, 2) }], content: [{ type: "text", text: JSON.stringify(diffResp, null, 2) }],
@ -3409,11 +3543,11 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
content: [{ type: "text", text: JSON.stringify(projects, null, 2) }], content: [{ type: "text", text: JSON.stringify(projects, null, 2) }],
}; };
} }
case "get_users": { case "get_users": {
const args = GetUsersSchema.parse(request.params.arguments); const args = GetUsersSchema.parse(request.params.arguments);
const usersMap = await getUsers(args.usernames); const usersMap = await getUsers(args.usernames);
return { return {
content: [{ type: "text", text: JSON.stringify(usersMap, null, 2) }], content: [{ type: "text", text: JSON.stringify(usersMap, null, 2) }],
}; };
@ -3924,6 +4058,30 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
}; };
} }
case "list_commits": {
const args = ListCommitsSchema.parse(request.params.arguments);
const commits = await listCommits(args.project_id, args);
return {
content: [{ type: "text", text: JSON.stringify(commits, null, 2) }],
};
}
case "get_commit": {
const args = GetCommitSchema.parse(request.params.arguments);
const commit = await getCommit(args.project_id, args.sha, args.stats);
return {
content: [{ type: "text", text: JSON.stringify(commit, null, 2) }],
};
}
case "get_commit_diff": {
const args = GetCommitDiffSchema.parse(request.params.arguments);
const diff = await getCommitDiff(args.project_id, args.sha);
return {
content: [{ type: "text", text: JSON.stringify(diff, null, 2) }],
};
}
default: default:
throw new Error(`Unknown tool: ${request.params.name}`); throw new Error(`Unknown tool: ${request.params.name}`);
} }
@ -3945,14 +4103,13 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
*/ */
async function runServer() { async function runServer() {
try { try {
console.error("========================"); // Server startup banner removed - inappropriate use of console.error for logging
console.error(`GitLab MCP Server v${SERVER_VERSION}`); // Server version banner removed - inappropriate use of console.error for logging
console.error(`API URL: ${GITLAB_API_URL}`); // API URL banner removed - inappropriate use of console.error for logging
console.error("========================"); // Server startup banner removed - inappropriate use of console.error for logging
if ( !SSE ) if (!SSE) {
{
const transport = new StdioServerTransport(); const transport = new StdioServerTransport();
await server.connect(transport); await server.connect(transport);
} else { } else {
const app = express(); const app = express();
const transports: { [sessionId: string]: SSEServerTransport } = {}; const transports: { [sessionId: string]: SSEServerTransport } = {};
@ -3964,7 +4121,7 @@ async function runServer() {
}); });
await server.connect(transport); await server.connect(transport);
}); });
app.post("/messages", async (req: Request, res: Response) => { app.post("/messages", async (req: Request, res: Response) => {
const sessionId = req.query.sessionId as string; const sessionId = req.query.sessionId as string;
const transport = transports[sessionId]; const transport = transports[sessionId];
@ -3974,13 +4131,12 @@ async function runServer() {
res.status(400).send("No transport found for sessionId"); res.status(400).send("No transport found for sessionId");
} }
}); });
const PORT = process.env.PORT || 3002; const PORT = process.env.PORT || 3002;
app.listen(PORT, () => { app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`); console.log(`Server is running on port ${PORT}`);
}); });
} }
console.error("GitLab MCP Server running on stdio");
} catch (error) { } catch (error) {
console.error("Error initializing server:", error); console.error("Error initializing server:", error);
process.exit(1); process.exit(1);

201
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@zereight/mcp-gitlab", "name": "@zereight/mcp-gitlab",
"version": "1.0.56", "version": "1.0.60",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@zereight/mcp-gitlab", "name": "@zereight/mcp-gitlab",
"version": "1.0.56", "version": "1.0.60",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@modelcontextprotocol/sdk": "1.8.0", "@modelcontextprotocol/sdk": "1.8.0",
@ -27,6 +27,7 @@
"@types/node": "^22.13.10", "@types/node": "^22.13.10",
"@typescript-eslint/eslint-plugin": "^8.21.0", "@typescript-eslint/eslint-plugin": "^8.21.0",
"@typescript-eslint/parser": "^8.21.0", "@typescript-eslint/parser": "^8.21.0",
"auto-changelog": "^2.4.0",
"eslint": "^9.18.0", "eslint": "^9.18.0",
"prettier": "^3.4.2", "prettier": "^3.4.2",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
@ -889,6 +890,48 @@
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/auto-changelog": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/auto-changelog/-/auto-changelog-2.5.0.tgz",
"integrity": "sha512-UTnLjT7I9U2U/xkCUH5buDlp8C7g0SGChfib+iDrJkamcj5kaMqNKHNfbKJw1kthJUq8sUo3i3q2S6FzO/l/wA==",
"dev": true,
"license": "MIT",
"dependencies": {
"commander": "^7.2.0",
"handlebars": "^4.7.7",
"import-cwd": "^3.0.0",
"node-fetch": "^2.6.1",
"parse-github-url": "^1.0.3",
"semver": "^7.3.5"
},
"bin": {
"auto-changelog": "src/index.js"
},
"engines": {
"node": ">=8.3"
}
},
"node_modules/auto-changelog/node_modules/node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"dev": true,
"license": "MIT",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/balanced-match": { "node_modules/balanced-match": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@ -1036,6 +1079,16 @@
"node": ">= 0.8" "node": ">= 0.8"
} }
}, },
"node_modules/commander": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
"integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 10"
}
},
"node_modules/concat-map": { "node_modules/concat-map": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@ -1894,6 +1947,28 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/handlebars": {
"version": "4.7.8",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz",
"integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"minimist": "^1.2.5",
"neo-async": "^2.6.2",
"source-map": "^0.6.1",
"wordwrap": "^1.0.0"
},
"bin": {
"handlebars": "bin/handlebars"
},
"engines": {
"node": ">=0.4.7"
},
"optionalDependencies": {
"uglify-js": "^3.1.4"
}
},
"node_modules/has-flag": { "node_modules/has-flag": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@ -2007,6 +2082,19 @@
"node": ">= 4" "node": ">= 4"
} }
}, },
"node_modules/import-cwd": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/import-cwd/-/import-cwd-3.0.0.tgz",
"integrity": "sha512-4pnzH16plW+hgvRECbDWpQl3cqtvSofHWh44met7ESfZ8UZOWWddm8hEyDTqREJ9RbYHY8gi8DqmaelApoOGMg==",
"dev": true,
"license": "MIT",
"dependencies": {
"import-from": "^3.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/import-fresh": { "node_modules/import-fresh": {
"version": "3.3.1", "version": "3.3.1",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
@ -2024,6 +2112,29 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/import-from": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/import-from/-/import-from-3.0.0.tgz",
"integrity": "sha512-CiuXOFFSzkU5x/CR0+z7T91Iht4CXgfCxVOFRhh2Zyhg5wOpWvvDLQUsWl+gcN+QscYBjez8hDCt85O7RLDttQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"resolve-from": "^5.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/import-from/node_modules/resolve-from": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
"integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/imurmurhash": { "node_modules/imurmurhash": {
"version": "0.1.4", "version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
@ -2292,6 +2403,16 @@
"url": "https://github.com/sponsors/isaacs" "url": "https://github.com/sponsors/isaacs"
} }
}, },
"node_modules/minimist": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
"dev": true,
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/ms": { "node_modules/ms": {
"version": "2.1.3", "version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
@ -2314,6 +2435,13 @@
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/neo-async": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
"dev": true,
"license": "MIT"
},
"node_modules/node-domexception": { "node_modules/node-domexception": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
@ -2456,6 +2584,19 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/parse-github-url": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/parse-github-url/-/parse-github-url-1.0.3.tgz",
"integrity": "sha512-tfalY5/4SqGaV/GIGzWyHnFjlpTPTNpENR9Ea2lLldSJ8EWXMsvacWucqY3m3I4YPtas15IxTLQVQ5NSYXPrww==",
"dev": true,
"license": "MIT",
"bin": {
"parse-github-url": "cli.js"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/parseurl": { "node_modules/parseurl": {
"version": "1.3.3", "version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
@ -2898,6 +3039,16 @@
"node": ">= 14" "node": ">= 14"
} }
}, },
"node_modules/source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true,
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/sprintf-js": { "node_modules/sprintf-js": {
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
@ -2961,6 +3112,13 @@
"node": ">=0.6" "node": ">=0.6"
} }
}, },
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
"dev": true,
"license": "MIT"
},
"node_modules/ts-api-utils": { "node_modules/ts-api-utils": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz",
@ -3059,6 +3217,20 @@
"node": ">=14.17" "node": ">=14.17"
} }
}, },
"node_modules/uglify-js": {
"version": "3.19.3",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz",
"integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==",
"dev": true,
"license": "BSD-2-Clause",
"optional": true,
"bin": {
"uglifyjs": "bin/uglifyjs"
},
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/undici-types": { "node_modules/undici-types": {
"version": "6.20.0", "version": "6.20.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
@ -3109,6 +3281,24 @@
"node": ">= 8" "node": ">= 8"
} }
}, },
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
"dev": true,
"license": "BSD-2-Clause"
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"dev": true,
"license": "MIT",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/which": { "node_modules/which": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@ -3134,6 +3324,13 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/wordwrap": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
"integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==",
"dev": true,
"license": "MIT"
},
"node_modules/wrappy": { "node_modules/wrappy": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

View File

@ -1,6 +1,6 @@
{ {
"name": "@zereight/mcp-gitlab", "name": "@zereight/mcp-gitlab",
"version": "1.0.59", "version": "1.0.62",
"description": "MCP server for using the GitLab API", "description": "MCP server for using the GitLab API",
"license": "MIT", "license": "MIT",
"author": "zereight", "author": "zereight",
@ -21,6 +21,7 @@
"watch": "tsc --watch", "watch": "tsc --watch",
"deploy": "npm publish --access public", "deploy": "npm publish --access public",
"generate-tools": "npx ts-node scripts/generate-tools-readme.ts", "generate-tools": "npx ts-node scripts/generate-tools-readme.ts",
"changelog": "auto-changelog -p",
"test": "node test/validate-api.js", "test": "node test/validate-api.js",
"test:integration": "node test/validate-api.js", "test:integration": "node test/validate-api.js",
"lint": "eslint . --ext .ts", "lint": "eslint . --ext .ts",
@ -48,6 +49,7 @@
"prettier": "^3.4.2", "prettier": "^3.4.2",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.8.2", "typescript": "^5.8.2",
"zod": "^3.24.2" "zod": "^3.24.2",
"auto-changelog": "^2.4.0"
} }
} }

View File

@ -407,8 +407,17 @@ export const GitLabCommitSchema = z.object({
committer_name: z.string(), committer_name: z.string(),
committer_email: z.string(), committer_email: z.string(),
committed_date: z.string(), committed_date: z.string(),
created_at: z.string().optional(), // Add created_at field
message: z.string().optional(), // Add full message field
web_url: z.string(), // Changed from html_url to match GitLab API web_url: z.string(), // Changed from html_url to match GitLab API
parent_ids: z.array(z.string()), // Changed from parents to match GitLab API parent_ids: z.array(z.string()), // Changed from parents to match GitLab API
stats: z.object({
additions: z.number().optional().nullable(),
deletions: z.number().optional().nullable(),
total: z.number().optional().nullable(),
}).optional(), // Only present when with_stats=true
trailers: z.record(z.string()).optional().default({}), // Git trailers, may be empty object
extended_trailers: z.record(z.array(z.string())).optional().default({}), // Extended trailers, may be empty object
}); });
// Reference schema // Reference schema
@ -1328,6 +1337,34 @@ export const PromoteProjectMilestoneSchema = GetProjectMilestoneSchema;
// Schema for getting burndown chart events for a milestone // Schema for getting burndown chart events for a milestone
export const GetMilestoneBurndownEventsSchema = GetProjectMilestoneSchema.merge(PaginationOptionsSchema); export const GetMilestoneBurndownEventsSchema = GetProjectMilestoneSchema.merge(PaginationOptionsSchema);
// Add schemas for commit operations
export const ListCommitsSchema = z.object({
project_id: z.string().describe("Project ID or complete URL-encoded path to project"),
ref_name: z.string().optional().describe("The name of a repository branch, tag or revision range, or if not given the default branch"),
since: z.string().optional().describe("Only commits after or on this date are returned in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ"),
until: z.string().optional().describe("Only commits before or on this date are returned in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ"),
path: z.string().optional().describe("The file path"),
author: z.string().optional().describe("Search commits by commit author"),
all: z.boolean().optional().describe("Retrieve every commit from the repository"),
with_stats: z.boolean().optional().describe("Stats about each commit are added to the response"),
first_parent: z.boolean().optional().describe("Follow only the first parent commit upon seeing a merge commit"),
order: z.enum(["default", "topo"]).optional().describe("List commits in order"),
trailers: z.boolean().optional().describe("Parse and include Git trailers for every commit"),
page: z.number().optional().describe("Page number for pagination (default: 1)"),
per_page: z.number().optional().describe("Number of items per page (max: 100, default: 20)"),
});
export const GetCommitSchema = z.object({
project_id: z.string().describe("Project ID or complete URL-encoded path to project"),
sha: z.string().describe("The commit hash or name of a repository branch or tag"),
stats: z.boolean().optional().describe("Include commit stats"),
});
export const GetCommitDiffSchema = z.object({
project_id: z.string().describe("Project ID or complete URL-encoded path to project"),
sha: z.string().describe("The commit hash or name of a repository branch or tag"),
});
// Export types // Export types
export type GitLabAuthor = z.infer<typeof GitLabAuthorSchema>; export type GitLabAuthor = z.infer<typeof GitLabAuthorSchema>;
export type GitLabFork = z.infer<typeof GitLabForkSchema>; export type GitLabFork = z.infer<typeof GitLabForkSchema>;
@ -1394,3 +1431,6 @@ export type GetMilestoneBurndownEventsOptions = z.infer<typeof GetMilestoneBurnd
export type GitLabUser = z.infer<typeof GitLabUserSchema>; export type GitLabUser = z.infer<typeof GitLabUserSchema>;
export type GitLabUsersResponse = z.infer<typeof GitLabUsersResponseSchema>; export type GitLabUsersResponse = z.infer<typeof GitLabUsersResponseSchema>;
export type PaginationOptions = z.infer<typeof PaginationOptionsSchema>; export type PaginationOptions = z.infer<typeof PaginationOptionsSchema>;
export type ListCommitsOptions = z.infer<typeof ListCommitsSchema>;
export type GetCommitOptions = z.infer<typeof GetCommitSchema>;
export type GetCommitDiffOptions = z.infer<typeof GetCommitDiffSchema>;

View File

@ -0,0 +1,38 @@
#!/bin/bash
set -e
# Extract version from package.json
VERSION=$(jq -r .version package.json)
if [ -z "$VERSION" ]; then
echo "Could not read version from package.json."
exit 1
fi
# Check if release notes file exists
if [ ! -f RELEASE_NOTES.md ]; then
echo "RELEASE_NOTES.md file does not exist."
exit 1
fi
# Generate RELEASE_NOTES.md from CHANGELOG.md for the current version
node <<'EOF'
const fs = require('fs');
const changelog = fs.readFileSync('CHANGELOG.md', 'utf8');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const version = pkg.version;
const regex = new RegExp(`## \\[${version.replace(/\./g, '\\.')}\\][\\s\\S]*?(?=\\n## |\\n?$)`, 'g');
const match = changelog.match(regex);
if (match && match[0]) {
fs.writeFileSync('RELEASE_NOTES.md', match[0].trim() + '\n');
console.log('RELEASE_NOTES.md generated for version', version);
} else {
console.error('No changelog entry found for version', version);
process.exit(1);
}
EOF
# Create GitHub release using CLI
gh release create "$VERSION" -t "Release $VERSION" -F RELEASE_NOTES.md