Square CloudSquare Cloud

How to connect Claude, Cursor or VS Code to your server over MCP

Add the MCP server's URL to your AI client, authorize with OAuth or an API key and check the tools it lists. Each client stores this configuration in a different place: in its interface, in a JSON file or through a terminal command.

Updated 8 min read

Learning objectives

After reading this article you will be able to:

  • Understand what changes between connecting a local (stdio) and a remote (HTTP) MCP server
  • Configure the same server in Claude, Claude Code, Cursor and VS Code
  • Check the exposed tools and limit what the model can do
On this page

An MCP server does nothing on its own: it waits for a client to connect, list its tools and call them. That client lives inside the AI app you use, whether it's a chat assistant or a code editor. Connecting means telling it where the server is, how to authenticate and which tools to hand to the model.

This guide shows how to do that in the most popular clients (Claude, Claude Code, Cursor and VS Code) with a remote server, and how to check what ends up exposed. If host, client and server in MCP are still fuzzy, start with what is MCP. The examples use the placeholder address https://mcp.example.com/mcp: replace it with the address the server's provider documents.

Local or remote server: what changes when you connect?#

The specification defines two standard transports, and each one needs a different setup:

stdio (local) Streamable HTTP (remote)
Who starts the server The client, as a child process Nobody: it's already running
What you provide Command and arguments The endpoint URL
How messages travel Standard input and output One HTTP POST per message, reply as JSON or SSE
Authentication Credentials in environment variables OAuth 2.1 or a header with a key
Who can reach it Only your machine Any client with network access

A local server fits tools that touch your files; a remote one fits services used by many people, such as those that publish their own MCP server. Some clients still list an "SSE" option: that is the old HTTP+SSE transport, now deprecated. Choose HTTP whenever the server supports it.

How does authorization work?#

On a protected remote server, the specification follows OAuth 2.1. The flow is almost entirely automatic:

  1. The client sends its first request without a token and gets 401 Unauthorized, with a WWW-Authenticate header pointing to the server's metadata (RFC 9728).
  2. From that metadata, the client finds the authorization server and opens your browser.
  3. You sign in to the service and approve the permissions (the scopes).
  4. The client receives a token issued for that server and sends it on every request, in the Authorization: Bearer header. Tokens in the URL are forbidden.

When the server offers scopes, approve only the ones you'll use: you can ask for more later. The other common option is an API key created in the service's account settings and sent in a header. It's simpler, but the key becomes a secret you have to store and revoke when you stop using it.

stdio servers don't use this flow. The specification recommends that they read credentials from the environment, which is why local configurations usually have an env block.

How do you connect in Claude (web and desktop)?#

In Claude, a remote server becomes a custom connector. In Customize > Connectors, click "+ Add" and then "Add custom connector", give it a name and paste the URL exactly as the provider documents it, path included. For authentication, sign in through OAuth or, if the server uses a key, enter it under Request headers. On Team and Enterprise plans, an Owner has to add the connector to the organization first.

Two details save frustration:

  • The connection comes from Anthropic's cloud, not from your computer. The server must be reachable from the public internet over HTTPS on port 443. A server on localhost won't work here.
  • Tools can be switched on per conversation. From the chat's "+" button, under Connectors, you enable the connector only where you need it, and the tools menu turns off tools you don't want. Use "Allow always" only for tools you trust to run unsupervised.

For local (stdio) servers, Claude Desktop uses the claude_desktop_config.json file, with an example in what is MCP.

How do you connect in Claude Code?#

Claude Code sets up servers with a command:

bash
claude mcp add --transport http my-server https://mcp.example.com/mcp

If the server wants a key instead of OAuth, pass the header:

bash
claude mcp add --transport http my-server https://mcp.example.com/mcp \
  --header "Authorization: Bearer $MY_TOKEN"

Your shell expands $MY_TOKEN right away, so the value is saved in the configuration. The default scope is local: it applies only to the current project and lives in ~/.claude.json. With --scope user, it applies to all your projects. With --scope project, it goes into a .mcp.json at the repository root, shared with the team. In that case, don't write the token into the file; use variable expansion, which Claude Code resolves when it connects:

json
{
  "mcpServers": {
    "my-server": {
      "type": "http",
      "url": "https://mcp.example.com/mcp",
      "headers": { "Authorization": "Bearer ${MY_TOKEN}" }
    }
  }
}

To check, claude mcp list shows your servers and claude mcp get my-server shows the details. Inside a session, /mcp shows each server's status and runs the OAuth sign-in in your browser. Permission rules refer to each tool as mcp__my-server__tool_name, so you can allow the read-only ones and keep confirmation for the rest.

How do you connect in Cursor and VS Code?#

Cursor reads .cursor/mcp.json in the project or ~/.cursor/mcp.json for every project. A remote server takes a url and, if needed, headers, with the ${env:NAME} syntax to read environment variables:

