How to Add MCP Servers to Cursor: mcp.json, Env Vars and Fixes
Cursor keeps its MCP setup in a JSON file rather than a CLI, which makes it easy to read and easy to get subtly wrong. There are two places that file can live, two kinds of server it can describe, and a handful of variable forms that only work in certain fields. This guide walks through all of it using two servers whose Cursor configs come straight from their maintainers: GitHub's official MCP server and Microsoft's Playwright MCP. Everything here matches Cursor's MCP docs and those servers' READMEs as of November 2026.
For a side-by-side with Claude Code and VS Code, see our post on configuring MCP servers across all three clients.
Project file or global file
Cursor's docs describe two locations:
.cursor/mcp.jsoninside a project, for tools that belong to that project.~/.cursor/mcp.jsonin your home directory, for tools you want in every project, in both the editor and the Cursor CLI.
Both use the same root key, mcpServers, with one entry per server name. The split works the same way it does for any dotfile. If a server is part of how the repo is built or tested, put it in the project file and commit it. If it's tied to your own accounts (your GitHub token, your personal notes), put it in the global file so it never lands in a pull request.
Stdio versus remote entries
A stdio server is a local process. Cursor starts it and talks over stdin and stdout. Its fields are type (set to "stdio"), command, args, env and envFile.
A remote server is a URL Cursor connects to over HTTP. Its fields are url and headers. The docs are explicit that envFile is only for stdio servers, so for remote ones you pass secrets through variable interpolation instead.
Cursor resolves variables in command, args, env, url and headers. The two you'll use most are ${env:NAME} for an environment variable and ${workspaceFolder} for the project root.
Worked example 1: GitHub, remote
GitHub's install guide for Cursor recommends the hosted server and gives this config for ~/.cursor/mcp.json:
{
"mcpServers": {
"github": {
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer YOUR_GITHUB_PAT"
}
}
}
}
That works, but it parks a live token in a plain file. Using Cursor's interpolation, you can keep the token in your shell environment instead:
{
"mcpServers": {
"github": {
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer ${env:GITHUB_PAT}"
}
}
}
}
Export GITHUB_PAT in the shell profile Cursor inherits from. On macOS, if you launch Cursor from the Dock, it may not see variables you only set in an interactive shell, so launching once from a terminal with cursor . is a quick way to test.
The guide notes the remote server needs Cursor v0.48.0 or later for Streamable HTTP. Any current build is well past that, but if you're on a pinned old version, this is the first thing to check. More on the server itself on our GitHub MCP server page.
Worked example 2: GitHub in Docker and Playwright via npx
If you'd rather run GitHub's server locally, the same guide gives a Docker config:
{
"mcpServers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_PAT"
}
}
}
}
The env block sets the variable for the docker process, and the bare -e GITHUB_PERSONAL_ACCESS_TOKEN in args forwards it into the container. Drop either half and the server starts without a token. Because this is a stdio entry, you could also move the token into a file and point envFile at it.
The Playwright MCP server is simpler. Its README gives a standard config that works in Cursor unchanged:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}
This one is a good candidate for the project file. Add "--headless" to args if you don't want a browser window popping up, or "--browser", "firefox" to switch engines; both flags are listed in the README. The README also mentions a one-click install button and a manual route through Cursor Settings, MCP, then "Add new MCP Server".
A merged file with both servers is just the two entries side by side under mcpServers, and our MCP config generator will write it for you if you pick the servers. If you'd like to check the JSON before Cursor reads it, paste it into our MCP config validator.
Approving tool calls
By default Cursor asks before it runs any MCP tool. The docs say MCP tools follow the same Run Modes as terminal commands, so if you use the "Auto-review" mode, tools you've allowlisted run immediately and the rest still ask.
My advice: leave read-only tools (searching issues, reading a page in Playwright) on the allowlist once you trust the server, and keep anything that writes (creating a pull request, pushing a branch) on manual approval. A prompt you have to click is a small price for not having an agent open twenty issues on a public repo. Our post on MCP tool poisoning and prompt-injection defenses explains why a malicious web page read through Playwright can try to steer later tool calls.
To switch a server off without deleting its config, open Customize in the sidebar and use the server's toggle. Disabled servers don't load and don't show up in chat.
Five errors and how to fix them
1. The server never appears. Usually invalid JSON: a trailing comma, a missing brace, or entries placed outside mcpServers. Cursor won't read a broken file. Validate it, then restart Cursor fully; GitHub's guide specifically says to restart after editing the config.
2. envFile ignored on a remote server. It's stdio-only. For a url entry, use ${env:NAME} inside headers instead.
3. Literal ${GITHUB_PAT} sent as the token. Cursor's form is ${env:NAME}, with the env: prefix. The bare ${NAME} syntax you might copy from a Claude Code .mcp.json doesn't use that prefix, and mixing them up gives you a 401.
4. Docker image pull fails. GitHub's guide covers this: make sure Docker Desktop is running, and if the pull from ghcr.io fails because of a stale login, run docker logout ghcr.io and try again. The image is public, so you don't need to be logged in.
5. Using the old npm package. Older tutorials point at @modelcontextprotocol/server-github. GitHub's guide says that package stopped working in April 2025; use the Docker image or the hosted endpoint.
When something else goes wrong, open the Output panel with Cmd+Shift+U (Ctrl+Shift+U on Windows and Linux) and choose "MCP Logs" from the dropdown. It shows initialization, each tool call and the errors, which is usually enough to tell a bad command path from a bad token.
Next steps
Browse the MCP server directory for more servers, read our Cursor profile for plans and pricing, and if you're still choosing an editor, Cursor alternatives lays out the options. For server-side debugging outside the editor, MCP Inspector is the tool to reach for.
Written by AIDToolStack Editorial
Researched from official documentation, specifications and vendor pages, listed under Sources below. Last checked November 2026.