Manage your organization from a coding agent
Connect a coding agent to the LumoAuth MCP server, and create an application, a role or an agent by asking for it.
What it shows
- You add
https://app.lumoauth.dev/mcpto a coding agent. Organizations in the EU region usehttps://eu.app.lumoauth.dev/mcp. - You choose your organization, sign in, and choose the access for each area: None, Read or Read and change.
- The agent calls
whoami, and tells you which organization it reached before it changes anything. - You ask for an application, and the agent creates it and writes the client ID into your
.envfile. - A change in an area with read access only is refused, and every call is in the audit log.
Before you start
- An account that can open the portal of your organization. A connection can never do more than your account can do in the portal.
- A coding agent, or Node.js 20 or later for the check script.
Add the server to your agent. The commands come from the setup page:
| Agent | How to add the server |
|---|---|
| Claude Code | claude mcp add --transport http lumoauth https://app.lumoauth.dev/mcp, then run /mcp in Claude Code and select lumoauth |
| Codex | codex mcp add lumoauth --url https://app.lumoauth.dev/mcp, then codex mcp login lumoauth |
| Cursor | In .cursor/mcp.json: {"mcpServers": {"lumoauth": {"url": "https://app.lumoauth.dev/mcp"}}} |
| VS Code | In .vscode/mcp.json: {"servers": {"lumoauth": {"type": "http", "url": "https://app.lumoauth.dev/mcp"}}} |
Your browser then shows three pages:
- Enter the short name of your organization, from the address of your portal:
acme-corpin/orgs/acme-corp/. Click Continue. - Sign in on the sign-in page of your organization.
- On the page Choose what this application may do, keep Read for the areas that the agent may look at. Choose Read and change for Applications. Click Authorize.
Then ask the agent, for example: "Which organization are you connected to?", and then "Create a public application named Northwind storefront with the redirect URI http://localhost:3000/auth/callback, and put its client ID into .env.local as LUMOAUTH_CLIENT_ID."
Optional: the agent skill lumoauth-mcp-management holds these steps for a coding agent. Install it with npx skills add lumoauth/agent-skills --skill lumoauth-mcp-management.
| Variable | Value |
|---|---|
LUMOAUTH_URL | https://app.lumoauth.dev for the US region, or https://eu.app.lumoauth.dev for the EU region. The program adds /mcp. |
MCP_CLIENT_REDIRECT_URI | Optional. The local address that the browser returns to. The default is http://localhost:8765/callback. |
Code
The check script does what a coding agent does, without a model. Use it to check a connection. It registers itself, signs you in with PKCE, and calls the tools whoami, list_applications, create_application and create_role.
Run each command from the recipes folder of the examples repository. Set the folder up once for your language. Every version below was run against a LumoAuth organization. The check script ran against an organization, and an administrator signed in and chose the access in a headless browser. The coding agents were not run: their settings on this page come from the LumoAuth documentation.
- Check script
// Does what a coding agent does with the LumoAuth MCP server: it registers,
// signs you in, and calls tools. Use it to check a connection without an agent.
//
// node mcp-clients/manage-lumoauth-from-an-agent/js/check.mjs
//
// The program prints an address. Open it in a browser, choose your
// organization, sign in, and give Applications the access "Read and change".
import http from 'node:http';
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { auth } from '@modelcontextprotocol/sdk/client/auth.js';
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
// One address for each region: https://eu.app.lumoauth.dev/mcp for the EU.
const serverUrl = `${(process.env.LUMOAUTH_URL ?? 'https://app.lumoauth.dev').replace(/\/+$/, '')}/mcp`;
const redirectUri = process.env.MCP_CLIENT_REDIRECT_URI ?? 'http://localhost:8765/callback';
// The browser comes back to this address with the code.
let deliverCode;
const callback = http.createServer((req, res) => {
const url = new URL(req.url, redirectUri);
if (url.pathname !== new URL(redirectUri).pathname) return res.writeHead(404).end();
res.end('You can close this window.');
deliverCode(url.searchParams.get('code'));
});
callback.listen(Number(new URL(redirectUri).port));
const code = new Promise((resolve) => (deliverCode = resolve));
// The MCP SDK registers the client, runs the authorization code flow with
// PKCE, and keeps the tokens. This client keeps everything in memory.
let clientInformation;
let tokens;
let codeVerifier;
const provider = {
redirectUrl: redirectUri,
clientMetadata: {
client_name: 'Organization check script',
redirect_uris: [redirectUri],
grant_types: ['authorization_code', 'refresh_token'],
response_types: ['code'],
token_endpoint_auth_method: 'none',
},
clientInformation: () => clientInformation,
saveClientInformation: (info) => (clientInformation = info),
tokens: () => tokens,
saveTokens: (saved) => (tokens = saved),
saveCodeVerifier: (verifier) => (codeVerifier = verifier),
codeVerifier: () => codeVerifier,
redirectToAuthorization: (url) => console.log(`sign in: open ${url}`),
};
// 1. Ask for read access everywhere, and for changes to applications.
const scope = [
...['users', 'groups', 'roles', 'permissions', 'clients', 'agents', 'webhooks', 'audit'].map((area) => `manage:${area}:read`),
'manage:clients:write',
].join(' ');
if ((await auth(provider, { serverUrl, scope })) === 'REDIRECT') {
await auth(provider, { serverUrl, authorizationCode: await code });
}
callback.close();
console.log(`access: ${tokens.scope}`);
const client = new Client({ name: 'organization-check', version: '1.0.0' });
await client.connect(
new StreamableHTTPClientTransport(new URL(serverUrl), {
requestInit: { headers: { Authorization: `Bearer ${tokens.access_token}` } },
}),
);
const call = async (name, args = {}) => (await client.callTool({ name, arguments: args })).structuredContent;
// 2. whoami names the organization and the person. Check them before a change.
const me = await call('whoami');
console.log(`organization: ${me.organization.name} (${me.organization.address}), as ${me.user?.email}`);
console.log(`tools: ${(await client.listTools()).tools.length}`);
// 3. Find the application, or create it, and print the setting for the .env file.
const name = 'Northwind storefront';
const found = await call('list_applications', { search: name });
let app = (found.data ?? found.items ?? []).find((a) => a.name === name);
if (!app) {
app = await call('create_application', {
name,
redirectUris: ['http://localhost:3000/auth/callback'],
isConfidential: false,
});
app = app.data ?? app;
}
console.log(`application: ${app.name}`);
console.log(`LUMOAUTH_CLIENT_ID=${app.clientId}`);
// 4. Roles have read access only, so a change is refused.
try {
await call('create_role', { name: 'Storefront manager' });
console.log('create_role: allowed');
} catch (error) {
console.log(`create_role: refused (${error.code ?? error.message})`);
}
await client.close();
node mcp-clients/manage-lumoauth-from-an-agent/js/check.mjs
Check the result
sign in: open https://app.lumoauth.dev/mcp/oauth/authorize?response_type=code&client_id=mcpc_5b1ba8883344aff0463a94e51ef712f8&…
access: manage:users:read manage:groups:read manage:roles:read manage:permissions:read manage:clients:read manage:agents:read manage:webhooks:read manage:audit:read manage:clients:write
organization: Acme Corp (acme-corp), as avery.stone@example.com
tools: 38
application: Northwind storefront
LUMOAUTH_CLIENT_ID=client_5283981e4cfc0be9e4a5930accfaeeca
create_role: refused (403)
access:lists the scopes that you gave on the page of areas, one for each area:manage:clients:writeis Read and change for Applications.tools:counts only the tools that your access and your permissions allow.create_roleis refused with403, because Roles has read access only.- The new application is in the portal under Applications. A second run finds it and creates no copy.
- In the portal, Applications, MCP connections lists the connection, the person who made it and the access.
- Audit logs lists each call as
mcp.management.tool_call, with your account as the actor and the tool as the target. The refused call has the statusfailure.
Limits
- The server cannot set a password, change an email address or change sign-in settings. A new user chooses a password from the password reset email.
- Billing, signing keys, custom domains and GDPR requests stay in the portal.
- A connection belongs to one organization. For a second organization, add the server again under another name.
- To change the access, connect again and choose again. The new choice replaces the old one.
- Each run of the check script registers a new client, and the portal keeps each one in MCP connections. A connection cannot be deleted: Disconnect the ones that you no longer use.