|
1 | 1 | --- |
2 | 2 | title: Deployment Auth |
3 | 3 | sidebarTitle: "Deployment Auth" |
4 | | -description: "Configure authentication for deployed agents (--no-auth, bearer token, OAuth)" |
| 4 | +description: "Configure authentication for deployed MCP servers" |
5 | 5 | icon: key |
6 | 6 | --- |
7 | 7 |
|
8 | | -<Info> |
9 | | -Content on --no-auth flag, bearer token authentication, and OAuth for deployments. |
10 | | -</Info> |
| 8 | +Every deployment needs an explicit stance on who can call its tools. This page covers the options supported today and what’s coming next. |
11 | 9 |
|
12 | | -## Deployment Authentication Options |
| 10 | +## 1. Bearer token authentication (default) |
13 | 11 |
|
14 | | -- **--no-auth** - Deploy without authentication (development only) |
15 | | -- **Bearer Token** - Simple token-based authentication |
16 | | -- **OAuth** - Full OAuth 2.1 authentication flows |
| 12 | +- Each user runs `mcp-agent login` to obtain an API key (`lm_mcp_api_*`). |
| 13 | +- Keys are stored locally (`~/.config/mcp-agent/credentials.json`) and can also be provided via the `MCP_API_KEY` environment variable (CI, containers). |
| 14 | +- Clients include the key in the `Authorization: Bearer <token>` header. |
| 15 | +- Deployments validate the token before executing requests. |
| 16 | + |
| 17 | +### Share instructions with users |
| 18 | + |
| 19 | +``` |
| 20 | +1. Install mcp-agent (uv tool install mcp-agent) |
| 21 | +2. Run mcp-agent login and follow the browser prompts |
| 22 | +3. Configure the client (mcp-agent install ... --client claude_desktop) |
| 23 | +``` |
| 24 | + |
| 25 | +### Rotate or revoke |
| 26 | + |
| 27 | +- Re-run `mcp-agent login` to issue a new key (old keys will stop working). |
| 28 | +- Delete the key file to force re-authentication. |
| 29 | +- Per-user revocation UI is on the roadmap; in the interim contact support if a key is compromised. |
| 30 | + |
| 31 | +### CLI recap |
17 | 32 |
|
18 | 33 | ```bash |
19 | | -# Deploy with OAuth |
20 | | -mcp-agent deploy my-agent --auth oauth |
| 34 | +mcp-agent login # browser flow |
| 35 | +mcp-agent cloud auth whoami # confirm identity |
| 36 | +mcp-agent install <url> --client cursor # writes config with Authorization header |
| 37 | +``` |
| 38 | + |
| 39 | +## 2. Unauthenticated access (`--no-auth`) |
21 | 40 |
|
22 | | -# Deploy with bearer token |
23 | | -mcp-agent deploy my-agent --auth bearer |
| 41 | +Use this mode for public servers, demos, or ChatGPT Apps (which cannot provide custom headers). |
24 | 42 |
|
25 | | -# Deploy without auth (not recommended) |
26 | | -mcp-agent deploy my-agent --no-auth |
| 43 | +```bash |
| 44 | +mcp-agent deploy blog-tools --no-auth |
27 | 45 | ``` |
| 46 | + |
| 47 | +- Anyone with the server URL can call it. |
| 48 | +- Logs still capture caller metadata (IP, user agent) for monitoring. |
| 49 | +- You can re-enable auth later: |
| 50 | + |
| 51 | + ```bash |
| 52 | + mcp-agent deploy blog-tools --auth |
| 53 | + ``` |
| 54 | + |
| 55 | + (`--auth` toggles `unauthenticatedAccess` back to false.) |
| 56 | + |
| 57 | +> For apps deployed without auth, consider rate limiting or requiring custom user-provided secrets to avoid abuse. |
| 58 | +
|
| 59 | +## 3. OAuth 2.1 (coming soon, preview) |
| 60 | + |
| 61 | +The upcoming release implements the MCP OAuth specification across three surfaces: |
| 62 | + |
| 63 | +1. **Authorization server** (control plane) |
| 64 | + - Metadata endpoint: `/.well-known/oauth-authorization-server` |
| 65 | + - Supports Google + GitHub providers initially |
| 66 | + - Issues access & refresh tokens |
| 67 | +2. **Resource server** (your deployment) |
| 68 | + - Implements `/.well-known/oauth-protected-resource` (RFC 9728) |
| 69 | + - Validates JWTs or proxies to token introspection |
| 70 | + - Allows per-scope access control (e.g., `read`, `write`, `admin`) |
| 71 | +3. **Client tooling** |
| 72 | + - `mcp-agent install` and `mcp-agent cloud configure` will drive the auth flow for supported clients (browser-based loopback or device code). |
| 73 | + |
| 74 | +Keep an eye on release notes for timelines. The migration will be additive—existing bearer-token flows continue to work. |
| 75 | + |
| 76 | +## 4. Combining with secrets management |
| 77 | + |
| 78 | +- Store long-lived service credentials in `mcp_agent.secrets.yaml` as deployment secrets; the runtime injects them securely. |
| 79 | +- Ask end-users for their own credentials via `mcp-agent cloud configure` (user secrets). You can enforce domain restrictions or other policies in code when processing those secrets. |
| 80 | + |
| 81 | +## 5. Security best practices |
| 82 | + |
| 83 | +<AccordionGroup> |
| 84 | + <Accordion title="Least privilege"> |
| 85 | + Only expose tools/resources that need to be public. For internal deployments, keep `--auth` enabled and share API keys via secure channels. |
| 86 | + </Accordion> |
| 87 | + <Accordion title="Audit logs"> |
| 88 | + The platform records every API call (user, timestamp, tool, outcome). A user-facing audit surface is planned—ask the team if you need access before it ships. |
| 89 | + </Accordion> |
| 90 | + <Accordion title="Secret rotation"> |
| 91 | + Rotate provider API keys regularly. Redeploy with updated secrets; the CLI invalidates old handles automatically. |
| 92 | + </Accordion> |
| 93 | + <Accordion title="Client distribution"> |
| 94 | + Provide install scripts (`mcp-agent install`) rather than asking users to edit config files manually. This reduces the risk of misconfigured auth headers. |
| 95 | + </Accordion> |
| 96 | +</AccordionGroup> |
| 97 | + |
| 98 | +## References |
| 99 | + |
| 100 | +- [Authentication overview →](/deployment/authentication/overview) |
| 101 | +- [External MCP server auth (downstream credentials) →](/deployment/authentication/external-mcp-auth) |
| 102 | +- [Secrets management →](/deployment/mcp-agent-cloud/manage-secrets) |
0 commit comments