Skip to main content
Glama
harshmaur

GitLab MCP Server

by harshmaur

create_or_update_file

Create or update files in GitLab projects by specifying content, path, and commit details to manage repository files directly.

Instructions

Create or update a single file in a GitLab project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesProject ID or complete URL-encoded path to project
file_pathYesPath where to create/update the file
contentYesContent of the file
commit_messageYesCommit message
branchYesBranch to create/update the file in
previous_pathNoPath of the file to move/rename
last_commit_idNoLast known file commit ID
commit_idNoCurrent file commit ID (for update operations)

Implementation Reference

  • Zod input schema definition for the 'create_or_update_file' tool, extending ProjectParamsSchema with file-specific parameters.
    export const CreateOrUpdateFileSchema = ProjectParamsSchema.extend({
      file_path: z.string().describe("Path where to create/update the file"),
      content: z.string().describe("Content of the file"),
      commit_message: z.string().describe("Commit message"),
      branch: z.string().describe("Branch to create/update the file in"),
      previous_path: z.string().optional().describe("Path of the file to move/rename"),
      last_commit_id: z.string().optional().describe("Last known file commit ID"),
      commit_id: z.string().optional().describe("Current file commit ID (for update operations)"),
    });
  • Response schema for the create_or_update_file tool operation.
    export const GitLabCreateUpdateFileResponseSchema = z.object({
      file_path: z.string(),
      branch: z.string(),
      commit_id: z.string().optional(), // Optional since it's not always returned by the API
      content: GitLabFileContentSchema.optional(),
    });
  • Base schema extended by CreateOrUpdateFileSchema for project_id parameter.
    const ProjectParamsSchema = z.object({
      project_id: z.string().describe("Project ID or complete URL-encoded path to project"), // Changed from owner/repo to match GitLab API
    });
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool performs write operations ('create or update'), implying mutation, but lacks details on permissions required, whether changes are reversible, rate limits, or error handling (e.g., what happens if the file already exists or the branch doesn't). This is a significant gap for a mutation tool.

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, clear sentence that efficiently conveys the core action and resource without unnecessary words. It's front-loaded with the key information, making it easy to parse quickly.

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 mutation tool with 8 parameters, no annotations, and no output schema, the description is insufficient. It doesn't cover behavioral aspects like permissions or error handling, nor does it explain the return value or how to interpret success/failure. Given the complexity and lack of structured data, more context is needed.

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

Parameters3/5

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

The schema description coverage is 100%, so all parameters are documented in the schema. The description adds no additional meaning beyond the schema, such as explaining the relationship between 'previous_path' and 'file_path' for renaming, or clarifying when 'last_commit_id' and 'commit_id' are needed. Baseline 3 is appropriate as the schema does the heavy lifting.

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 action ('create or update') and resource ('a single file in a GitLab project'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'push_files' or 'get_file_contents', which could handle similar file operations, so it doesn't reach the highest score.

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?

The description provides no guidance on when to use this tool versus alternatives like 'push_files' (which might handle multiple files) or 'get_file_contents' (for reading). There's no mention of prerequisites, such as authentication or project access, or when to choose create vs. update operations based on file existence.

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

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/harshmaur/gitlab-mcp'

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