Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCP GitHub Server Cannot Access Private Repositories (Cursor) #727

Open
attilapolgar opened this issue Mar 3, 2025 · 3 comments
Open

MCP GitHub Server Cannot Access Private Repositories (Cursor) #727

attilapolgar opened this issue Mar 3, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@attilapolgar
Copy link

attilapolgar commented Mar 3, 2025

Description

The @modelcontextprotocol/server-github package cannot access private GitHub repositories, consistently returning a "Not Found" error despite having a correctly authorized Personal Access Token (PAT). The same server successfully accesses public repositories with or without a token, indicating that the authentication mechanism is not being properly applied to API requests for private repositories.

Environment

  • OS: macOS 24.3.0
  • Node.js version: Latest stable
  • MCP server package: @modelcontextprotocol/server-github (latest)
  • Configuration: Using npx to run the server
  • Cursor v0.46.8

Reproduction Steps

  1. Create a GitHub Personal Access Token (PAT) with the repo scope
  2. Configure the MCP server with this token:
    {
        "mcpServers": {
            "github": {
                "command": "npx",
                "args": [
                    "-y",
                    "@modelcontextprotocol/server-github"
                ],
                "env": {
                    "GITHUB_TOKEN": "your_token_here"
                }
            }
        }
    }
  3. Attempt to list issues from a private repository using:
    mcp__list_issues({owner: "OWNER", repo: "PRIVATE_REPO", per_page: 3})

Actual Result

{"error":"MCP error -32603: Not Found: Resource not found: Not Found"}

Expected Result

The MCP server should successfully list issues from the private repository, similar to how it works with public repositories.

Verification Steps

  1. Token authentication works correctly with public repositories:

    mcp__list_issues({owner: "microsoft", repo: "vscode", per_page: 3})

    Result: Successfully returns issues from the microsoft/vscode repository.

  2. Direct API calls to the private repository using the same token work properly:

    • Using curl:

      curl -H "Authorization: token GITHUB_TOKEN" https://api.github.com/repos/OWNER/PRIVATE_REPO/issues
      

      Result: Successfully returns issues from the private repository.

    • Using a custom Node.js script:

      // Custom script with same token
      const fetch = require('node-fetch');
      
      async function getIssues() {
        const response = await fetch(
          'https://api.github.com/repos/OWNER/PRIVATE_REPO/issues',
          {
            headers: {
              Authorization: `token ${process.env.GITHUB_TOKEN}`,
              'User-Agent': 'GitHub-API-Test'
            }
          }
        );
        
        if (response.ok) {
          const issues = await response.json();
          console.log(JSON.stringify(issues, null, 2));
        } else {
          console.error('Error:', response.status, await response.text());
        }
      }
      
      getIssues();

      Result: Successfully returns issues from the private repository.

Additional Information

  • Various environment variable names were tried (GITHUB_TOKEN, GH_TOKEN) with no difference in results
  • The token permissions were thoroughly verified and confirmed to have the necessary repo scope
  • The error only occurs when trying to access private repositories through the MCP GitHub server
  • The MCP server appears to be ignoring the authentication token when making API requests to GitHub for private repositories, as the behavior is identical with or without a token
@attilapolgar attilapolgar added the bug Something isn't working label Mar 3, 2025
@attilapolgar attilapolgar changed the title MCP GitHub Server Cannot Access Private Repositories MCP GitHub Server Cannot Access Private Repositories (Cursor) Mar 3, 2025
@attilapolgar
Copy link
Author

attilapolgar commented Mar 3, 2025

Potentially relevant issues or comments I discovered

#710 (comment)
#720
#677

@gthieleb
Copy link

gthieleb commented Mar 3, 2025

Did you try with GITHUB_PERSONAL_ACCESS_TOKEN. Its stated in the README you need to scroll a bit down?

@jacobcolyvan
Copy link

jacobcolyvan commented Mar 3, 2025

Confirming same for me, I think its because the builds are failing which means the latest changes aren't being released to NPM.
I added a PR yesterday that should fix the typescript/NPM build – #722.

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

No branches or pull requests

3 participants