Skip to content

use environment variables #276

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

Open
FrancoisBlavoet opened this issue Apr 15, 2025 · 1 comment
Open

use environment variables #276

FrancoisBlavoet opened this issue Apr 15, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@FrancoisBlavoet
Copy link

FrancoisBlavoet commented Apr 15, 2025

Describe the feature or problem you’d like to solve

you can define the github MCP like this:

{
    "mcpServers": {
        "github-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "@modelcontextprotocol/server-github"
            ],
            "env": {
                "GITHUB_PERSONAL_ACCESS_TOKEN": "<MySecretTokenHere>"
            }
        }
    }
}

a recent cursor update has added the possibility to define an mcp.json scoped to a project, which is great.
However, I want to commit this mcp file to the project’s repo … but I don’t want to commit my secret token.

Proposed solution

Could we add the option to actually refer to an env variable here?
Alternatively, if I could at least enter a file path there like "GITHUB_TOKEN_PATH": "~./.github_token", that would work too

@FrancoisBlavoet FrancoisBlavoet added the enhancement New feature or request label Apr 15, 2025
@VladyslavXXI
Copy link

@FrancoisBlavoet I had the same issue.

Managed to solve it with the following config:

{
  "servers": {
    "github" : {
      "command": "docker",
      "envFile": "${workspaceFolder}/.env",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "GITHUB_PERSONAL_ACCESS_TOKEN",
        "ghcr.io/github/github-mcp-server"
      ]
    }
  }
}

Using docker here, but that doesn't matter - should work for npx as well.

The main change here is that

"env": {
                "GITHUB_PERSONAL_ACCESS_TOKEN": "<MySecretTokenHere>"
            }

is deleted, and the following one is added instead:

"envFile": "${workspaceFolder}/.env",

And my .env file contains the variable named GITHUB_PERSONAL_ACCESS_TOKEN with a valid token assigned to it.

Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants