Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
402f068470 | |||
83a8aa8fc2 | |||
8d706275e6 |
14
CHANGELOG.md
14
CHANGELOG.md
@ -1,3 +1,17 @@
|
|||||||
|
## [1.0.63] - 2025-06-12
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 📊 **CI Job Log Pagination**: Added pagination support for CI job logs to prevent context window flooding
|
||||||
|
- `get_pipeline_job_output` now supports optional `limit` and `offset` parameters
|
||||||
|
- Default limit is 1000 lines when pagination is used
|
||||||
|
- Returns lines from the end of the log, with configurable offset
|
||||||
|
- Includes truncation metadata showing what was skipped
|
||||||
|
- Maintains backward compatibility (no parameters = full log)
|
||||||
|
- See: [PR #97](https://github.com/zereight/gitlab-mcp/pull/97)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## [1.0.62] - 2025-06-10
|
## [1.0.62] - 2025-06-10
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -111,6 +111,7 @@ $ sh scripts/image_push.sh docker_user_name
|
|||||||
- `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_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_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.
|
- `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.
|
||||||
|
- `GITLAB_AUTH_COOKIE_PATH`: Path to an authentication cookie file for GitLab instances that require cookie-based authentication. When provided, the cookie will be included in all GitLab API requests.
|
||||||
|
|
||||||
## Tools 🛠️
|
## Tools 🛠️
|
||||||
|
|
||||||
|
92
index.ts
92
index.ts
@ -4,7 +4,9 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|||||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||||
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
||||||
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
||||||
import fetch from "node-fetch";
|
import nodeFetch from "node-fetch";
|
||||||
|
import fetchCookie from "fetch-cookie";
|
||||||
|
import { CookieJar, parse as parseCookie } from "tough-cookie";
|
||||||
import { SocksProxyAgent } from "socks-proxy-agent";
|
import { SocksProxyAgent } from "socks-proxy-agent";
|
||||||
import { HttpsProxyAgent } from "https-proxy-agent";
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
||||||
import { HttpProxyAgent } from "http-proxy-agent";
|
import { HttpProxyAgent } from "http-proxy-agent";
|
||||||
@ -203,6 +205,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 GITLAB_AUTH_COOKIE_PATH = process.env.GITLAB_AUTH_COOKIE_PATH;
|
||||||
const IS_OLD = process.env.GITLAB_IS_OLD === "true";
|
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";
|
||||||
@ -245,6 +248,88 @@ if (HTTPS_PROXY) {
|
|||||||
httpsAgent = httpsAgent || new HttpsAgent(sslOptions);
|
httpsAgent = httpsAgent || new HttpsAgent(sslOptions);
|
||||||
httpAgent = httpAgent || new Agent();
|
httpAgent = httpAgent || new Agent();
|
||||||
|
|
||||||
|
// Create cookie jar with clean Netscape file parsing
|
||||||
|
const createCookieJar = (): CookieJar | null => {
|
||||||
|
if (!GITLAB_AUTH_COOKIE_PATH) return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cookiePath = GITLAB_AUTH_COOKIE_PATH.startsWith("~/")
|
||||||
|
? path.join(process.env.HOME || "", GITLAB_AUTH_COOKIE_PATH.slice(2))
|
||||||
|
: GITLAB_AUTH_COOKIE_PATH;
|
||||||
|
|
||||||
|
const jar = new CookieJar();
|
||||||
|
const cookieContent = fs.readFileSync(cookiePath, "utf8");
|
||||||
|
|
||||||
|
cookieContent.split("\n").forEach(line => {
|
||||||
|
// Handle #HttpOnly_ prefix
|
||||||
|
if (line.startsWith("#HttpOnly_")) {
|
||||||
|
line = line.slice(10);
|
||||||
|
}
|
||||||
|
// Skip comments and empty lines
|
||||||
|
if (line.startsWith("#") || !line.trim()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse Netscape format: domain, flag, path, secure, expires, name, value
|
||||||
|
const parts = line.split("\t");
|
||||||
|
if (parts.length >= 7) {
|
||||||
|
const [domain, , path, secure, expires, name, value] = parts;
|
||||||
|
|
||||||
|
// Build cookie string in standard format
|
||||||
|
const cookieStr = `${name}=${value}; Domain=${domain}; Path=${path}${secure === "TRUE" ? "; Secure" : ""}${expires !== "0" ? `; Expires=${new Date(parseInt(expires) * 1000).toUTCString()}` : ""}`;
|
||||||
|
|
||||||
|
// Use tough-cookie's parse function for robust parsing
|
||||||
|
const cookie = parseCookie(cookieStr);
|
||||||
|
if (cookie) {
|
||||||
|
const url = `${secure === "TRUE" ? "https" : "http"}://${domain.startsWith(".") ? domain.slice(1) : domain}`;
|
||||||
|
jar.setCookieSync(cookie, url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return jar;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error loading cookie file:", error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initialize cookie jar and fetch
|
||||||
|
const cookieJar = createCookieJar();
|
||||||
|
const fetch = cookieJar ? fetchCookie(nodeFetch, cookieJar) : nodeFetch;
|
||||||
|
|
||||||
|
// Ensure session is established for the current request
|
||||||
|
async function ensureSessionForRequest(): Promise<void> {
|
||||||
|
if (!cookieJar || !GITLAB_AUTH_COOKIE_PATH) return;
|
||||||
|
|
||||||
|
// Extract the base URL from GITLAB_API_URL
|
||||||
|
const apiUrl = new URL(GITLAB_API_URL);
|
||||||
|
const baseUrl = `${apiUrl.protocol}//${apiUrl.hostname}`;
|
||||||
|
|
||||||
|
// Check if we already have GitLab session cookies
|
||||||
|
const gitlabCookies = cookieJar.getCookiesSync(baseUrl);
|
||||||
|
const hasSessionCookie = gitlabCookies.some(cookie =>
|
||||||
|
cookie.key === '_gitlab_session' || cookie.key === 'remember_user_token'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!hasSessionCookie) {
|
||||||
|
try {
|
||||||
|
// Establish session with a lightweight request
|
||||||
|
await fetch(`${GITLAB_API_URL}/user`, {
|
||||||
|
...DEFAULT_FETCH_CONFIG,
|
||||||
|
redirect: 'follow'
|
||||||
|
}).catch(() => {
|
||||||
|
// Ignore errors - the important thing is that cookies get set during redirects
|
||||||
|
});
|
||||||
|
|
||||||
|
// Small delay to ensure cookies are fully processed
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
|
} catch (error) {
|
||||||
|
// Ignore session establishment errors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Modify DEFAULT_HEADERS to include agent configuration
|
// Modify DEFAULT_HEADERS to include agent configuration
|
||||||
const DEFAULT_HEADERS: Record<string, string> = {
|
const DEFAULT_HEADERS: Record<string, string> = {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
@ -3112,6 +3197,11 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
|||||||
if (!request.params.arguments) {
|
if (!request.params.arguments) {
|
||||||
throw new Error("Arguments are required");
|
throw new Error("Arguments are required");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure session is established for every request if cookie authentication is enabled
|
||||||
|
if (GITLAB_AUTH_COOKIE_PATH) {
|
||||||
|
await ensureSessionForRequest();
|
||||||
|
}
|
||||||
|
|
||||||
switch (request.params.name) {
|
switch (request.params.name) {
|
||||||
case "fork_repository": {
|
case "fork_repository": {
|
||||||
|
52
package-lock.json
generated
52
package-lock.json
generated
@ -1,22 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "@zereight/mcp-gitlab",
|
"name": "@zereight/mcp-gitlab",
|
||||||
"version": "1.0.60",
|
"version": "1.0.62",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@zereight/mcp-gitlab",
|
"name": "@zereight/mcp-gitlab",
|
||||||
"version": "1.0.60",
|
"version": "1.0.62",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@modelcontextprotocol/sdk": "1.8.0",
|
"@modelcontextprotocol/sdk": "1.8.0",
|
||||||
"@types/node-fetch": "^2.6.12",
|
"@types/node-fetch": "^2.6.12",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
|
"fetch-cookie": "^3.1.0",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"http-proxy-agent": "^7.0.2",
|
"http-proxy-agent": "^7.0.2",
|
||||||
"https-proxy-agent": "^7.0.6",
|
"https-proxy-agent": "^7.0.6",
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"socks-proxy-agent": "^8.0.5",
|
"socks-proxy-agent": "^8.0.5",
|
||||||
|
"tough-cookie": "^5.1.2",
|
||||||
"zod-to-json-schema": "^3.23.5"
|
"zod-to-json-schema": "^3.23.5"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
@ -1709,6 +1711,16 @@
|
|||||||
"node": "^12.20 || >= 14.13"
|
"node": "^12.20 || >= 14.13"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/fetch-cookie": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-s/XhhreJpqH0ftkGVcQt8JE9bqk+zRn4jF5mPJXWZeQMCI5odV9K+wEWYbnzFPHgQZlvPSMjS4n4yawWE8RINw==",
|
||||||
|
"license": "Unlicense",
|
||||||
|
"dependencies": {
|
||||||
|
"set-cookie-parser": "^2.4.8",
|
||||||
|
"tough-cookie": "^5.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/file-entry-cache": {
|
"node_modules/file-entry-cache": {
|
||||||
"version": "8.0.0",
|
"version": "8.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz",
|
||||||
@ -2902,6 +2914,12 @@
|
|||||||
"node": ">= 18"
|
"node": ">= 18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/set-cookie-parser": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/setprototypeof": {
|
"node_modules/setprototypeof": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
|
||||||
@ -3090,6 +3108,24 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tldts": {
|
||||||
|
"version": "6.1.86",
|
||||||
|
"resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.86.tgz",
|
||||||
|
"integrity": "sha512-WMi/OQ2axVTf/ykqCQgXiIct+mSQDFdH2fkwhPwgEwvJ1kSzZRiinb0zF2Xb8u4+OqPChmyI6MEu4EezNJz+FQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tldts-core": "^6.1.86"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"tldts": "bin/cli.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tldts-core": {
|
||||||
|
"version": "6.1.86",
|
||||||
|
"resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.86.tgz",
|
||||||
|
"integrity": "sha512-Je6p7pkk+KMzMv2XXKmAE3McmolOQFdxkKw0R8EYNr7sELW46JqnNeTX8ybPiQgvg1ymCoF8LXs5fzFaZvJPTA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/to-regex-range": {
|
"node_modules/to-regex-range": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||||
@ -3112,6 +3148,18 @@
|
|||||||
"node": ">=0.6"
|
"node": ">=0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tough-cookie": {
|
||||||
|
"version": "5.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-5.1.2.tgz",
|
||||||
|
"integrity": "sha512-FVDYdxtnj0G6Qm/DhNPSb8Ju59ULcup3tuJxkFb5K8Bv2pUXILbf0xZWU8PX8Ov19OXljbUyveOFwRMwkXzO+A==",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"tldts": "^6.1.32"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/tr46": {
|
"node_modules/tr46": {
|
||||||
"version": "0.0.3",
|
"version": "0.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||||
|
@ -33,11 +33,13 @@
|
|||||||
"@modelcontextprotocol/sdk": "1.8.0",
|
"@modelcontextprotocol/sdk": "1.8.0",
|
||||||
"@types/node-fetch": "^2.6.12",
|
"@types/node-fetch": "^2.6.12",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
|
"fetch-cookie": "^3.1.0",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"http-proxy-agent": "^7.0.2",
|
"http-proxy-agent": "^7.0.2",
|
||||||
"https-proxy-agent": "^7.0.6",
|
"https-proxy-agent": "^7.0.6",
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"socks-proxy-agent": "^8.0.5",
|
"socks-proxy-agent": "^8.0.5",
|
||||||
|
"tough-cookie": "^5.1.2",
|
||||||
"zod-to-json-schema": "^3.23.5"
|
"zod-to-json-schema": "^3.23.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -298,14 +298,14 @@ export const GitLabRepositorySchema = z.object({
|
|||||||
project_access: z
|
project_access: z
|
||||||
.object({
|
.object({
|
||||||
access_level: z.number(),
|
access_level: z.number(),
|
||||||
notification_level: z.number().optional(),
|
notification_level: z.number().nullable().optional(),
|
||||||
})
|
})
|
||||||
.optional()
|
.optional()
|
||||||
.nullable(),
|
.nullable(),
|
||||||
group_access: z
|
group_access: z
|
||||||
.object({
|
.object({
|
||||||
access_level: z.number(),
|
access_level: z.number(),
|
||||||
notification_level: z.number().optional(),
|
notification_level: z.number().nullable().optional(),
|
||||||
})
|
})
|
||||||
.optional()
|
.optional()
|
||||||
.nullable(),
|
.nullable(),
|
||||||
|
Reference in New Issue
Block a user