Introduction
I'm a second-year student at ZEN University studying intelligent informatics, and I want to become an AI engineer. I build personal projects alongside my studies.
Day to day I work on Windows with Claude Code, Codex CLI, and Cursor. I often connect MCP servers so I can work with issues, docs, and external services without pasting the same context into chat. The catch is that each client stores the configuration in a different place and uses a different add command.
This article is a setup note for myself, limited to how I connect MCP servers. Command names, config-file locations, and flags are taken from official documentation I checked. I have left out anything I could not verify. Token values in the examples are placeholders only.
What MCP is
The Model Context Protocol (MCP) is an open protocol for connecting an AI application to external tools and data sources. A host—an AI application such as Claude Code or Cursor—holds a client connection for each MCP server, and can then use the tools and resources that server provides.
The official architecture overview describes the roles this way:
- Host: the AI application that coordinates the connections
- Client: the component that maintains the connection to one MCP server
- Server: the program that provides tools or context
"MCP server" refers to the program that serves context, not to where it runs. A process started on your own machine and a server hosted in the cloud are both MCP servers.
The reason to connect one is simple: instead of pasting information from another system into chat, Claude, Codex, or Cursor can use that system directly. Only connect servers you trust. A server that fetches external content can also expose you to prompt-injection risk.
Two ways to connect: stdio and remote (HTTP / OAuth)
The MCP specification focuses on two transports:
| Type | How it works | How authentication works |
|---|---|---|
| stdio | The host starts a local process and talks to it over standard input and output | Do not use the MCP OAuth flow. Pass any required keys through environment variables or similar |
| Streamable HTTP | The host connects over HTTP to a remote server, or to an HTTP endpoint you run locally | Bearer tokens, API keys, custom headers, or OAuth. MCP recommends OAuth |
stdio suits tools that need direct access to your machine, such as the filesystem or local commands. Remote HTTP suits endpoints that a service hosts, such as GitHub or Notion.
Two footnotes are worth keeping in mind:
- Some clients can still connect to older SSE endpoints. Claude Code's documentation marks the SSE transport as deprecated and tells you to use HTTP when it is available.
- OAuth in the MCP specification is for HTTP-based transports. A stdio server should not use that flow; it should take credentials from the environment.
When a server needs a key, it is safer not to put the value itself in a config file or a command that will be stored in shell history. Leave only the variable name in the config: --env or ${API_KEY} in Claude Code, env_vars or bearer_token_env_var in Codex, and ${env:API_KEY} in Cursor.
Adding a server in Claude Code
In Claude Code, the basic command is claude mcp add. Where the configuration is stored depends on the scope.
| Scope | Loads in | Shared with the team | Stored in |
|---|---|---|---|
| local (default) | The current project only | No |
~/.claude.json, under that project's entry |
| project | The current project only | Yes, through version control |
.mcp.json at the project root |
| user | All of your projects | No | ~/.claude.json |
Local scope is stored in ~/.claude.json in your home directory. That is not the same file as .claude/settings.local.json inside a project. On Windows, when official docs write ~, they mean a path under your user profile directory.
Remote HTTP servers
claude mcp add --transport http <name> <url>
# Example
claude mcp add --transport http notion https://mcp.notion.com/mcp
# Passing a bearer token in a header (placeholder value)
claude mcp add --transport http secure-api https://api.example.com/mcp --header "Authorization: Bearer YOUR_TOKEN"
In JSON, set type to http. streamable-http is accepted as an alias for http. An entry that has a url but no type is read as a stdio server and fails.
If a service still exposes only SSE, use --transport sse. From Claude Code v2.1.265, a server added with --transport http may fall back to SSE if the server does not accept HTTP. The docs still recommend HTTP when it is available.
Local stdio servers
For stdio servers, separate Claude Code's own options from the command that starts the server with --. Everything after -- is passed to the server command unchanged.
claude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable -- npx -y airtable-mcp-server
If the server name comes immediately after --env, the CLI reads the name as another KEY=value pair and rejects it. Put another option, such as --transport stdio, between --env and the server name.
Claude Code sets CLAUDE_PROJECT_DIR in the spawned server's environment. If you reference that variable with ${VAR} expansion in a project .mcp.json or in a local- or user-scoped entry in ~/.claude.json, you need a default such as ${CLAUDE_PROJECT_DIR:-.}.
Choosing a scope
# Current project, private to you (default)
claude mcp add --transport http stripe https://mcp.stripe.com
# Write a shared .mcp.json for the team
claude mcp add --transport http shared-server --scope project https://example.com/mcp
# Available in all of your projects
claude mcp add --transport http hubspot --scope user https://mcp.hubspot.com/anthropic
If the same server name exists in more than one scope, Claude Code does not merge the entries. It uses the entire definition from the highest-precedence source. Precedence is local, then project, then user.
Project-scoped servers from .mcp.json require approval in an interactive session. To reset those choices, run claude mcp reset-project-choices. In a freshly cloned repository, approvals committed in the repo may not apply until you trust the workspace.
Do not hardcode secrets in .mcp.json
In a shared .mcp.json, reference environment variables instead of writing the token itself.
{
"mcpServers": {
"api-server": {
"type": "http",
"url": "${API_BASE_URL:-https://api.example.com}/mcp",
"headers": {
"Authorization": "Bearer ${API_KEY}"
}
}
}
}
${VAR} expands to the value of VAR. ${VAR:-default} uses default when VAR is unset. A variable set to an empty string counts as set, so the default is not used.
One more caveat: in a remote server's url or headers, Claude Code leaves certain credential variable names empty instead of expanding them. That includes names such as ANTHROPIC_API_KEY, AWS_BEARER_TOKEN_BEDROCK, and NPM_TOKEN. Copy the value into a variable with a name of your own, then reference that name.
If you are adapting an mcpServers block written for another client, pass claude mcp add-json <name> '<the inner object>' the object inside mcpServers, not the wrapper.
Adding a server in Codex CLI
Codex stores MCP configuration in config.toml. The default is the user-level file ~/.codex/config.toml. You can also scope servers to a trusted project with .codex/config.toml. The ChatGPT desktop app, Codex CLI, and the IDE extension share this host configuration.
Adding a server with the CLI
# stdio
codex mcp add <server-name> --env VAR1=VALUE1 --env VAR2=VALUE2 -- <stdio server-command>
# Example
codex mcp add context7 -- npx -y @upstash/context7-mcp
# Remote HTTP, with an OAuth client ID
codex mcp add example --url https://mcp.example.com --oauth-client-id my-client
For a server that supports OAuth, run codex mcp login <server-name>. In a terminal without a local browser, use codex mcp login <server-name> --no-browser, open the printed authorization URL, and paste the full redirect URL back into the terminal. OAuth login is for Streamable HTTP servers.
Writing config.toml
A stdio example, forwarding a token from the environment instead of hardcoding it:
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
env_vars = ["LOCAL_TOKEN"]
[mcp_servers.context7.env]
MY_ENV_VAR = "MY_ENV_VALUE"
A Streamable HTTP example. The bearer token is specified by environment variable name, not by the value itself:
[mcp_servers.figma]
url = "https://mcp.figma.com/mcp"
bearer_token_env_var = "FIGMA_OAUTH_TOKEN"
http_headers = { "X-Figma-Region" = "us-east-1" }
The fields I use most often are:
- stdio:
command(required),args,env,env_vars,cwd - HTTP:
url(required),bearer_token_env_var,http_headers,env_http_headers,auth(oauthis the default) - Optional for either:
enabled,startup_timeout_sec(default 10 seconds),tool_timeout_sec,enabled_tools,disabled_tools
If you pass an OAuth client secret to codex mcp add, Codex saves it as mcp_servers.<name>.oauth.client_secret in config.toml. Keep that file private and out of version control.
Adding a server in Cursor
In Cursor, you can add a server from the Customize page or by writing mcp.json. Cursor supports stdio, SSE, and Streamable HTTP. Remote servers can also use OAuth.
| Location | Use |
|---|---|
.cursor/mcp.json in the project |
Project-specific. Commit it if you want teammates to get the same servers |
~/.cursor/mcp.json in your home directory |
Available in every project you open in the editor or CLI |
The two files are merged. If the same server name appears in both, the project entry wins. Hosted Cloud Agents do not read ~/.cursor/mcp.json on your machine.
stdio and remote examples
{
"mcpServers": {
"server-name": {
"command": "npx",
"args": ["-y", "mcp-server"],
"env": {
"API_KEY": "${env:API_KEY}"
}
}
}
}
{
"mcpServers": {
"server-name": {
"url": "https://mcp.example.com/mcp",
"headers": {
"Authorization": "Bearer ${env:MY_SERVICE_TOKEN}"
}
}
}
}
Cursor expands variables in command, args, env, url, and headers, including ${env:NAME}. Keep secrets out of the file and read them from your shell or system environment. envFile is available only for stdio servers, not for remote HTTP or SSE servers.
After you save the file, restart Cursor. The official docs also recommend environment variables for secrets, least privilege for keys, and local stdio for sensitive servers.
How to check that a server is connected
Adding a server does not by itself mean it connected. Check the status in each client.
Claude Code
claude mcp list
claude mcp get notion
Inside a session, you can also run /mcp. An Added ... line from claude mcp add only means the configuration was written. Use the status afterwards to see whether the server actually connected.
claude mcp list reports connection results such as ✔ Connected, ! Needs authentication, or ✘ Failed to connect. These other statuses describe a configuration state, not a connection attempt:
-
⏸ Pending approval (run claude to approve): a project-scoped server from.mcp.jsonthat you have not approved yet -
⊘ Disabled for this project (re-enable via /mcp): disabled for this project; you can turn it back on from/mcp -
✘ Rejectedor a policy block: refused by settings or by an organization policy
If you see ⏸ Pending approval, start claude interactively in that project and accept workspace trust and the server approval. If a remote server needs authentication, complete OAuth from /mcp or with claude mcp login <name>. Use claude mcp login <name> --no-browser when no local browser is available.
If you want the authorization server to revoke tokens before you delete the server, run claude mcp logout <name> first. claude mcp remove deletes the tokens Claude Code stored; it does not revoke them at the issuer.
Codex CLI
codex mcp list
codex mcp --help
In the TUI, /mcp shows the servers that are active. After codex mcp login <server-name> for an OAuth server, check the list again.
Cursor
Restart Cursor after you save the configuration. The Customize page shows whether a server is enabled and whether it needs an OAuth sign-in. You can also toggle a server off temporarily there. If a connection fails, open the Output panel, choose "MCP Logs", and look for connection errors, authentication failures, or server crashes.
Pitfalls
These are the mismatches I watch for.
The server is configured but does not connect
- A Claude Code
.mcp.jsonentry has aurlbut notype, so it is read as a stdio server and fails - A project-scoped server is still pending approval (
⏸ Pending approval) - You saved Cursor's
mcp.jsonbut have not restarted Cursor - The command that starts a stdio server (
npxorpython) is not on the PATH in that environment - You set an environment variable only in the current session, so the agent or another window cannot see it. In Windows PowerShell,
$Env:API_KEY = "YOUR_KEY"lasts only for the current process - A Claude Code remote entry references a reserved credential variable such as
${ANTHROPIC_API_KEY}, which is expanded to empty - The same server name exists in more than one scope, and a definition you did not intend is the one that loads. Claude Code warns about the conflict in
claude mcp listand/mcp
How you pass a key
Do not commit the key itself in a shared config file. Use ${API_KEY} in Claude Code's .mcp.json, ${env:API_KEY} in Cursor, and bearer_token_env_var or env_vars in Codex, and keep the value in the environment. Putting the value on the command line can leave it in shell history.
Windows-specific friction
Much of the official documentation uses bash examples. In PowerShell, use $Env:API_KEY = "..." instead of export API_KEY=.... A session-only variable is a common reason Claude Code or Cursor, started from another terminal, cannot see the key.
Home-directory config files (~/.claude.json, ~/.codex/config.toml, ~/.cursor/mcp.json) live under your user profile on Windows. If you type a path by hand, check the home directory of the environment you are actually using.
A stdio MCP server is started directly by the host. If npx works in your terminal but the server fails to start, look at the PATH the agent process sees. That part varies by environment, so I rely on each client's logs: /mcp or claude mcp get in Claude Code, MCP Logs in Cursor, and codex mcp list in Codex.
Official documentation I used
- MCP Architecture overview
- MCP Authorization
- Connect Claude Code to tools via MCP
- Codex: Model Context Protocol
- Codex configuration reference
- Cursor: Model Context Protocol (MCP)
Closing
When I connect an MCP server, I check three things: the transport (stdio or HTTP), the scope (this project or every project), and whether the client actually reports a successful connection. On Windows, using Claude Code, Codex, and Cursor side by side, the easy mistake is mixing up config-file locations and the environment in which a variable is visible. I look at those first.
If a step is wrong or the docs have changed, follow the official documentation.
Top comments (0)