Sub topic 12
Remote servers and authorization
This chapter assumes you know the host, client and server roles, the stdio and Streamable HTTP transports, and how to edit the mcpServers configuration. It covers what changes when a server runs somewhere other than your own machine.
Why remote servers differ from local ones
A local stdio server is a child process of your assistant. It runs with your permissions, and the operating system keeps other machines away from it. Nobody else can reach it, so it needs no login.
A remote server is a web service reached over Streamable HTTP. Several users may share it, and anyone on the network can try to call it. The server must therefore answer two questions for every request: who is calling, and what are they allowed to do.
| Property | Local (stdio) | Remote (Streamable HTTP) |
|---|---|---|
| Who starts it | The assistant | A service operator |
| Where it runs | Your machine | A host on the network |
| Credentials | Passed through `env` | Sent with each HTTP request |
| Who can reach it | Only the parent process | Anyone who can reach the URL |
| Updates | You install them | The operator ships them |
Configuring a remote server
Many assistants accept a url instead of a command. The field names vary between assistants, so check your assistant's documentation. A common shape looks like this:
{
"mcpServers": {
"issue-tracker": {
"url": "https://mcp.example.com/mcp"
}
}
}The client sends each JSON-RPC message as an HTTP POST to that URL. The server may reply with a plain JSON body or with a stream of events, which lets it send progress messages before the final result.
How authorization works
The MCP specification builds its authorization for HTTP transports on OAuth 2.1. You do not need to implement OAuth to use a remote server, but you should recognize the steps.
- The client calls the server without a token. The server answers
401 Unauthorizedand says where to find its authorization details. - The client reads those details and finds the authorization server that issues tokens.
- The assistant opens your browser. You sign in and approve the access the server asks for.
- The client receives an access token and sends it in an
Authorization: Bearerheader on every later request. - The server checks the token. It rejects the call if the token is expired, was issued for a different server, or lacks the needed scope.
A scope is a named permission, such as read-only access to issues. Approve the narrowest scopes that do the job.
Some servers accept a static API key in a header instead of the OAuth flow. This is simpler, but the key does not expire on its own and cannot be limited as precisely.
Common errors
- Repeated 401 responses. The token expired or the sign-in never finished. Reconnect the server so the assistant restarts the flow.
- 403 Forbidden. You signed in, but your account or the granted scope does not allow the tool. Request the right scope or ask the operator for access.
- Connection works in a browser but not in the assistant. A corporate proxy or firewall may block long-lived streaming responses.
- Trusting a server because it uses HTTPS. HTTPS protects the connection. It says nothing about whether the operator is trustworthy or what its tools do with your data.
Trust and scope
A remote server sees every argument you send to its tools, and its answers go straight into the model's context. Before connecting, check who operates it, what data your prompts could send to it, and whether the tokens it asks for are broader than the task needs. The security chapter's concerns about prompt injection apply here too, and they matter more because you do not control the code.
Exercise
A remote server returns 401 on the first request, and after you sign in, a later call to one tool returns 403. What does each status tell you, and what do you do about the 403?
Show answer
The 401 means the request had no valid token, which is the normal start of the OAuth flow. The 403 means the token is valid but does not permit that tool. Check which scopes you approved, then reconnect and grant the extra scope if the tool is one you need and trust. Otherwise leave it blocked.
Exercise
Why is a local stdio server usually configured with an env token, while a remote server uses a bearer token sent per request?
Show answer
A stdio server is a private child process, so the assistant passes it credentials once at launch. A remote server is shared over the network and cannot rely on a private process boundary, so it must check a credential on every HTTP request.