Skip to main content
Glama

upload_project_wiki_attachment

Upload files as attachments to a GitLab project wiki by specifying the branch, file path, project ID, and content. Simplify documentation and resource management directly within the wiki.

Instructions

Upload an attachment to a GitLab project wiki

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branchNo
contentNo
file_pathNo
project_idNo

Implementation Reference

  • Core handler function that performs the actual upload of wiki attachment to GitLab project wiki using the GitLab API.
    async uploadProjectWikiAttachment(
      projectId: 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}/projects/${encodeURIComponent(projectId)}/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 server request handler that parses input arguments with the schema and delegates to the GitLabApi handler method.
    case "upload_project_wiki_attachment": {
      const args = UploadProjectWikiAttachmentSchema.parse(request.params.arguments);
      const attachment = await gitlabApi.uploadProjectWikiAttachment(args.project_id, {
        file_path: args.file_path,
        content: args.content,
        branch: args.branch
      });
      return formatWikiAttachmentResponse(attachment);
    }
  • Zod schema defining the input validation for the upload_project_wiki_attachment tool: project_id, file_path, content, optional branch.
    export const UploadProjectWikiAttachmentSchema = z.object({
      project_id: z.string(),
      file_path: z.string(),
      content: z.string(),
      branch: z.string().optional()
    });
  • src/index.ts:223-228 (registration)
    Tool registration in the ALL_TOOLS array, defining name, description, input schema, and read-only status for the MCP server.
    {
      name: "upload_project_wiki_attachment",
      description: "Upload an attachment to a GitLab project wiki",
      inputSchema: createJsonSchema(UploadProjectWikiAttachmentSchema),
      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