GitLab MCP server fails because GitLab API response has no `fork` field
The official GitLab MCP server (modelcontextprotocol/servers) fails against the GitLab Projects API because the Zod schema
GitLabRepositorySchemarequiresownerandforkfields that the API response does not include. Is this a bug, and how can I make the server work against a self-managed GitLab instance (v17.8.2-ee)?Originally asked on GitHub: https://github.com/modelcontextprotocol/servers/issues/590
4 answers
Status: confirmed bug, but closed as NOT_PLANNED. The GitLab MCP server was moved to the archived
modelcontextprotocol/servers-archivedrepository, and the maintainer points users to the alternatives listed in the official integrations Readme, so no fix is coming in this codebase.The root cause is in
src/gitlab/schemas.ts:GitLabRepositorySchemarequiresowner: GitLabOwnerSchemaandfork: z.boolean(). As the reporter noted, the GitLab Projects API documentation says the response has noforkfield; onlyforked_from_projectappears when the project is a fork, and that field requires a valid token when the upstream project is private. The schema therefore fails to parse project responses.Workaround that worked (confirmed by a commenter against a self-managed GitLab v17.8.2-ee instance): edit
src/gitlab/schemas.tsand delete these two lines fromGitLabRepositorySchema:typescriptowner: GitLabOwnerSchema, fork: z.boolean(),General advice: since this edits the server's source, you need to rebuild or restart the MCP server process afterward for the change to take effect.
One commenter suggested generating
schemas.tsfrom GitLab's OpenAPI spec usingopenapi-typescript-codegen, but another replied that the spec is incomplete and too detailed to produce tools an LLM can use well, so that route is unconfirmed.Did this work for you?What a GitHub user tried on GitHub (Outcome unclear)
Reported that
GitLabRepositorySchemarequiresownerandfork, and quoted the GitLab Projects API docs showing the response has noforkfield (onlyforked_from_projectappears for forks). This schema mismatch breaks response parsing.Source: https://github.com/modelcontextprotocol/servers/issues/590 (opens external site)
Did this work for you?What @schnaker85 tried on GitHub (Worked)
Edited
src/gitlab/schemas.tsto removeowner: GitLabOwnerSchemaandfork: z.boolean()fromGitLabRepositorySchema; the server then worked against a self-managed GitLab v17.8.2-ee instance.Did this work for you?What @perweij tried on GitHub (Outcome unclear)
Proposed generating the schema from GitLab's OpenAPI spec (
wgettheopenapi_v2.yaml, thennpx openapi-typescript-codegen --input openapi_v2.yaml --output schema --client zod). Another commenter said the spec is incomplete and too detailed, so this was not confirmed.Did this work for you?
Related questions
- mcp-server-fetch: 'AnyUrl' object has no attribute 'decode' error
- Does the official MCP Postgres example validate SQL before executing it?
- How to fix UTF-8 Japanese text corruption/crash in mcp-server-sqlite with Claude Desktop on Windows?
- MCP Knowledge Graph Memory Server fails with ${workspaceFolder} in MEMORY_FILE_PATH
- npx @modelcontextprotocol/server-filesystem: ERR_MODULE_NOT_FOUND for zod-to-json-schema