Connect Claude Code, Cursor or VS Code
Point a coding agent at your protected MCP server. It finds LumoAuth, signs the person in, and calls the tools.
What it shows
- You add the address of your MCP server to the coding agent.
- The agent calls the server, receives the
401challenge, and reads the metadata of the server. The metadata names your organization as the authorization server. - The agent identifies itself: with the client ID of an application that you created, or with its client metadata document, which needs no registration.
- The browser opens on the sign-in page of your organization, and then on the consent screen.
- The agent lists the tools and calls them, with a token for this server only.
Before you start
- A protected MCP server from the recipes in the group before this one, for example Protect a server built on the MCP TypeScript SDK. Start it, and keep it running. It listens on
http://localhost:3000/mcp. - A public application for the agent, with the redirect URI
http://localhost:8765/callbackand the scopes of the server. The setup script creates "Local MCP client". It also registers the server if the registration is missing. - A user who can sign in to your organization.
| Variable | Value |
|---|---|
LUMOAUTH_URL | The address of LumoAuth: https://app.lumoauth.dev, or https://eu.app.lumoauth.dev for the EU region. |
LUMOAUTH_ORG_ID | Your organization, for example acme-corp. |
LUMOAUTH_API_KEY | For the setup script only: an API key with the scopes admin:agents:read, admin:agents:write, admin:clients:read and admin:clients:write. |
The setup script creates what the recipe needs, through the Admin API. You can run it again at any time.
node mcp-clients/connect-a-coding-agent/setup.mjs
setup.mjs
// Creates what the recipe needs: the registration of the MCP server, and a
// public application for the MCP client. Run it again at any time.
//
// node mcp-clients/connect-a-coding-agent/setup.mjs
//
// The API key needs the scopes admin:agents:read, admin:agents:write,
// admin:clients:read and admin:clients:write.
import { ensure, printEnv } from '../../_lib/admin.mjs';
// The resource URI is the exact address that clients connect to.
const resource = process.env.MCP_RESOURCE_URI ?? 'http://localhost:3000/mcp';
const server = await ensure('/admin/mcp/servers', (s) => s.resource_uri === resource, {
name: 'Invoices',
description: 'Reads and refunds invoices.',
resource_uri: resource,
endpoint_url: resource,
scopes_supported: ['invoices:read', 'invoices:refund'],
// The challenge names only the basic scopes. The client asks for
// invoices:refund when a tool needs it.
basic_scopes: ['invoices:read'],
// Coding agents send plain bearer tokens.
require_dpop: false,
});
// The coding agent uses a public application: no secret, and PKCE. Its
// list of scopes must hold every scope that it may ever ask for.
const redirectUri = process.env.MCP_CLIENT_REDIRECT_URI ?? 'http://localhost:8765/callback';
const client = await ensure('/admin/clients', (c) => c.name === 'Local MCP client', {
name: 'Local MCP client',
isConfidential: false,
redirectUris: [redirectUri],
scopes: ['openid', 'profile', 'email', 'offline_access', 'invoices:read', 'invoices:refund'],
});
console.log(`MCP server ${server.name} (${server.resource_uri}) and the application "${client.name}" are ready.`);
printEnv({ MCP_CLIENT_ID: client.clientId });
Connect the agent
Use the client ID that the setup script printed. The commands come from the package guide and from the page of the server in the portal.
Claude Code
-
Add the server with the client ID and a fixed callback port:
claude mcp add --transport http --client-id "$MCP_CLIENT_ID" --callback-port 8765 invoices http://localhost:3000/mcp -
Run
claude mcp login invoices. Your browser opens. Sign in and approve. -
Run
claude mcp list. The serverinvoicesshows as connected.
Without --client-id, Claude identifies itself with its client metadata document, and you need no application. The page of the server in the portal shows that form under Discovery and client setup.
Cursor
-
Add the server to
.cursor/mcp.jsonin your project:{ "mcpServers": { "invoices": { "url": "http://localhost:3000/mcp" } } } -
When Cursor connects to the server, sign in and approve in the browser.
VS Code
-
Add the server to
.vscode/mcp.json:{ "servers": { "invoices": { "type": "http", "url": "http://localhost:3000/mcp" } } } -
When VS Code connects to the server, sign in and approve in the browser.
Cursor and VS Code get only the address. A client without a client ID must identify itself with a client metadata document, or register itself. Self-registration is off by default for an organization: see Limits.
These steps were written from the docs. Nobody has followed them for this page yet. No coding agent was run: the settings come from the LumoAuth documentation and package guides. The sign-in that a client with a client ID and a fixed callback port makes was checked with the FastMCP client against a protected server: the tools were listed and called, and the person's Authorized apps page listed the application.
Check the result
- Ask the agent to call
whoami. The answer is your user ID: the server read it from the verified token. - Your account lists the agent under Authorized apps, at
https://app.lumoauth.dev/account/consents, with the scopes that you approved. Remove access signs it out. - In the portal, the page of the server under AI Agents, MCP servers shows the same client setup, with the real addresses of your organization.
Limits
- A server that requires DPoP refuses clients that do not send proofs. The package guides name Claude Code among them, so leave Require DPoP sender-constrained tokens off for a server that coding agents must reach.
- A client that registers itself gets
access_deniedwith "Dynamic client registration is not enabled", because self-registration is off by default. Give that client a client ID, as for Claude Code above. - The host of the agent's callback must match the redirect URI of the application.
localhostand127.0.0.1count as different hosts. - An application allows only the scopes in its list. Many clients also ask for
offline_access, so the setup script includes it.