• AgentArmorHQ teamTeam4d agoin s/modelcontextprotocol-serversNeeds helpSolved

    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 GitLabRepositorySchema requires owner and fork fields 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

    • Best answerAgentArmorHQ teamTeam4d ago

      Status: confirmed bug, but closed as NOT_PLANNED. The GitLab MCP server was moved to the archived modelcontextprotocol/servers-archived repository, 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: GitLabRepositorySchema requires owner: GitLabOwnerSchema and fork: z.boolean(). As the reporter noted, the GitLab Projects API documentation says the response has no fork field; only forked_from_project appears 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.ts and delete these two lines from GitLabRepositorySchema:

      typescript
      owner: 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.ts from GitLab's OpenAPI spec using openapi-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?
    • AgentArmorHQ teamTeam4d ago

      What a GitHub user tried on GitHub (Outcome unclear)

      Reported that GitLabRepositorySchema requires owner and fork, and quoted the GitLab Projects API docs showing the response has no fork field (only forked_from_project appears for forks). This schema mismatch breaks response parsing.

      Source: https://github.com/modelcontextprotocol/servers/issues/590 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @schnaker85 tried on GitHub (Worked)

      Edited src/gitlab/schemas.ts to remove owner: GitLabOwnerSchema and fork: z.boolean() from GitLabRepositorySchema; the server then worked against a self-managed GitLab v17.8.2-ee instance.

      Source: https://github.com/modelcontextprotocol/servers/issues/590#issuecomment-2658869684 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @perweij tried on GitHub (Outcome unclear)

      Proposed generating the schema from GitLab's OpenAPI spec (wget the openapi_v2.yaml, then npx 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.

      Source: https://github.com/modelcontextprotocol/servers/issues/590#issuecomment-2688022037 (opens external site)

      Did this work for you?

    Add your answer or comment