@zereight/mcp-gitlab 1.0.61 → 1.0.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -97,7 +97,7 @@ const DEFAULT_HEADERS = {
97
97
  "Content-Type": "application/json",
98
98
  };
99
99
  if (IS_OLD) {
100
- DEFAULT_HEADERS["Private-Token"] = `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`;
100
+ DEFAULT_HEADERS["Private-Token"] = `${GITLAB_PERSONAL_ACCESS_TOKEN}`;
101
101
  }
102
102
  else {
103
103
  DEFAULT_HEADERS["Authorization"] = `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`;
@@ -366,7 +366,7 @@ const allTools = [
366
366
  },
367
367
  {
368
368
  name: "get_pipeline_job_output",
369
- description: "Get the output/trace of a GitLab pipeline job number",
369
+ description: "Get the output/trace of a GitLab pipeline job with optional pagination to limit context window usage",
370
370
  inputSchema: zodToJsonSchema(GetPipelineJobOutputSchema),
371
371
  },
372
372
  {
@@ -1963,9 +1963,11 @@ async function getPipelineJob(projectId, jobId) {
1963
1963
  *
1964
1964
  * @param {string} projectId - The ID or URL-encoded path of the project
1965
1965
  * @param {number} jobId - The ID of the job
1966
+ * @param {number} limit - Maximum number of lines to return from the end (default: 1000)
1967
+ * @param {number} offset - Number of lines to skip from the end (default: 0)
1966
1968
  * @returns {Promise<string>} The job output/trace
1967
1969
  */
1968
- async function getPipelineJobOutput(projectId, jobId) {
1970
+ async function getPipelineJobOutput(projectId, jobId, limit, offset) {
1969
1971
  projectId = decodeURIComponent(projectId); // Decode project ID
1970
1972
  const url = new URL(`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/jobs/${jobId}/trace`);
1971
1973
  const response = await fetch(url.toString(), {
@@ -1979,7 +1981,28 @@ async function getPipelineJobOutput(projectId, jobId) {
1979
1981
  throw new Error(`Job trace not found or job is not finished yet`);
1980
1982
  }
1981
1983
  await handleGitLabError(response);
1982
- return await response.text();
1984
+ const fullTrace = await response.text();
1985
+ // Apply client-side pagination to limit context window usage
1986
+ if (limit !== undefined || offset !== undefined) {
1987
+ const lines = fullTrace.split('\n');
1988
+ const startOffset = offset || 0;
1989
+ const maxLines = limit || 1000;
1990
+ // Return lines from the end, skipping offset lines and limiting to maxLines
1991
+ const startIndex = Math.max(0, lines.length - startOffset - maxLines);
1992
+ const endIndex = lines.length - startOffset;
1993
+ const selectedLines = lines.slice(startIndex, endIndex);
1994
+ const result = selectedLines.join('\n');
1995
+ // Add metadata about truncation
1996
+ if (startIndex > 0 || endIndex < lines.length) {
1997
+ const totalLines = lines.length;
1998
+ const shownLines = selectedLines.length;
1999
+ const skippedFromStart = startIndex;
2000
+ const skippedFromEnd = startOffset;
2001
+ return `[Log truncated: showing ${shownLines} of ${totalLines} lines, skipped ${skippedFromStart} from start, ${skippedFromEnd} from end]\n\n${result}`;
2002
+ }
2003
+ return result;
2004
+ }
2005
+ return fullTrace;
1983
2006
  }
1984
2007
  /**
1985
2008
  * Create a new pipeline
@@ -2069,7 +2092,7 @@ async function getRepositoryTree(options) {
2069
2092
  "Content-Type": "application/json",
2070
2093
  };
2071
2094
  if (IS_OLD) {
2072
- headers["Private-Token"] = `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`;
2095
+ headers["Private-Token"] = `${GITLAB_PERSONAL_ACCESS_TOKEN}`;
2073
2096
  }
2074
2097
  else {
2075
2098
  headers["Authorization"] = `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`;
@@ -2823,8 +2846,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
2823
2846
  };
2824
2847
  }
2825
2848
  case "get_pipeline_job_output": {
2826
- const { project_id, job_id } = GetPipelineJobOutputSchema.parse(request.params.arguments);
2827
- const jobOutput = await getPipelineJobOutput(project_id, job_id);
2849
+ const { project_id, job_id, limit, offset } = GetPipelineJobOutputSchema.parse(request.params.arguments);
2850
+ const jobOutput = await getPipelineJobOutput(project_id, job_id, limit, offset);
2828
2851
  return {
2829
2852
  content: [
2830
2853
  {
package/build/schemas.js CHANGED
@@ -178,6 +178,8 @@ export const CancelPipelineSchema = z.object({
178
178
  export const GetPipelineJobOutputSchema = z.object({
179
179
  project_id: z.string().describe("Project ID or URL-encoded path"),
180
180
  job_id: z.number().describe("The ID of the job"),
181
+ limit: z.number().optional().describe("Maximum number of lines to return from the end of the log (default: 1000)"),
182
+ offset: z.number().optional().describe("Number of lines to skip from the end of the log (default: 0)"),
181
183
  });
182
184
  // User schemas
183
185
  export const GitLabUserSchema = z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zereight/mcp-gitlab",
3
- "version": "1.0.61",
3
+ "version": "1.0.63",
4
4
  "description": "MCP server for using the GitLab API",
5
5
  "license": "MIT",
6
6
  "author": "zereight",