Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 18, 2026

Cloudflare blocks requests without User-Agent headers. The MCP server uses node-fetch which doesn't set this header by default, causing 403 errors when accessing GitLab.com.

Changes

  • Added User-Agent: gitlab-mcp-server/${version} (node-fetch) to BASE_HEADERS
  • Added test to verify User-Agent header presence

Example

Before:

const BASE_HEADERS: Record<string, string> = {
  Accept: "application/json",
  "Content-Type": "application/json",
};

After:

const BASE_HEADERS: Record<string, string> = {
  Accept: "application/json",
  "Content-Type": "application/json",
  "User-Agent": `gitlab-mcp-server/${SERVER_VERSION} (node-fetch)`,
};

All HTTP requests to GitLab APIs now include this header, making them pass Cloudflare's bot detection.

Original prompt

This section details on the original issue you should resolve

<issue_title>403 Forbidden due to Cloudflare when using MCP server on GitLab.com</issue_title>
<issue_description>Hi,

I’m using GitHub Copilot in PhpStorm with gitlab-mcp to access GitLab.com. While direct curl requests with my Personal Access Token work fine, the MCP server returns 403 Forbidden with a Cloudflare “Just a moment… Enable JavaScript and cookies to continue” page when trying to fetch merge requests.

Interestingly, using the official GitLab MCP server does not produce this issue.

Is this a known limitation of gitlab-mcp with Cloudflare-protected GitLab instances, or is it something specific to my setup?

Thanks for any guidance!</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 18, 2026 14:17
Co-authored-by: zereight <42544600+zereight@users.noreply.github.com>
Co-authored-by: zereight <42544600+zereight@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix 403 Forbidden error with MCP server on GitLab.com Add User-Agent header to fix Cloudflare 403 on GitLab.com Jan 18, 2026
Copilot AI requested a review from zereight January 18, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

403 Forbidden due to Cloudflare when using MCP server on GitLab.com

2 participants