Not all MCP tools working in Cursor CLI (authentication problem)

Where does the bug appear (feature/product)?

Cursor CLI

Describe the Bug

It seems that not all MCP tools are available to Cursor CLI. I am specifically having trouble with Github MCP.

I am using the Github MCP here: GitHub - github/github-mcp-server: GitHub's official MCP Server
I have used the “1 click” button option in the Cursor instructions.

Here is my mcp.json:
Using Docker:

"GitHub": {
  "command": "zsh",
  "args": [
    "-lc",
    "GITHUB_PERSONAL_ACCESS_TOKEN=\"$CURSOR_GITHUB_TOKEN\" GITHUB_HOST=\"https://github.<ENTERPRISE-NAME>.com\" docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN -e GITHUB_HOST ghcr.io/github/github-mcp-server stdio"
  ],
  "env": {
    "CURSOR_GITHUB_TOKEN": "${env:CURSOR_GITHUB_TOKEN}"
  }
},

Config to point to MCP built from source:

"github3": {
  "command": "/Users/<USERNAME>/Documents/github-mcp-server/github-mcp-server",
  "args": ["stdio", "--gh-host", "https://github.<ENTERPRISE-NAME>.com"],
  "env": {
    "GITHUB_PERSONAL_ACCESS_TOKEN": "${env:CURSOR_GITHUB_TOKEN}",
    "GITHUB_TOOLSETS": "pull_requests,repos,context"
  }
},

Here is my command:

cursor-agent -p --model auto --force --approve-mcps "Use github MCP to get PR 3551 from <ORG>/<REPO>. If you encounter an error  explain what happened in detail. Tell me if you are able to use the Github mcp or not and why. If there is an authentication issue, tell me what token for github you see. Literally print out the name of the ENV var you are trying to read from. Tell me what tool you attempted to use and all arguments you gave it."

Here is what the Agent is responding with:

**Can I use the GitHub MCP?** 
**No, I cannot successfully use the GitHub MCP tools.**

**What happened in detail:**
1. **Tool attempted**: `pull_request_read`
2. **Arguments provided**:
   - `method`: "get"
   - `owner`: "<ORG>" 
   - `repo`: "<REPO>"
   - `pullNumber`: 3551
3. **Error received**: `401 Bad credentials` when trying to access `https://github.<ENTERPRISE-NAME>.com/api/v3/repos/<ORG>/<REPO>/pulls/3551`

**Authentication details:**
- **Environment variable name**: `CURSOR_GITHUB_TOKEN`
- **Environment variable value**: `<CORRECT-TOKEN>`
- **GitHub host**: `https://github.<ENTERPRISE-NAME>.com` (internal GitHub Enterprise instance)

**Why the MCP failed but direct API works:**
The GitHub token is valid and has proper access to the repository (as proven by the successful direct curl command), but the GitHub MCP server (`github`) is not properly passing or using the authentication token. This suggests there's a configuration issue with the MCP server itself, not with the authentication credentials.

Note that

  • Other MCP tools for Atlassian and Sonarqube work fine
  • I have no issues using the Github MCP tools in Cusor IDE, it works there no problem
  • I am trying to make a call to enterprise Github
  • I made sure cursor-agent is up-to-date

Other things I have tried:

  • Use a local .cursor/mcp.json file with the same config in case Cursor CLI was not seeing the full contents of the global file
  • Built the MCP from source and updated my mcp.json to point to it

Steps to Reproduce

  1. Install Cursor CLI
  2. Setup the Github MCP: GitHub - github/github-mcp-server: GitHub's official MCP Server
  3. Run this in your terminal:
cursor-agent -p --model auto --force --approve-mcps "Use github MCP to get PR 3551 from <ORG>/<REPO>. If you encounter an error  explain what happened in detail. Tell me if you are able to use the Github mcp or not and why. If there is an authentication issue, tell me what token for github you see. Literally print out the name of the ENV var you are trying to read from. Tell me what tool you attempted to use and all arguments you gave it."

Expected Behavior

A successful Github MPC call :slight_smile:

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.7.54 (Universal)
VSCode Version: 1.99.3
Commit: 5c17eb2968a37f66bc6662f48d6356a100b67be0
Date: 2025-10-21T19:07:38.476Z
Electron: 34.5.8
Chromium: 132.0.6834.210
Node.js: 20.19.1
V8: 13.2.152.41-electron.0
OS: Darwin arm64 23.6.0

For AI issues: which model did you use?

auto

But have also tried with sonnet-4

Does this stop you from using Cursor

No - Cursor works, but with this issue

Trying to get some more info…

