Skip to main content
Glama

upload_group_wiki_attachment

Upload attachments to a GitLab group wiki by specifying the branch, content, file path, and group ID. Simplify file management and documentation updates.

Instructions

Upload an attachment to a GitLab group wiki

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branchNo
contentNo
file_pathNo
group_idNo

Implementation Reference

  • Core handler function that performs the actual upload to GitLab group wiki by making a POST request to the /wikis/attachments endpoint, handling content encoding to base64, and parsing the response.
    async uploadGroupWikiAttachment(
      groupId: string,
      options: {
        file_path: string;
        content: string;
        branch?: string;
      }
    ): Promise<GitLabWikiAttachment> {
      // Convert content to base64 if it's not already
      const content = options.content.startsWith("data:")
        ? options.content
        : `data:application/octet-stream;base64,${Buffer.from(options.content).toString('base64')}`;
    
      const response = await fetch(
        `${this.apiUrl}/groups/${encodeURIComponent(groupId)}/wikis/attachments`,
        {
          method: "POST",
          headers: {
            Authorization: `Bearer ${this.token}`,
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            file_name: options.file_path.split('/').pop(),
            file_path: options.file_path,
            content: content,
            branch: options.branch,
          }),
        }
      );
    
      if (!response.ok) {
        throw new McpError(
          ErrorCode.InternalError,
          `GitLab API error: ${response.statusText}`
        );
      }
    
      // Parse the response JSON
      const attachment = await response.json();
    
      // Validate and return the response
      return GitLabWikiAttachmentSchema.parse(attachment);
    }
  • MCP tool dispatcher that parses input arguments using the schema and delegates to the GitLabApi.uploadGroupWikiAttachment method.
    case "upload_group_wiki_attachment": {
      const args = UploadGroupWikiAttachmentSchema.parse(request.params.arguments);
      const attachment = await gitlabApi.uploadGroupWikiAttachment(args.group_id, {
        file_path: args.file_path,
        content: args.content,
        branch: args.branch
      });
      return formatWikiAttachmentResponse(attachment);
    }
  • Zod schema defining the input parameters for the upload_group_wiki_attachment tool: group_id, file_path, content, and optional branch.
    export const UploadGroupWikiAttachmentSchema = z.object({
      group_id: z.string(),
      file_path: z.string(),
      content: z.string(),
      branch: z.string().optional()
    });
  • src/index.ts:261-264 (registration)
    Tool registration object added to the ALL_TOOLS array, defining name, description, input schema, and readOnly flag for the MCP server.
    name: "upload_group_wiki_attachment",
    description: "Upload an attachment to a GitLab group wiki",
    inputSchema: createJsonSchema(UploadGroupWikiAttachmentSchema),
    readOnly: false

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yoda-digital/mcp-gitlab-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server