@structured-world/gitlab-mcp 6.6.0 → 6.7.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.
package/README.md CHANGED
@@ -54,6 +54,7 @@ env = { "GITLAB_TOKEN" = "mytoken", "GITLAB_API_URL" = "https://gitlab.com" }
54
54
  "USE_PIPELINE": "false", // use pipeline api?
55
55
  "USE_VARIABLES": "true", // use variables api?
56
56
  "USE_WEBHOOKS": "true", // use webhooks api?
57
+ "USE_SNIPPETS": "true", // use snippets api?
57
58
  "SKIP_TLS_VERIFY": "false" // skip SSL cert verification (dev only)
58
59
  }
59
60
  }
@@ -123,6 +124,8 @@ env = { "GITLAB_TOKEN" = "mytoken", "GITLAB_API_URL" = "https://gitlab.com" }
123
124
  "USE_VARIABLES",
124
125
  "-e",
125
126
  "USE_WEBHOOKS",
127
+ "-e",
128
+ "USE_SNIPPETS",
126
129
  "ghcr.io/structured-world/gitlab-mcp:latest"
127
130
  ],
128
131
  "env": {
@@ -133,7 +136,8 @@ env = { "GITLAB_TOKEN" = "mytoken", "GITLAB_API_URL" = "https://gitlab.com" }
133
136
  "USE_MILESTONE": "true",
134
137
  "USE_PIPELINE": "true",
135
138
  "USE_VARIABLES": "true",
136
- "USE_WEBHOOKS": "true"
139
+ "USE_WEBHOOKS": "true",
140
+ "USE_SNIPPETS": "true"
137
141
  }
138
142
  }
139
143
  }
@@ -470,6 +474,7 @@ When OAuth is enabled, the following endpoints are available:
470
474
  - `USE_VARIABLES`: When set to 'true', enables the CI/CD variables-related tools (browse_variables, manage_variable). These 2 CQRS tools consolidate all variable operations. Supports both project-level and group-level variables. By default, variables features are enabled.
471
475
  - `USE_WORKITEMS`: When set to 'true', enables the work items-related tools (browse_work_items, manage_work_item). These 2 CQRS tools consolidate all work item operations using GitLab GraphQL API. By default, work items features are enabled.
472
476
  - `USE_WEBHOOKS`: When set to 'true', enables the webhooks-related tools (list_webhooks, manage_webhook). These 2 tools provide full CRUD operations plus testing for both project and group webhooks. Group webhooks require GitLab Premium tier. By default, webhooks features are enabled.
