GitHub MCP Server Policy

Sandbox the GitHub MCP server. Both REST and GraphQL live on api.github.com.

What it needs

ResourceAccessDetails
FilesystemRead + WriteCache for API responses, output for generated files
Networkapi.github.comREST API + GraphQL (same hostname)
EnvGITHUB_TOKENGitHub personal access token

Complete Policy

command: ["node", "@modelcontextprotocol/server-github"]

filesystem:
  read:
    - "./cache"              # API response cache
  write:
    - "./output"             # Generated diffs, reports

network:
  allow:
    - "api.github.com"       # REST + GraphQL

env:
  allow:
    - "GITHUB_TOKEN"
    - "HOME"

limits:
  memory_mb: 256
  timeout_s: 300

How to run

# Step 1: Install the server
npm install -g @modelcontextprotocol/server-github

# Step 2: Set your token
export GITHUB_TOKEN="ghp_xxxxxxxxxxxx"

# Step 3: Run sandboxed
warden run --policy policy-github.yaml

Tips

  • Grant HOME if the server needs to read git config or .netrc
  • Never put GITHUB_TOKEN in the policy, give only the name; the value comes from the shell
  • Both GraphQL and REST are on api.github.com, so one entry is enough
  • Increase timeout_s for long-running PR reviews

Troubleshooting

ErrorFix
permission denied on networkCheck that api.github.com is in network.allow
Token not foundExport GITHUB_TOKEN in the shell; the policy contains only the name
Rate limitingGrant write access to the cache directory

Resources