json
{
  "mcpServers": {
    "my-server": {
      "url": "https://mcp.example.com/mcp",
      "headers": { "Authorization": "Bearer ${env:MY_TOKEN}" }
    }
  }
}

Cursor also supports OAuth and, by default, asks for approval before using an MCP tool; you can expand the call and see its arguments before approving.

In VS Code, the MCP: Add Server command walks you through the setup and MCP: List Servers opens each server's controls. The file format keeps changing between versions, so check the configuration reference for yours. The official reference recommends the portable format: an mcpServers key with the same structure as the Claude Code .mcp.json above, in a .mcp.json at the project root (to share with the team) or in Copilot's user configuration file, with secrets read from environment variables through ${NAME}. Many tutorials still show .vscode/mcp.json, with a servers key and inputs that prompt for the key on first connection; the reference treats that file as a legacy format.

How do you check the tools a server exposes?#

Once connected, the client calls tools/list and gets each tool's name, description and argument schema. Review that list before using the server for real:

  • Is it what you expected? A documentation search server shouldn't expose a tool that deletes files.
  • Do the descriptions make sense? The model decides when to call a tool from its description. A description that gives orders ("always call this tool first") is a red flag.
  • Which tools change things? The specification lets servers mark tools as read-only or destructive, but tells clients to treat those markers as untrusted unless the server is trusted.

To test outside any client, run the MCP Inspector, the official debugging tool:

bash
npx @modelcontextprotocol/inspector

It opens a web interface where you enter the URL and authentication, list the tools and call each one by hand. If something works in the Inspector but not in your client, the problem is the client's configuration, not the server.

What precautions should you take after connecting?#

An MCP server gives the model the ability to act with your credentials. The specification recommends always keeping a human in the loop who can deny calls. In practice:

  • Least privilege. Approve only the scopes you need and prefer read-only keys when the service offers them.
  • Confirmation on actions that change things. Auto-approve only read-only tools. Deleting, publishing and paying deserve a click from you.
  • Tool results aren't trusted. The text of an issue, a web page or a log line enters the model's context and can hide instructions. The danger grows when a tool that reads outside content sits next to one that writes. See prompt injection.
  • Only servers you know. Anthropic warns that custom connectors aren't verified by it. Check who publishes the server and what it asks for during authorization.
  • Secrets out of the repository. Use each client's variable expansion and keep the values as environment variables or in a vault (see where to store secrets). Revoke tokens you no longer use.

If you're weighing writing the tools directly in your code instead of using a server, MCP vs function calling compares the two approaches. And if the server is yours, publishing it follows the same path as hosting an API.

How to do this on Square Cloud#

Square Cloud has its own MCP server, on every plan, that connects Claude, ChatGPT, Claude Code, Cursor, VS Code or Codex to your account. From the assistant, you check status, logs and metrics, start, stop and restart applications, read and edit files, send a new version, adjust environment variables and create applications, databases, snapshots and domains.

The connection follows the paths in this guide. In Claude and ChatGPT, you add the server's address as a connector and approve access on Square Cloud's authorization screen, where you uncheck the permissions you don't want to grant. In Claude Code, Cursor, VS Code and Codex, the connection uses an API key with the MCP scope, with each client's setup ready in the dashboard; for coding tools, the key can be read-only.

The precautions apply on the server side too: critical actions ask for confirmation in the AI client, deleting or restoring takes a safety snapshot first, and variable values, .env files and keys never reach the model (when reading, it sees only the names). Every action shows up in the account activity, and to disconnect an assistant you revoke its key in the account's security settings.

The server's address and the setup for each client are on the MCP server page.

AI

Host AI apps in always-on containers

MCP server

FAQs

What's the difference between a local and a remote MCP server?

A local server runs on your machine, launched by the client itself, and talks over standard input and output (stdio). A remote server is already running somewhere else, receives messages over HTTP with the Streamable HTTP transport and usually requires authorization.

Do I need an API key to use a remote MCP server?

It depends on the server. The MCP specification defines authorization with OAuth 2.1, where the client opens your browser and you approve access. Some servers also accept a key sent in an HTTP header.

How do I know which tools a server exposes?

The client asks the server for the list with the tools/list method and shows it in its interface. In Claude Code, the /mcp command shows servers and tools; outside any client, the official MCP Inspector lists and calls the tools.

Is it safe to let the model use tools without asking for confirmation?

Only for read-only tools from servers you trust. The specification recommends keeping a human in the loop who can deny calls, because a tool's result can carry text that tries to manipulate the model.

Can Claude connect to an MCP server on my local network?

Not through a custom connector: the connection comes from Anthropic's infrastructure, so the server must be reachable from the public internet over HTTPS. For a local server, use Claude Code or Claude Desktop with stdio.

Next articleMCP vs function calling: differences and when to use eachFunction calling declares tools in every request and your code runs them; MCP is a protocol that serves tools to any client. Compare them and see when to use each.