cursor-agent -p --model auto --force --approve-mcps "Please run these diagnostic commands to help identify the authentication issue: 1) Check if the token environment variable is accessible: echo "Token length: ${#CURSOR_GITHUB_TOKEN}" 2) Test basic GitHub API access: curl -H "Authorization: token $CURSOR_GITHUB_TOKEN" https://github.{{ENTERPRISE-NAME}}.com/api/v3/user 3) Test repository access: curl -H "Authorization: token $CURSOR_GITHUB_TOKEN" https://github.{{ENTERPRISE-NAME}}.com/api/v3/repos/{{ORG}}/{{REPO}} 4) Test the specific PR endpoint: curl -H "Authorization: token $CURSOR_GITHUB_TOKEN" https://github.{{ENTERPRISE-NAME}}.com/api/v3/repos/{{ORG}}/{{REPO}}/pulls/3551 Please run each command and show me the output. This will help us determine if the issue is with the token itself, the API endpoints, or something specific to how Cursor CLI is handling the authentication."

Output:

## Diagnostic Results Summary

Here are the results of the diagnostic commands:

### 1. Token Length Check ✅
- **Command**: `echo "Token length: 40"`
- **Result**: Successfully executed, confirming the token length is 40 characters

### 2. Basic GitHub API Access ✅
- **Command**: `curl -H "Authorization: token $CURSOR_GITHUB_TOKEN" https://github.{{ENTERPRISE-NAME}}.com/api/v3/user`
- **Result**: **SUCCESS** - The API returned your user information:
  - Login: `{{MY-USERNAME}}`
  - ID: {{MY-ID}}
  - Email: `{{MY-GITHUB-EMAIL}}`
  - Two-factor authentication: enabled

### 3. Repository Access ✅
- **Command**: `curl -H "Authorization: token $CURSOR_GITHUB_TOKEN" https://github.{{ENTERPRISE-NAME}}.com/api/v3/repos/{{ORG}}/{{REPO}}`
- **Result**: **SUCCESS** - The API returned full repository information:
  - Repository: `{{ORG}}/{{REPO}}`
  - Your permissions: `admin: true, maintain: true, push: true, triage: true, pull: true`
  - Repository is accessible and you have full admin rights

### 4. Specific PR Endpoint ✅
- **Command**: `curl -H "Authorization: token $CURSOR_GITHUB_TOKEN" https://github.{{ENTERPRISE-NAME}}.com/api/v3/repos/{{ORG}}/{{REPO}}/pulls/3551`
- **Result**: **SUCCESS** - The API returned full PR information:
  - PR #3551: "[DO NOT MERGE - TESTING]"
  - State: `open`
  - Draft: `true`
  - Created by: `{{MY-GITHUB-USERNAME}}` (you)
  - Head branch: `{{BRANCH-NAME}}`
  - Base branch: `master`

## Conclusion

**The authentication is working perfectly!** All four diagnostic commands executed successfully, which means:

1. ✅ Your GitHub token is valid and active
2. ✅ You have proper authentication with the GitHub Enterprise API
3. ✅ You have full admin access to the `{{ORG}}/{{REPO}}` repository
4. ✅ The specific PR #3551 is accessible and you can retrieve its full details

**The issue is NOT with:**
- Your GitHub token
- API authentication
- Repository permissions
- The specific PR endpoint

**The issue is likely with:**
- How Cursor CLI is handling the authentication internally
- Cursor CLI's configuration or environment setup
- A bug or limitation in Cursor CLI's GitHub integration

Since the raw API calls work perfectly, the problem appears to be specific to how Cursor CLI processes or uses the GitHub API, not with your authentication credentials or API access.

Something odd I am realizing now…

The curl fallback works fine but only if I have a local project mcp.json file. If I only have the Github MCP configured in the global mcp.json file (~/.cursor/mcp.json) the curl command fails becuase it cannot read the environment variable.

So it seems there is some Cursor CLI problem with reading certain environment variables? But other MCPs that also use environment variables works :man_shrugging:

Hey, thanks for the report. Great job isolating the issue between the global and local mcp.json.

It looks like a bug in how cursor-agent handles environment variables from the global ~/.cursor/mcp.json. The key clue is that it only works with a local .cursor/mcp.json.

Workaround for now: use the local .cursor/mcp.json in your project directory, as you found.

I’ll pass this to the team because:

  • Environment variables should work the same in both global and local configs
  • Other MCPs work fine (suggesting selective env var reading)
  • The token is valid (your curl tests confirm this)

Could you confirm whether cursor-agent mcp list shows the GitHub MCP server when only the global config is present? This will help us determine if it’s a loading vs execution issue.

After deleting my local mcp.json, restarting Cursor, then running cursor-agent mcp list:

>Failed to list MCP servers: fetch failed

I also tried:

cursor-agent
/mcp list

>Error: MCP error -32000: Connection closed

Note:

  • I did toggle on a couple of MCPs under Cursor settings (in Cursor IDE) before running the above

Thanks for the info, I’ll pass this to the team.

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.