File content retrieval fails with numeric project IDs but works with string format
Problem Summary
The get_file_contents
function fails when using numeric project IDs but works correctly when using the string format for project IDs.
What I was doing
Testing file content retrieval using both numeric and string project ID formats:
- Numeric:
project_id: 2
- String:
project_id: john/melange-mvp-template
Expected behavior
Both numeric and string project ID formats should work according to GitLab API specifications. The GitLab API accepts both formats for project identification.
Actual behavior
-
✅ String format works:get_file_contents(project_id="john/melange-mvp-template", file_path="README.md")
returns file content successfully -
❌ Numeric format fails:get_file_contents(project_id=2, file_path="dune")
returns "GitLab API error: Not Found" -
❌ Same numeric ID works elsewhere: The same numeric ID (2) works fine in other operations likeget_issues(project_id="john/melange-mvp-template")
which internally resolves to project ID 2
Test cases that demonstrate the issue
// These should both work but only the second one does:
// FAILS - Returns "GitLab API error: Not Found"
mcp_gitlab.get_file_contents({
project_id: 2,
file_path: "README.md"
})
// WORKS - Returns file content successfully
mcp_gitlab.get_file_contents({
project_id: "john/melange-mvp-template",
file_path: "README.md"
})
Error logs
MCP error -32603: GitLab API error: Not Found
Repository tested against
- Repository:
john/melange-mvp-template
ongit.haley.io
- Project ID: 2 (confirmed via search_repositories)
- Files tested:
README.md
,dune
,CLAUDE.md
Reproducibility
100% reproducible. The numeric format consistently fails while the string format consistently works for the exact same files.
Possible root cause
The MCP server may not be properly URL-encoding numeric project IDs when constructing the GitLab API URL, or may be treating numeric vs string project IDs differently in the request construction.
Impact
- Medium: Users must remember to use string format instead of numeric IDs
- Consistency: Creates confusion since other operations work with both formats
- Developer experience: Reduces reliability and predictability of the API
Suggested fix
Ensure that both numeric and string project ID formats are handled consistently across all functions, following GitLab API standards where project ID can be either:
- Numeric:
123
- String:
namespace/project-name
- URL-encoded:
namespace%2Fproject-name