Skip to content

Conversation

@BobMerkus
Copy link
Contributor

Description

This PR fixes the get_file_contents tool, as the ref is optional for the AI, but not set when a request is made to the gitlab API. It also sets the default ref to HEAD for the create_branch tool, this avoids making an unnecessary API request to retrieve it.

Server Details

  • Server: gitlab
  • Changes to: tools

Motivation and Context

The get_file_contents has an optional ref parameter for the AI tooling, but is not set properly in the API request when omitted by the AI.

How Has This Been Tested?

Yeah have tested the MCP locally

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

Additional context

See Repository Files API Gitlab Documentation

Attribute Type Required Description
id integer or string yes The ID or URL-encoded path of the project.
file_path string yes URL encoded full path to new file, such as lib%2Fclass%2Erb.
ref string yes The name of branch, tag or commit. Use HEAD to automatically use the default branch.

If you don’t know the branch name or want to use the default branch, you can use HEAD as the ref value. For example:

curl --header "PRIVATE-TOKEN: " \
  --url "https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fmodels%2Fkey%2Erb?ref=HEAD"

@BobMerkus
Copy link
Contributor Author

@tadasant Would you mind taking a look at this PR? Let me know if any changes are required

@olaservo olaservo added bug Something isn't working server-gitlab labels Apr 18, 2025
});

export const GetFileContentsSchema = ProjectParamsSchema.extend({
project_id: z.string().describe("Project ID or URL-encoded path"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is redundant since its already being inherited from the ProjectParamsSchema?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, have removed it from schema

@olaservo olaservo merged commit 0f86b30 into modelcontextprotocol:main Apr 19, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants