gitlab-docs-mcp 1.0.1 → 1.1.0

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": "1.0.0",
3
- "document_count": 2494,
4
- "created_at": "2025-12-06T22:10:11.500Z",
3
+ "document_count": 2507,
4
+ "created_at": "2025-12-08T13:56:08.027Z",
5
5
  "source_repo": "https://gitlab.com/gitlab-org/gitlab-docs"
6
6
  }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Document chunking utilities for splitting large documents into manageable pieces
3
+ * Specifically handles the massive GraphQL reference documentation
4
+ */
5
+ interface ChunkConfig {
6
+ /**
7
+ * Maximum size in characters before chunking is applied
8
+ */
9
+ maxChunkSize: number;
10
+ /**
11
+ * Section markers that indicate logical split points
12
+ */
13
+ sectionMarkers: string[];
14
+ /**
15
+ * Overlap between chunks to preserve context
16
+ */
17
+ overlapSize: number;
18
+ }
19
+ interface DocumentChunk {
20
+ /**
21
+ * Original document path with chunk suffix
22
+ */
23
+ path: string;
24
+ /**
25
+ * Title of the chunk
26
+ */
27
+ title: string;
28
+ /**
29
+ * Content of the chunk
30
+ */
31
+ content: string;
32
+ /**
33
+ * Which chunk this is (1-indexed)
34
+ */
35
+ chunkIndex: number;
36
+ /**
37
+ * Total number of chunks for this document
38
+ */
39
+ totalChunks: number;
40
+ }
41
+ /**
42
+ * Checks if a document should be chunked based on size and path
43
+ */
44
+ export declare function shouldChunkDocument(path: string, content: string): boolean;
45
+ /**
46
+ * Splits a large document into logical chunks based on section markers
47
+ */
48
+ export declare function chunkDocument(path: string, title: string, content: string, config?: ChunkConfig): DocumentChunk[];
49
+ /**
50
+ * Creates a summary chunk with links to all other chunks
51
+ */
52
+ export declare function createSummaryChunk(originalPath: string, originalTitle: string, chunks: DocumentChunk[]): string;
53
+ export {};
54
+ //# sourceMappingURL=chunker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunker.d.ts","sourceRoot":"","sources":["../../src/content/chunker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,UAAU,WAAW;IACnB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;IAEzB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,aAAa;IACrB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAqBD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAM1E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,WAAkC,GACzC,aAAa,EAAE,CAkEjB;AA+DD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,aAAa,EAAE,GACtB,MAAM,CA8BR"}
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Document chunking utilities for splitting large documents into manageable pieces
3
+ * Specifically handles the massive GraphQL reference documentation
4
+ */
5
+ import { logger } from '../utils/logger.js';
6
+ /**
7
+ * Default configuration for GraphQL reference chunking
8
+ * Note: These markers are based on GitLab's auto-generated GraphQL documentation structure.
9
+ * If markers change, the system falls back to size-based chunking automatically.
10
+ */
11
+ const GRAPHQL_CHUNK_CONFIG = {
12
+ maxChunkSize: 500000, // 500KB per chunk
13
+ sectionMarkers: [
14
+ 'Query type',
15
+ 'Mutation type',
16
+ 'Object types',
17
+ 'Enumeration types',
18
+ 'Scalar types',
19
+ 'Abstract types',
20
+ 'Input types',
21
+ ],
22
+ overlapSize: 1000, // 1KB overlap to preserve context
23
+ };
24
+ /**
25
+ * Checks if a document should be chunked based on size and path
26
+ */
27
+ export function shouldChunkDocument(path, content) {
28
+ // Only chunk the massive GraphQL reference file
29
+ if (path === 'api/graphql/reference/_index.md' && content.length > 500000) {
30
+ return true;
31
+ }
32
+ return false;
33
+ }
34
+ /**
35
+ * Splits a large document into logical chunks based on section markers
36
+ */
37
+ export function chunkDocument(path, title, content, config = GRAPHQL_CHUNK_CONFIG) {
38
+ const chunks = [];
39
+ // Find all section markers
40
+ const sections = [];
41
+ for (const marker of config.sectionMarkers) {
42
+ const regex = new RegExp(`^${marker}\\s*$`, 'gm');
43
+ let match;
44
+ while ((match = regex.exec(content)) !== null) {
45
+ sections.push({
46
+ marker,
47
+ position: match.index,
48
+ });
49
+ }
50
+ }
51
+ // Sort sections by position
52
+ sections.sort((a, b) => a.position - b.position);
53
+ if (sections.length === 0) {
54
+ // No sections found, fall back to size-based chunking
55
+ logger.warn(`No section markers found in ${path}, using size-based chunking`);
56
+ return chunkBySize(path, title, content, config);
57
+ }
58
+ logger.info(`Found ${sections.length} sections in ${path}, creating semantic chunks`);
59
+ // Create chunks based on sections
60
+ for (let i = 0; i < sections.length; i++) {
61
+ const section = sections[i];
62
+ const nextSection = sections[i + 1];
63
+ const start = section.position;
64
+ const end = nextSection ? nextSection.position : content.length;
65
+ const chunkContent = content.slice(start, end);
66
+ // If chunk is still too large, split it further
67
+ if (chunkContent.length > config.maxChunkSize * 1.5) {
68
+ const subChunks = chunkBySize(`${path}#${sanitizeMarker(section.marker)}`, `${title} - ${section.marker}`, chunkContent, config);
69
+ chunks.push(...subChunks);
70
+ }
71
+ else {
72
+ chunks.push({
73
+ path: `${path}#${sanitizeMarker(section.marker)}`,
74
+ title: `${title} - ${section.marker}`,
75
+ content: chunkContent,
76
+ chunkIndex: chunks.length + 1,
77
+ totalChunks: 0, // Will be set later
78
+ });
79
+ }
80
+ }
81
+ // Update total chunks count
82
+ const totalChunks = chunks.length;
83
+ chunks.forEach((chunk) => {
84
+ chunk.totalChunks = totalChunks;
85
+ });
86
+ return chunks;
87
+ }
88
+ /**
89
+ * Splits content by size when no logical sections are found
90
+ */
91
+ function chunkBySize(path, title, content, config) {
92
+ const chunks = [];
93
+ let position = 0;
94
+ let chunkIndex = 1;
95
+ while (position < content.length) {
96
+ const end = Math.min(position + config.maxChunkSize, content.length);
97
+ let chunkEnd = end;
98
+ // Try to break at a paragraph boundary
99
+ if (end < content.length) {
100
+ const nextNewlines = content.indexOf('\n\n', end - 100);
101
+ if (nextNewlines !== -1 && nextNewlines < end + 100) {
102
+ chunkEnd = nextNewlines;
103
+ }
104
+ }
105
+ const chunkContent = content.slice(Math.max(0, position - config.overlapSize), chunkEnd);
106
+ chunks.push({
107
+ path: `${path}#chunk-${chunkIndex}`,
108
+ title: `${title} (Part ${chunkIndex})`,
109
+ content: chunkContent,
110
+ chunkIndex,
111
+ totalChunks: 0, // Will be set later
112
+ });
113
+ position = chunkEnd;
114
+ chunkIndex++;
115
+ }
116
+ // Update total chunks count
117
+ const totalChunks = chunks.length;
118
+ chunks.forEach((chunk) => {
119
+ chunk.totalChunks = totalChunks;
120
+ });
121
+ return chunks;
122
+ }
123
+ /**
124
+ * Sanitizes a section marker for use in a path fragment
125
+ */
126
+ function sanitizeMarker(marker) {
127
+ return marker
128
+ .toLowerCase()
129
+ .replace(/\s+/g, '-')
130
+ .replace(/[^a-z0-9-]/g, '');
131
+ }
132
+ /**
133
+ * Creates a summary chunk with links to all other chunks
134
+ */
135
+ export function createSummaryChunk(originalPath, originalTitle, chunks) {
136
+ const summaryLines = [
137
+ `# ${originalTitle}`,
138
+ '',
139
+ '> **Note:** This document has been split into multiple sections for better performance.',
140
+ '',
141
+ '## Available Sections',
142
+ '',
143
+ ];
144
+ for (const chunk of chunks) {
145
+ summaryLines.push(`- [${chunk.title}](${chunk.path})`);
146
+ }
147
+ summaryLines.push('');
148
+ summaryLines.push('## About This Reference');
149
+ summaryLines.push('');
150
+ summaryLines.push('This is the auto-generated GraphQL API reference for GitLab. Each section contains detailed information about:');
151
+ summaryLines.push('');
152
+ summaryLines.push('- **Query types**: Top-level entry points for read operations');
153
+ summaryLines.push('- **Mutation types**: Entry points for write operations');
154
+ summaryLines.push('- **Object types**: Resource representations in the API');
155
+ summaryLines.push('- **Enumeration types**: Predefined value sets');
156
+ summaryLines.push('- **Scalar types**: Basic data types');
157
+ summaryLines.push('- **Abstract types**: Unions and interfaces');
158
+ summaryLines.push('- **Input types**: Arguments for mutations and queries');
159
+ summaryLines.push('');
160
+ summaryLines.push('Use the interactive GraphQL explorer to test queries, or generate a machine-readable schema in IDL or JSON formats.');
161
+ return summaryLines.join('\n');
162
+ }
163
+ //# sourceMappingURL=chunker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunker.js","sourceRoot":"","sources":["../../src/content/chunker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AA8C5C;;;;GAIG;AACH,MAAM,oBAAoB,GAAgB;IACxC,YAAY,EAAE,MAAM,EAAE,kBAAkB;IACxC,cAAc,EAAE;QACd,YAAY;QACZ,eAAe;QACf,cAAc;QACd,mBAAmB;QACnB,cAAc;QACd,gBAAgB;QAChB,aAAa;KACd;IACD,WAAW,EAAE,IAAI,EAAE,kCAAkC;CACtD,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,OAAe;IAC/D,gDAAgD;IAChD,IAAI,IAAI,KAAK,iCAAiC,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;QAC1E,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAY,EACZ,KAAa,EACb,OAAe,EACf,SAAsB,oB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,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=chunker.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunker.test.d.ts","sourceRoot":"","sources":["../../src/content/chunker.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,92 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { shouldChunkDocument, chunkDocument, createSummaryChunk } from './chunker.js';
3
+ describe('Document Chunker', () => {
4
+ describe('shouldChunkDocument', () => {
5
+ it('should return true for large GraphQL reference', () => {
6
+ const largePath = 'api/graphql/reference/_index.md';
7
+ const largeContent = 'x'.repeat(600000); // 600KB
8
+ expect(shouldChunkDocument(largePath, largeContent)).toBe(true);
9
+ });
10
+ it('should return false for small GraphQL reference', () => {
11
+ const path = 'api/graphql/reference/_index.md';
12
+ const smallContent = 'x'.repeat(100000); // 100KB
13
+ expect(shouldChunkDocument(path, smallContent)).toBe(false);
14
+ });
15
+ it('should return false for other large documents', () => {
16
+ const path = 'some/other/doc.md';
17
+ const largeContent = 'x'.repeat(600000);
18
+ expect(shouldChunkDocument(path, largeContent)).toBe(false);
19
+ });
20
+ });
21
+ describe('chunkDocument', () => {
22
+ it('should split document by section markers', () => {
23
+ const content = `Query type
24
+ Some query content here.
25
+ This is about queries.
26
+
27
+ Mutation type
28
+ Some mutation content here.
29
+ This is about mutations.
30
+
31
+ Object types
32
+ Object types represent resources.
33
+ More object type info.`;
34
+ const chunks = chunkDocument('api/graphql/reference/_index.md', 'GraphQL Reference', content);
35
+ expect(chunks.length).toBe(3);
36
+ expect(chunks[0].title).toBe('GraphQL Reference - Query type');
37
+ expect(chunks[0].path).toBe('api/graphql/reference/_index.md#query-type');
38
+ expect(chunks[1].title).toBe('GraphQL Reference - Mutation type');
39
+ expect(chunks[2].title).toBe('GraphQL Reference - Object types');
40
+ // Check that each chunk has correct metadata
41
+ chunks.forEach((chunk) => {
42
+ expect(chunk.totalChunks).toBe(3);
43
+ });
44
+ });
45
+ it('should handle content without section markers', () => {
46
+ const content = 'x'.repeat(600000);
47
+ const chunks = chunkDocument('some/doc.md', 'Some Document', content);
48
+ expect(chunks.length).toBeGreaterThan(1);
49
+ expect(chunks[0].title).toContain('(Part 1)');
50
+ expect(chunks[1].title).toContain('(Part 2)');
51
+ });
52
+ it('should include chunk metadata', () => {
53
+ const content = `Query type
54
+ Content here.
55
+
56
+ Mutation type
57
+ More content.`;
58
+ const chunks = chunkDocument('api/graphql/reference/_index.md', 'GraphQL Reference', content);
59
+ expect(chunks[0].chunkIndex).toBe(1);
60
+ expect(chunks[1].chunkIndex).toBe(2);
61
+ expect(chunks[0].totalChunks).toBe(2);
62
+ expect(chunks[1].totalChunks).toBe(2);
63
+ });
64
+ });
65
+ describe('createSummaryChunk', () => {
66
+ it('should create a summary with links to all chunks', () => {
67
+ const chunks = [
68
+ {
69
+ path: 'api/graphql/reference/_index.md#query-type',
70
+ title: 'GraphQL Reference - Query type',
71
+ content: 'content',
72
+ chunkIndex: 1,
73
+ totalChunks: 2,
74
+ },
75
+ {
76
+ path: 'api/graphql/reference/_index.md#mutation-type',
77
+ title: 'GraphQL Reference - Mutation type',
78
+ content: 'content',
79
+ chunkIndex: 2,
80
+ totalChunks: 2,
81
+ },
82
+ ];
83
+ const summary = createSummaryChunk('api/graphql/reference/_index.md', 'GraphQL Reference', chunks);
84
+ expect(summary).toContain('# GraphQL Reference');
85
+ expect(summary).toContain('split into multiple sections');
86
+ expect(summary).toContain('[GraphQL Reference - Query type](api/graphql/reference/_index.md#query-type)');
87
+ expect(summary).toContain('[GraphQL Reference - Mutation type](api/graphql/reference/_index.md#mutation-type)');
88
+ expect(summary).toContain('About This Reference');
89
+ });
90
+ });
91
+ });
92
+ //# sourceMappingURL=chunker.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunker.test.js","sourceRoot":"","sources":["../../src/content/chunker.test.ts"],"names":[],"mappings":"AAAA,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8BAA8B,CAAC,CAAC;YAC1D,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,8EAA8E,CAAC,CAAC;YAC1G,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,oFAAoF,CAAC,CAAC;YAChH,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './parser.js';
2
2
  export * from './cache.js';
3
+ export * from './chunker.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/content/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/content/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './parser.js';
2
2
  export * from './cache.js';
3
+ export * from './chunker.js';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/content/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/content/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitlab-docs-mcp",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "mcpName": "io.github.ozanmutlu/gitlab-docs",
5
5
  "author": "Ozan Mutlu",
6
6
  "license": "MIT",
@@ -15,7 +15,7 @@
15
15
  "gitlab-docs-mcp": "./dist/bin.js"
16
16
  },
17
17
  "engines": {
18
- "node": ">=18.0.0"
18
+ "node": ">=22.0.0"
19
19
  },
20
20
  "scripts": {
21
21
  "build": "tsc",