477
+ - `USE_SNIPPETS`: When set to 'true', enables the snippets-related tools (list_snippets, manage_snippet). These 2 CQRS tools provide full listing and CRUD operations for both personal and project snippets. Supports multi-file snippets, visibility control, and flexible scoping. By default, snippets features are enabled.
473
478
  - `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.
474
479
  - `SKIP_TLS_VERIFY`: When set to 'true', skips TLS certificate verification for all GitLab API requests (both REST and GraphQL). **WARNING**: This bypasses SSL certificate validation and should only be used for testing with self-signed certificates or trusted internal GitLab instances. Never use this in production environments.
475
480
  - `SSL_CERT_PATH`: Path to PEM certificate file for direct HTTPS/TLS termination. Requires `SSL_KEY_PATH` to also be set.
@@ -538,11 +543,11 @@ export GITLAB_TOOL_MANAGE_WORK_ITEM="Create and manage tickets for our sprint pl
538
543
  - **Case Sensitivity**: Tool names in environment variables must be UPPERCASE (e.g., `LIST_PROJECTS` not `list_projects`)
539
544
  - **Invalid Names**: Invalid tool names in environment variables are ignored with a warning in debug logs
540
545
  - **Content Guidelines**: Descriptions can be any valid string but should be kept concise for better UX
541
- - **Scope**: Works with all 58 available tools across all entities (Core, Work Items, Merge Requests, Files, etc.)
546
+ - **Scope**: Works with all 59 available tools across all entities (Core, Work Items, Merge Requests, Files, Snippets, etc.)
542
547
 
543
548
  ## Tools 🛠️
544
549
 
545
- **57 Tools Available** - Organized by entity and functionality below.
550
+ **59 Tools Available** - Organized by entity and functionality below.
546
551
 
547
552
  ### Key Features:
548
553
  - **CQRS Pattern** - Consolidated action-based tools: `browse_*` for reads, `manage_*` for writes
@@ -696,6 +701,20 @@ Webhooks can be configured to trigger on:
696
701
  - **Subgroup events** - Subgroup created/removed (group webhooks only)
697
702
  - **Project events** - Project created/removed (group webhooks only)
698
703
 
704
+ ### Snippets Management (2 tools)
705
+ Requires USE_SNIPPETS=true environment variable (enabled by default). Uses CQRS pattern with action-based tools. Supports personal, project, and public snippets with multi-file support.
706
+
707
+ #### Snippet Browsing (Query)
708
+ - 📖 **`list_snippets`**: LIST GitLab code snippets with flexible scoping. Use scope='personal' for current user's snippets, scope='project' for project-specific snippets (requires projectId), or scope='public' to discover all public snippets. Filter by visibility level (private/internal/public) and creation date. Supports pagination.
709
+
710
+ #### Snippet Management (Command)
711
+ - ✏️ **`manage_snippet`**: MANAGE GitLab snippets with full CRUD operations via action parameter. Actions: "read" retrieves snippet metadata or raw content, "create" creates new snippet with multiple files and visibility control, "update" modifies title/description/visibility/files (supports file create/update/delete/move actions), "delete" permanently removes snippet. Supports both personal and project snippets.
712
+
713
+ #### Multi-file Snippet Support
714
+ Snippets can contain multiple files with individual operations:
715
+ - **Create action** - Files array with `file_path` and `content` for each file
716
+ - **Update action** - Files array with `action` field: "create" (add new), "update" (modify existing), "delete" (remove), "move" (rename with `previous_path`)
717
+
699
718
  ## CLI Tools 🔧
700
719
 
701
720
  ### list-tools - Browse Available Tools
@@ -11,6 +11,7 @@ export declare const USE_LABELS: boolean;
11
11
  export declare const USE_MRS: boolean;
12
12
  export declare const USE_FILES: boolean;
13
13
  export declare const USE_VARIABLES: boolean;
14
+ export declare const USE_SNIPPETS: boolean;
14
15
  export declare const USE_WEBHOOKS: boolean;
15
16
  export declare const HOST: string;
16
17
  export declare const PORT: string | number;
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.packageVersion = exports.packageName = exports.GITLAB_ALLOWED_PROJECT_IDS = exports.GITLAB_PROJECT_ID = exports.GITLAB_API_URL = exports.GITLAB_BASE_URL = exports.GITLAB_CA_CERT_PATH = exports.NODE_TLS_REJECT_UNAUTHORIZED = exports.HTTPS_PROXY = exports.HTTP_PROXY = exports.SKIP_TLS_VERIFY = exports.RATE_LIMIT_SESSION_MAX_REQUESTS = exports.RATE_LIMIT_SESSION_WINDOW_MS = exports.RATE_LIMIT_SESSION_ENABLED = exports.RATE_LIMIT_IP_MAX_REQUESTS = exports.RATE_LIMIT_IP_WINDOW_MS = exports.RATE_LIMIT_IP_ENABLED = exports.API_TIMEOUT_MS = exports.TRUST_PROXY = exports.SSL_PASSPHRASE = exports.SSL_CA_PATH = exports.SSL_KEY_PATH = exports.SSL_CERT_PATH = exports.PORT = exports.HOST = exports.USE_WEBHOOKS = exports.USE_VARIABLES = exports.USE_FILES = exports.USE_MRS = exports.USE_LABELS = exports.USE_WORKITEMS = exports.USE_PIPELINE = exports.USE_MILESTONE = exports.USE_GITLAB_WIKI = exports.GITLAB_DENIED_TOOLS_REGEX = exports.GITLAB_READ_ONLY_MODE = exports.IS_OLD = exports.GITLAB_AUTH_COOKIE_PATH = exports.GITLAB_TOKEN = void 0;
36
+ exports.packageVersion = exports.packageName = exports.GITLAB_ALLOWED_PROJECT_IDS = exports.GITLAB_PROJECT_ID = exports.GITLAB_API_URL = exports.GITLAB_BASE_URL = exports.GITLAB_CA_CERT_PATH = exports.NODE_TLS_REJECT_UNAUTHORIZED = exports.HTTPS_PROXY = exports.HTTP_PROXY = exports.SKIP_TLS_VERIFY = exports.RATE_LIMIT_SESSION_MAX_REQUESTS = exports.RATE_LIMIT_SESSION_WINDOW_MS = exports.RATE_LIMIT_SESSION_ENABLED = exports.RATE_LIMIT_IP_MAX_REQUESTS = exports.RATE_LIMIT_IP_WINDOW_MS = exports.RATE_LIMIT_IP_ENABLED = exports.API_TIMEOUT_MS = exports.TRUST_PROXY = exports.SSL_PASSPHRASE = exports.SSL_CA_PATH = exports.SSL_KEY_PATH = exports.SSL_CERT_PATH = exports.PORT = exports.HOST = exports.USE_WEBHOOKS = exports.USE_SNIPPETS = exports.USE_VARIABLES = exports.USE_FILES = exports.USE_MRS = exports.USE_LABELS = exports.USE_WORKITEMS = exports.USE_PIPELINE = exports.USE_MILESTONE = exports.USE_GITLAB_WIKI = exports.GITLAB_DENIED_TOOLS_REGEX = exports.GITLAB_READ_ONLY_MODE = exports.IS_OLD = exports.GITLAB_AUTH_COOKIE_PATH = exports.GITLAB_TOKEN = void 0;
37
37
  exports.getEffectiveProjectId = getEffectiveProjectId;
38
38
  exports.getToolDescriptionOverrides = getToolDescriptionOverrides;
39
39
  const path = __importStar(require("path"));
@@ -54,6 +54,7 @@ exports.USE_LABELS = process.env.USE_LABELS !== "false";
54
54
  exports.USE_MRS = process.env.USE_MRS !== "false";
55
55
  exports.USE_FILES = process.env.USE_FILES !== "false";
56
56
  exports.USE_VARIABLES = process.env.USE_VARIABLES !== "false";
57
+ exports.USE_SNIPPETS = process.env.USE_SNIPPETS !== "false";
57
58
  exports.USE_WEBHOOKS = process.env.USE_WEBHOOKS !== "false";
58
59
  exports.HOST = process.env.HOST ?? "0.0.0.0";
59
60
  exports.PORT = process.env.PORT ?? 3002;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,sDAcC;AAwBD,kEAgBC;AArJD,2CAA6B;AAC7B,uCAAyB;AAEzB,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;AAGvD,QAAA,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AACxC,QAAA,uBAAuB,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;AAC9D,QAAA,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,MAAM,CAAC;AAC9C,QAAA,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,MAAM,CAAC;AACrE,QAAA,yBAAyB,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB;IAC5E,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC;IACnD,CAAC,C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AAC;IACF,sBAAA,WAAW,GAAG,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC;IAC9C,yBAAA,cAAc,GAAG,WAAW,CAAC,OAAO,IAAI,cAAc,CAAC;AACzD,CAAC;AAAC,MAAM,CAAC;AAET,CAAC;AASD,SAAgB,2BAA2B;IACzC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,MAAM,MAAM,GAAG,cAAc,CAAC;IAG9B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvD,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YAGpC,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;YAE5D,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from "../shared";
2
+ export * from "./schema-readonly";
3
+ export * from "./schema";
4
+ export * from "./registry";
5
+ import type { ToolDefinition } from "../../types";
6
+ export declare const snippetsTools: ToolDefinition[];
7
+ export declare const snippetsReadOnlyTools: string[];
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.snippetsReadOnlyTools = exports.snippetsTools = void 0;
18
+ __exportStar(require("../shared"), exports);
19
+ __exportStar(require("./schema-readonly"), exports);
20
+ __exportStar(require("./schema"), exports);
21
+ __exportStar(require("./registry"), exports);
22
+ const registry_1 = require("./registry");
23
+ const isReadOnly = process.env.GITLAB_READONLY === "true";
24
+ const snippetsToolsFromRegistry = (0, registry_1.getFilteredSnippetsTools)(isReadOnly);
25
+ exports.snippetsTools = snippetsToolsFromRegistry.map((tool) => ({
26
+ name: tool.name,
27
+ description: tool.description,
28
+ inputSchema: tool.inputSchema,
29
+ }));
30
+ exports.snippetsReadOnlyTools = (0, registry_1.getSnippetsReadOnlyToolNames)();
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/entities/snippets/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,4CAA0B;AAG1B,oDAAkC;AAGlC,2CAAyB;AAGzB,6CAA2B;AAG3B,yCAAoF;AAIpF,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,MAAM,CAAC;AAG1D,MAAM,yBAAyB,GAAG,IAAA,mCAAwB,EAAC,UAAU,CAAC,CAAC;AAG1D,QAAA,aAAa,GAAqB,yBAAyB,CAAC,GAAG,CAC1E,CAAC,IAAI,EAAkB,EAAE,CAAC,CAAC;IACzB,IAAI,EAAE,IAAI,CAAC,IAAI;IACf,WAAW,EAAE,IAAI,CAAC,WAAW;IAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;CAC9B,CAAC,CACH,CAAC;AAGW,QAAA,qBAAqB,GAAG,IAAA,uCAA4B,GAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { ToolRegistry, EnhancedToolDefinition } from "../../types";
2
+ export declare const snippetsToolRegistry: ToolRegistry;
3
+ export declare function getSnippetsReadOnlyToolNames(): string[];
4
+ export declare function getSnippetsToolDefinitions(): EnhancedToolDefinition[];
5
+ export declare function getFilteredSnippetsTools(readOnlyMode?: boolean): EnhancedToolDefinition[];
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.snippetsToolRegistry = void 0;
37
+ exports.getSnippetsReadOnlyToolNames = getSnippetsReadOnlyToolNames;
38
+ exports.getSnippetsToolDefinitions = getSnippetsToolDefinitions;
39
+ exports.getFilteredSnippetsTools = getFilteredSnippetsTools;
40
+ const z = __importStar(require("zod"));
41
+ const schema_readonly_1 = require("./schema-readonly");
42
+ const schema_1 = require("./schema");
43
+ const gitlab_api_1 = require("../../utils/gitlab-api");
44
+ const ManageSnippetSchema = z.discriminatedUnion("action", [
45
+ schema_readonly_1.GetSnippetSchema,
46
+ schema_1.CreateSnippetSchema,
47
+ schema_1.UpdateSnippetSchema,
48
+ schema_1.DeleteSnippetSchema,
49
+ ]);
50
+ exports.snippetsToolRegistry = new Map([
51
+ [
52
+ "list_snippets",
53
+ {
54
+ name: "list_snippets",
55
+ description: "List GitLab code snippets with flexible scoping. Use scope='personal' for current user's snippets, scope='project' for project-specific snippets (requires projectId), or scope='public' to discover all public snippets. Filter by visibility level (private/internal/public) and creation date. Snippets are reusable code blocks, configs, or text that support versioning and can be shared.",
56
+ inputSchema: z.toJSONSchema(schema_readonly_1.ListSnippetsSchema),
57
+ handler: async (args) => {
58
+ const options = schema_readonly_1.ListSnippetsSchema.parse(args);
59
+ let path;
60
+ if (options.scope === "personal") {
61
+ path = "snippets";
62
+ }
63
+ else if (options.scope === "public") {
64
+ path = "snippets/public";
65
+ }
66
+ else {
67
+ if (!options.projectId) {
68
+ throw new Error("projectId is required for project scope");
69
+ }
70
+ const encodedProjectId = encodeURIComponent(options.projectId);
71
+ path = `projects/${encodedProjectId}/snippets`;
72
+ }
73
+ return gitlab_api_1.gitlab.get(path, {
74
+ query: (0, gitlab_api_1.toQuery)(options, ["scope", "projectId"]),
75
+ });
76
+ },
77
+ },
78
+ ],
79
+ [
80
+ "manage_snippet",
81
+ {
82
+ name: "manage_snippet",
83
+ description: "Manage GitLab snippets with full CRUD operations via action parameter. action='read': retrieve snippet metadata or raw content. action='create': create new snippet with multiple files, visibility control. action='update': modify title, description, visibility, or files (supports create/update/delete/move file actions). action='delete': permanently remove snippet. Supports both personal and project snippets. Multi-file snippets enable organizing related code in one place.",
84
+ inputSchema: z.toJSONSchema(ManageSnippetSchema),
85
+ handler: async (args) => {
86
+ const options = ManageSnippetSchema.parse(args);
87
+ switch (options.action) {
88
+ case "read": {
89
+ const encodedId = options.id.toString();
90
+ let path;
91
+ if (options.projectId) {
92
+ const encodedProjectId = encodeURIComponent(options.projectId);
93
+ path = `projects/${encodedProjectId}/snippets/${encodedId}`;
94
+ }
95
+ else {
96
+ path = `snippets/${encodedId}`;
97
+ }
98
+ if (options.raw) {
99
+ path = `${path}/raw`;
100
+ }
101
+ return gitlab_api_1.gitlab.get(path);
102
+ }
103
+ case "create": {
104
+ const body = {
105
+ title: options.title,
106
+ visibility: options.visibility,
107
+ files: options.files,
108
+ };
109
+ if (options.description) {
110
+ body.description = options.description;
111
+ }
112
+ let path;
113
+ if (options.projectId) {
114
+ const encodedProjectId = encodeURIComponent(options.projectId);
115
+ path = `projects/${encodedProjectId}/snippets`;
116
+ }
117
+ else {
118
+ path = "snippets";
119
+ }
120
+ return gitlab_api_1.gitlab.post(path, {
121
+ body,
122
+ contentType: "json",
123
+ });
124
+ }
125
+ case "update": {
126
+ const encodedId = options.id.toString();
127
+ const body = {};
128
+ if (options.title !== undefined) {
129
+ body.title = options.title;
130
+ }
131
+ if (options.description !== undefined) {
132
+ body.description = options.description;
133
+ }
134
+ if (options.visibility !== undefined) {
135
+ body.visibility = options.visibility;
136
+ }
137
+ if (options.files !== undefined) {
138
+ body.files = options.files;
139
+ }
140
+ let path;
141
+ if (options.projectId) {
142
+ const encodedProjectId = encodeURIComponent(options.projectId);
143
+ path = `projects/${encodedProjectId}/snippets/${encodedId}`;
144
+ }
145
+ else {
146
+ path = `snippets/${encodedId}`;
147
+ }
148
+ return gitlab_api_1.gitlab.put(path, {
149
+ body,
150
+ contentType: "json",
151
+ });
152
+ }
153
+ case "delete": {
154
+ const encodedId = options.id.toString();
155
+ let path;
156
+ if (options.projectId) {
157
+ const encodedProjectId = encodeURIComponent(options.projectId);
158
+ path = `projects/${encodedProjectId}/snippets/${encodedId}`;
159
+ }
160
+ else {
161
+ path = `snippets/${encodedId}`;
162
+ }
163
+ await gitlab_api_1.gitlab.delete(path);
164
+ return { deleted: true, id: options.id };
165
+ }
166
+ default:
167
+ throw new Error(`Unknown action: ${options.action}`);
168
+ }
169
+ },
170
+ },
171
+ ],
172
+ ]);
173
+ function getSnippetsReadOnlyToolNames() {
174
+ return ["list_snippets"];
175
+ }
176
+ function getSnippetsToolDefinitions() {
177
+ return Array.from(exports.snippetsToolRegistry.values());
178
+ }
179
+ function getFilteredSnippetsTools(readOnlyMode = false) {
180
+ if (readOnlyMode) {
181
+ const readOnlyNames = getSnippetsReadOnlyToolNames();
182
+ return Array.from(exports.snippetsToolRegistry.values()).filter(tool => readOnlyNames.includes(tool.name));
183
+ }
184
+ return getSnippetsToolDefinitions();
185
+ }
186
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../src/entities/snippets/registry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmKA,oEAEC;AAED,gEAEC;AAED,4DAQC;AAnLD,uCAAyB;AACzB,uDAAyE;AACzE,qCAAyF;AACzF,uDAAyD;AAMzD,MAAM,mBAAmB,GAAG,CAAC,CAAC,kBAAkB,CAAC,QAAQ,EAAE;IACzD,kCAAgB;IAChB,4BAAmB;IACnB,4BAAmB;IACnB,4BAAmB;CACpB,CAAC,CAAC;AAKU,QAAA,oBAAoB,GAAiB,IAAI,GAAG,CAAiC;IACxF;QACE,eAAe;QACf;YACE,IAAI,EAAE,eAAe;YACrB,WAAW,EACT,kYAAkY;YACpY,WAAW,EAAE,CAAC,CAAC,YAAY,CAAC,oCAAkB,CAAC;YAC/C,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;gBAC/B,MAAM,OAAO,GAAG,oCAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAG/C,IAAI,IAAY,CAAC;gBACjB,IAAI,OAAO,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;oBACjC,IAAI,GAAG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E,MAAM,IAAI,KAAK,CAAC,mBAAoB,OAA8B,CAAC,MAAM,EAAE,CAAC,CAAC;gBACjF,CAAC;YACH,CAAC;SACF;KACF;CACF,CAAC,CAAC;AAEH,SAAgB,4BAA4B;IAC1C,OAAO,CAAC,eAAe,CAAC,CAAC;AAC3B,CAAC;AAED,SAAgB,0BAA0B;IACxC,OAAO,KAAK,CAAC,IAAI,CAAC,4BAAoB,CAAC,MAAM,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,SAAgB,wBAAwB,CAAC,eAAwB,KAAK;IACpE,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,aAAa,GAAG,4BAA4B,EAAE,CAAC;QACrD,OAAO,KAAK,CAAC,IAAI,CAAC,4BAAoB,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAC7D,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAClC,CAAC;IACJ,CAAC;IACD,OAAO,0BAA0B,EAAE,CAAC;AACtC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ export declare const ListSnippetsSchema: z.ZodObject<{
3
+ scope: z.ZodEnum<{
4
+ project: "project";
5
+ public: "public";
6
+ personal: "personal";
7
+ }>;
8
+ projectId: z.ZodOptional<z.ZodString>;
9
+ visibility: z.ZodOptional<z.ZodEnum<{
10
+ private: "private";
11
+ internal: "internal";
12
+ public: "public";
13
+ }>>;
14
+ created_after: z.ZodOptional<z.ZodString>;
15
+ created_before: z.ZodOptional<z.ZodString>;
16
+ page: z.ZodOptional<z.ZodNumber>;
17
+ per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
18
+ }, z.core.$strip>;
19
+ export declare const GetSnippetSchema: z.ZodObject<{
20
+ action: z.ZodLiteral<"read">;
21
+ id: z.ZodNumber;
22
+ projectId: z.ZodOptional<z.ZodString>;
23
+ raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
24
+ }, z.core.$strip>;
25
+ export type ListSnippetsOptions = z.infer<typeof ListSnippetsSchema>;
26
+ export type GetSnippetOptions = z.infer<typeof GetSnippetSchema>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetSnippetSchema = exports.ListSnippetsSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const shared_1 = require("../shared");
6
+ const SnippetScopeSchema = zod_1.z.enum(["personal", "project", "public"]);
7
+ exports.ListSnippetsSchema = zod_1.z
8
+ .object({
9
+ scope: SnippetScopeSchema.describe('The scope of snippets to list: "personal" for current user snippets, "project" for project-specific snippets, "public" for all public snippets'),
10
+ projectId: zod_1.z
11
+ .string()
12
+ .optional()
13
+ .describe("Project ID or URL-encoded path (required when scope is 'project'). Example: '123' or 'group/project'"),
14
+ visibility: zod_1.z
15
+ .enum(["private", "internal", "public"])
16
+ .optional()
17
+ .describe("Filter snippets by visibility level. Private: only author can see. Internal: authenticated users can see. Public: anyone can see"),
18
+ created_after: zod_1.z
19
+ .string()
20
+ .optional()
21
+ .describe("Return snippets created after this date (ISO 8601 format). Example: '2024-01-01T00:00:00Z'"),
22
+ created_before: zod_1.z
23
+ .string()
24
+ .optional()
25
+ .describe("Return snippets created before this date (ISO 8601 format). Example: '2024-12-31T23:59:59Z'"),
26
+ })
27
+ .merge(shared_1.PaginationOptionsSchema)
28
+ .refine(data => data.scope !== "project" || data.projectId, {
29
+ message: "projectId is required when scope is 'project'",
30
+ path: ["projectId"],
31
+ });
32
+ const GetSnippetActionSchema = zod_1.z.literal("read");
33
+ exports.GetSnippetSchema = zod_1.z
34
+ .object({
35
+ action: GetSnippetActionSchema.describe("Must be 'read' for retrieving snippet details"),
36
+ id: zod_1.z.number().int().positive().describe("The ID of the snippet to retrieve"),
37
+ projectId: zod_1.z
38
+ .string()
39
+ .optional()
40
+ .describe("Project ID or URL-encoded path (required for project snippets). Leave empty for personal snippets"),
41
+ raw: zod_1.z
42
+ .boolean()
43
+ .optional()
44
+ .default(false)
45
+ .describe("Return raw content of the snippet files instead of metadata. Useful for downloading snippet content directly"),
46
+ })
47
+ .refine(data => !data.projectId || typeof data.projectId === "string", {
48
+ message: "projectId must be a string when provided",
49
+ path: ["projectId"],
50
+ });
51
+ //# sourceMappingURL=schema-readonly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-readonly.js","sourceRoot":"","sources":["../../../../src/entities/snippets/schema-readonly.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,sCAAoD;AAKpD,MAAM,kBAAkB,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAGxD,QAAA,kBAAkB,GAAG,OAAC;KAChC,MAAM,CAAC;IACN,KAAK,EAAE,kBAAkB,CAAC,QAAQ,CAChC,gJAAgJ,CACjJ;IACD,SAAS,EAAE,OAAC;SACT,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,sGAAsG,CACvG;IACH,UAAU,EAAE,OAAC;SACV,IAAI,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;SACvC,QAAQ,EAAE;SACV,QAAQ,CACP,kIAAkI,CACnI;IACH,aAAa,EAAE,OAAC;SACb,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,4FAA4F,CAC7F;IACH,cAAc,EAAE,OAAC;SACd,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,6FAA6F,CAC9F;CACJ,CAAC;KACD,KAAK,CAAC,gCAAuB,CAAC;KAC9B,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,EAAE;IAC1D,OAAO,EAAE,+CAA+C;IACxD,IAAI,EAAE,CAAC,WAAW,CAAC;CACpB,CAAC,CAAC;AAGL,MAAM,sBAAsB,GAAG,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAGpC,QAAA,gBAAgB,GAAG,OAAC;KAC9B,MAAM,CAAC;IACN,MAAM,EAAE,sBAAsB,CAAC,QAAQ,CAAC,+CAA+C,CAAC;IACxF,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IAC7E,SAAS,EAAE,OAAC;SACT,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,mGAAmG,CACpG;IACH,GAAG,EAAE,OAAC;SACH,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,OAAO,CAAC,KAAK,CAAC;SACd,QAAQ,CACP,8GAA8G,CAC/G;CACJ,CAAC;KACD,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,EAAE;IACrE,OAAO,EAAE,0CAA0C;IACnD,IAAI,EAAE,CAAC,WAAW,CAAC;CACpB,CAAC,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { z } from "zod";
2
+ declare const SnippetFileSchema: z.ZodObject<{
3
+ file_path: z.ZodString;
4
+ content: z.ZodOptional<z.ZodString>;
5
+ action: z.ZodOptional<z.ZodEnum<{
6
+ create: "create";
7
+ update: "update";
8
+ delete: "delete";
9
+ move: "move";
10
+ }>>;
11
+ previous_path: z.ZodOptional<z.ZodString>;
12
+ }, z.core.$strip>;
13
+ export declare const CreateSnippetSchema: z.ZodObject<{
14
+ action: z.ZodLiteral<"create">;
15
+ projectId: z.ZodOptional<z.ZodString>;
16
+ title: z.ZodString;
17
+ description: z.ZodOptional<z.ZodString>;
18
+ visibility: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodEnum<{
19
+ private: "private";
20
+ internal: "internal";
21
+ public: "public";
22
+ }>>>>;
23
+ files: z.ZodArray<z.ZodObject<{
24
+ file_path: z.ZodString;
25
+ content: z.ZodString;
26
+ }, z.core.$strip>>;
27
+ }, z.core.$strip>;
28
+ export declare const UpdateSnippetSchema: z.ZodObject<{
29
+ action: z.ZodLiteral<"update">;
30
+ id: z.ZodNumber;
31
+ projectId: z.ZodOptional<z.ZodString>;
32
+ title: z.ZodOptional<z.ZodString>;
33
+ description: z.ZodOptional<z.ZodString>;
34
+ visibility: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodEnum<{
35
+ private: "private";
36
+ internal: "internal";
37
+ public: "public";
38
+ }>>>;
39
+ files: z.ZodOptional<z.ZodArray<z.ZodObject<{
40
+ file_path: z.ZodString;
41
+ content: z.ZodOptional<z.ZodString>;
42
+ action: z.ZodOptional<z.ZodEnum<{
43
+ create: "create";
44
+ update: "update";
45
+ delete: "delete";
46
+ move: "move";
47
+ }>>;
48
+ previous_path: z.ZodOptional<z.ZodString>;
49
+ }, z.core.$strip>>>;
50
+ }, z.core.$strip>;
51
+ export declare const DeleteSnippetSchema: z.ZodObject<{
52
+ action: z.ZodLiteral<"delete">;
53
+ id: z.ZodNumber;
54
+ projectId: z.ZodOptional<z.ZodString>;
55
+ }, z.core.$strip>;
56
+ export type CreateSnippetOptions = z.infer<typeof CreateSnippetSchema>;
57
+ export type UpdateSnippetOptions = z.infer<typeof UpdateSnippetSchema>;
58
+ export type DeleteSnippetOptions = z.infer<typeof DeleteSnippetSchema>;
59
+ export type SnippetFile = z.infer<typeof SnippetFileSchema>;
60
+ export {};
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeleteSnippetSchema = exports.UpdateSnippetSchema = exports.CreateSnippetSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const flexibleVisibility = zod_1.z.preprocess(val => {
6
+ if (typeof val === "string") {
7
+ const normalized = val.toLowerCase().trim();
8
+ if (["private", "priv"].includes(normalized)) {
9
+ return "private";
10
+ }
11
+ if (["internal", "intern"].includes(normalized)) {
12
+ return "internal";
13
+ }
14
+ if (["public", "pub"].includes(normalized)) {
15
+ return "public";
16
+ }
17
+ }
18
+ return val;
19
+ }, zod_1.z.enum(["private", "internal", "public"]));
20
+ const SnippetFileSchema = zod_1.z.object({
21
+ file_path: zod_1.z
22
+ .string()
23
+ .min(1)
24
+ .describe("The path/name of the file within the snippet. Can include subdirectories (e.g., 'src/main.py'). Must be unique within the snippet"),
25
+ content: zod_1.z
26
+ .string()
27
+ .optional()
28
+ .describe("The content of the file. Required for 'create' and 'update' actions. Can be empty string for placeholder files. For binary content, use base64 encoding"),
29
+ action: zod_1.z
30
+ .enum(["create", "update", "delete", "move"])
31
+ .optional()
32
+ .describe("Action to perform on the file (only for update operations): 'create' adds a new file, 'update' modifies existing file, 'delete' removes file, 'move' renames file (requires previous_path)"),
33
+ previous_path: zod_1.z
34
+ .string()
35
+ .optional()
36
+ .describe("Original file path when using 'move' action to rename a file. Must match an existing file in the snippet"),
37
+ });
38
+ const CreateSnippetActionSchema = zod_1.z.literal("create");
39
+ exports.CreateSnippetSchema = zod_1.z
40
+ .object({
41
+ action: CreateSnippetActionSchema.describe("Must be 'create' for creating a new snippet"),
42
+ projectId: zod_1.z
43
+ .string()
44
+ .optional()
45
+ .describe("Project ID or URL-encoded path to create a project snippet. Leave empty for a personal snippet"),
46
+ title: zod_1.z
47
+ .string()
48
+ .min(1)
49
+ .max(255)
50
+ .describe("The title of the snippet. This is displayed in the snippet list and as the page title. Maximum 255 characters"),
51
+ description: zod_1.z
52
+ .string()
53
+ .optional()
54
+ .describe("Optional description explaining the purpose of the snippet. Supports markdown formatting"),
55
+ visibility: flexibleVisibility
56
+ .optional()
57
+ .default("private")
58
+ .describe("Visibility level: 'private' (only author), 'internal' (authenticated users), or 'public' (everyone). Defaults to 'private'"),
59
+ files: zod_1.z
60
+ .array(zod_1.z.object({
61
+ file_path: zod_1.z.string().min(1),
62
+ content: zod_1.z.string(),
63
+ }))
64
+ .min(1)
65
+ .describe("Array of files to include in the snippet. At least one file is required. Each file needs file_path and content"),
66
+ })
67
+ .refine(data => data.files.length > 0, {
68
+ message: "At least one file is required",
69
+ path: ["files"],
70
+ });
71
+ const UpdateSnippetActionSchema = zod_1.z.literal("update");
72
+ exports.UpdateSnippetSchema = zod_1.z
73
+ .object({
74
+ action: UpdateSnippetActionSchema.describe("Must be 'update' for updating an existing snippet"),
75
+ id: zod_1.z
76
+ .number()
77
+ .int()
78
+ .positive()
79
+ .describe("The ID of the snippet to update. Must be an existing snippet"),
80
+ projectId: zod_1.z
81
+ .string()
82
+ .optional()
83
+ .describe("Project ID or URL-encoded path (required for project snippets). Leave empty for personal snippets"),
84
+ title: zod_1.z
85
+ .string()
86
+ .min(1)
87
+ .max(255)
88
+ .optional()
89
+ .describe("Update the title of the snippet. Maximum 255 characters"),
90
+ description: zod_1.z
91
+ .string()
92
+ .optional()
93
+ .describe("Update the description of the snippet. Supports markdown formatting"),
94
+ visibility: flexibleVisibility
95
+ .optional()
96
+ .describe("Update the visibility level of the snippet"),
97
+ files: zod_1.z
98
+ .array(SnippetFileSchema)
99
+ .optional()
100
+ .describe("Array of file operations to perform. Each file must specify an 'action': 'create' (add new file), 'update' (modify existing), 'delete' (remove file), or 'move' (rename file with previous_path)"),
101
+ })
102
+ .refine(data => {
103
+ return (data.title !== undefined ||
104
+ data.description !== undefined ||
105
+ data.visibility !== undefined ||
106
+ (data.files !== undefined && data.files.length > 0));
107
+ }, {
108
+ message: "At least one field must be provided to update (title, description, visibility, or files)",
109
+ });
110
+ const DeleteSnippetActionSchema = zod_1.z.literal("delete");
111
+ exports.DeleteSnippetSchema = zod_1.z.object({
112
+ action: DeleteSnippetActionSchema.describe("Must be 'delete' for deleting a snippet"),
113
+ id: zod_1.z
114
+ .number()
115
+ .int()
116
+ .positive()
117
+ .describe("The ID of the snippet to delete. This operation is permanent and cannot be undone"),
118
+ projectId: zod_1.z
119
+ .string()
120
+ .optional()
121
+ .describe("Project ID or URL-encoded path (required for project snippets). Leave empty for personal snippets"),
122
+ });
123
+ //# sourceMappingURL=schema.js.map