Skip to main content

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.

RecipeDraftView source
This page is a draft. The code exists, and not all of it has been run for this page yet. The page says what was checked.
Works with
MCP clients

What it shows​

  1. You add the address of your MCP server to the coding agent.
  2. The agent calls the server, receives the 401 challenge, and reads the metadata of the server. The metadata names your organization as the authorization server.
  3. The agent identifies itself: with the client ID of an application that you created, or with its client metadata document, which needs no registration.
  4. The browser opens on the sign-in page of your organization, and then on the consent screen.
  5. 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/callback and 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.
VariableValue
LUMOAUTH_URLThe address of LumoAuth: https://app.lumoauth.dev, or https://eu.app.lumoauth.dev for the EU region.
LUMOAUTH_ORG_IDYour organization, for example acme-corp.
LUMOAUTH_API_KEYFor 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

  1. 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
  2. Run claude mcp login invoices. Your browser opens. Sign in and approve.

  3. Run claude mcp list. The server invoices shows 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

  1. Add the server to .cursor/mcp.json in your project:

    { "mcpServers": { "invoices": { "url": "http://localhost:3000/mcp" } } }
  2. When Cursor connects to the server, sign in and approve in the browser.

VS Code

  1. Add the server to .vscode/mcp.json:

    { "servers": { "invoices": { "type": "http", "url": "http://localhost:3000/mcp" } } }
  2. 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_denied with "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. localhost and 127.0.0.1 count 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.