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
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden but only states the action without behavioral details. It doesn't disclose required permissions, whether it overwrites existing attachments, rate limits, response format, or error conditions. 'Upload' implies a write operation, but no safety or mutation context is provided.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, direct sentence with zero wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place by conveying essential purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 4-parameter mutation tool with no annotations and no output schema, the description is incomplete. It lacks parameter explanations, behavioral context, usage guidance, and output details. While concise, it doesn't provide enough information for safe and effective use given the complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate but adds no parameter information. It doesn't explain what 'branch', 'content', 'file_path', or 'project_id' mean, their formats, or relationships (e.g., 'content' as file data, 'file_path' as wiki location). This leaves all 4 parameters undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('upload') and resource ('attachment to a GitLab project wiki'), making the purpose immediately understandable. It distinguishes from some siblings like 'upload_group_wiki_attachment' by specifying 'project' vs 'group', but doesn't explicitly differentiate from other file/writing tools like 'create_or_update_file' or 'push_files'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing project access), compare to similar tools like 'upload_group_wiki_attachment' or 'create_project_wiki_page', or specify use cases (e.g., for adding images/docs to wiki pages).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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