lumoauth 0.0.0-stage → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,215 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <a href="https://lumoauth.dev">
4
+ <picture>
5
+ <source media="(prefers-color-scheme: dark)" srcset="https://docs.lumoauth.dev/img/lumoauth-logo-horizontal-reversed.svg">
6
+ <img src="https://docs.lumoauth.dev/img/lumoauth-logo-horizontal.svg" alt="LumoAuth" height="36">
7
+ </picture>
8
+ </a>
9
+
10
+ # npx lumoauth secure
11
+
12
+ **Put sign-in and per-tool access control in front of any MCP server, without changing its code.**
13
+
14
+ [![lumoauth on npm](https://img.shields.io/badge/npm-lumoauth-111)](https://www.npmjs.com/package/lumoauth)
15
+ [![Node 20+](https://img.shields.io/badge/node-20%2B-111)](https://nodejs.org)
16
+ [![HTTP and stdio](https://img.shields.io/badge/servers-HTTP%20%C2%B7%20stdio-111)](#what-it-does)
17
+ [![License: MIT](https://img.shields.io/badge/license-MIT-111)](#license)
18
+
19
+ [Quick start](#quick-start) · [What it does](#what-it-does) · [Per-tool policy](#per-tool-policy) · [Options](#options) · [Troubleshooting](#troubleshooting) · [Docs](https://docs.lumoauth.dev/mcp/)
20
+
21
+ </div>
22
+
23
+ ---
24
+
25
+ ```bash
26
+ # An HTTP MCP server that you already run on port 8000
27
+ npx lumoauth secure --upstream http://127.0.0.1:8000/mcp
28
+
29
+ # Start the server too, and wait until it listens
30
+ npx lumoauth secure --upstream http://127.0.0.1:8000/mcp -- python server.py
31
+
32
+ # A stdio MCP server, served over HTTP behind LumoAuth
33
+ npx lumoauth secure --stdio -- npx -y @modelcontextprotocol/server-everything
34
+ ```
35
+
36
+ [LumoAuth](https://lumoauth.dev) signs users in and issues the tokens. `lumoauth` checks each token before anything reaches your server. It works with a server in any language. Building with the official TypeScript SDK? [`@lumoauth/mcp`](https://www.npmjs.com/package/@lumoauth/mcp) does the same inside your code.
37
+
38
+ ## Quick start
39
+
40
+ You need Node 20 or later and a LumoAuth organization. [Create an organization](https://app.lumoauth.dev/register) if you do not have one yet.
41
+
42
+ ### 1. Register your server
43
+
44
+ In the LumoAuth portal:
45
+
46
+ 1. Open **AI Agents → MCP servers** and click **Register MCP server**.
47
+ 2. Set **Server name** to `Invoices` and **Resource URI** to `http://localhost:8080/mcp`. This is the address of `lumoauth`, not of your server. Keep the **Streamable HTTP** transport, also for a stdio server.
48
+ 3. Click **Next** twice, then click **Register MCP server**.
49
+ 4. On the server's page, click **Edit**, then **Next**. Make two changes:
50
+ - Under **Scopes**, click **Use defaults**.
51
+ - Switch off **Require DPoP sender-constrained tokens**. Claude Code does not send DPoP proofs, so it cannot connect while this switch is on.
52
+ 5. Click **Next**, then **Save changes**. Copy the **Server id** (`mcp_…`) from the top of the page.
53
+
54
+ ### 2. Put it in front of your server
55
+
56
+ Use your organization's slug and the server id from step 1. The slug is the part after `/orgs/` in the portal's URL.
57
+
58
+ ```bash
59
+ export LUMOAUTH_ORG_ID=acme
60
+ export LUMOAUTH_MCP_SERVER_ID=mcp_0123456789abcdef01234567
61
+
62
+ npx lumoauth secure --upstream http://127.0.0.1:8000/mcp
63
+ ```
64
+
65
+ `lumoauth` prints what it protects and where it runs:
66
+
67
+ ```console
68
+ lumoauth: http://127.0.0.1:8000/mcp is protected by LumoAuth
69
+ listening http://0.0.0.0:8080/mcp
70
+ resource http://localhost:8080/mcp
71
+ issuer https://app.lumoauth.dev/orgs/acme/api/v1
72
+ discovery http://localhost:8080/.well-known/oauth-protected-resource/mcp
73
+ tool policy off
74
+ ```
75
+
76
+ No MCP server yet? Use `--stdio -- npx -y @modelcontextprotocol/server-everything` in place of `--upstream` and its URL.
77
+
78
+ For the EU region, also set `LUMOAUTH_URL=https://eu.app.lumoauth.dev`.
79
+
80
+ ### 3. Call it without a token
81
+
82
+ ```console
83
+ $ curl -i http://localhost:8080/mcp
84
+ HTTP/1.1 401 Unauthorized
85
+ WWW-Authenticate: Bearer scope="mcp:read", resource_metadata="http://localhost:8080/.well-known/oauth-protected-resource/mcp"
86
+ ```
87
+
88
+ Calls without a token no longer reach your server. The `401` tells MCP clients where to find LumoAuth.
89
+
90
+ ### 4. Sign in from a client
91
+
92
+ First, create an application for the client in the portal:
93
+
94
+ 1. Open **Applications**, click **New application** and choose **Single-page or mobile app**.
95
+ 2. Set **Application name** to `Local MCP client` and **Redirect URI** to `http://localhost:8765/callback`.
96
+ 3. Click **Create application** and copy the **Client ID**.
97
+ 4. On the **Configuration** tab, set **Scopes** to `openid profile email offline_access mcp:read`. Click **Save configuration**.
98
+
99
+ Then connect Claude Code, with your client ID:
100
+
101
+ ```bash
102
+ claude mcp add --transport http \
103
+ --client-id client_0123456789abcdef0123456789abcdef \
104
+ --callback-port 8765 \
105
+ invoices http://localhost:8080/mcp
106
+
107
+ claude mcp login invoices
108
+ ```
109
+
110
+ Your browser opens on the LumoAuth sign-in page. After you sign in and approve, `claude mcp list` shows the connection:
111
+
112
+ ```console
113
+ invoices: http://localhost:8080/mcp (HTTP) - ✔ Connected
114
+ ```
115
+
116
+ Other MCP clients connect the same way if they let you set a client ID and a callback port. [Troubleshooting](#troubleshooting) explains the errors that you may see.
117
+
118
+ ### Before you go to production
119
+
120
+ - Register a separate server with your public `https://` address. LumoAuth accepts plain `http://` only for `localhost`, `127.0.0.1` and `[::1]`.
121
+ - Put `lumoauth` behind your TLS terminator or tunnel at that address. Clients reach the server at its Resource URI.
122
+ - Keep the upstream on `127.0.0.1`, so that callers can reach it only through `lumoauth`.
123
+ - Under **Allowed clients**, choose **Only the clients I pick**.
124
+ - Switch on **Require DPoP sender-constrained tokens** if all your clients can send proofs. Agents built on the LumoAuth JavaScript, Python and Go SDKs can do so.
125
+
126
+ ## What it does
127
+
128
+ `secure` runs on port 8080 (or `--port`, or `PORT`). In front of your server, it does the following:
129
+
130
+ - **Discovery.** It serves the protected resource metadata that sends MCP clients to your LumoAuth organization, and it answers `401` with the challenge that points to it.
131
+ - **Token checks.** It verifies each request's LumoAuth token (Bearer or DPoP) before anything reaches your server. It never passes the token on.
132
+ - **Identity.** It sends the caller's identity to your server in the headers below. Headers with these names from the client are removed.
133
+ - **Sessions.** It binds each MCP session to the caller that opened it.
134
+ - **Tool policy.** With LumoAuth's per-tool policy on, it removes from `tools/list` the tools that the caller may not run. It rejects those calls without reaching your server.
135
+
136
+ | Header | Value |
137
+ | --- | --- |
138
+ | `X-LumoAuth-Subject` | The user id, or `agent_agt_…` for an agent |
139
+ | `X-LumoAuth-Subject-Type` | `user` or `agent` |
140
+ | `X-LumoAuth-Agent-Id` | The agent's `agt_…` id |
141
+ | `X-LumoAuth-Actor` | The agent acting for the user |
142
+ | `X-LumoAuth-Client-Id` | The OAuth client |
143
+ | `X-LumoAuth-Scopes` | The granted scopes |
144
+
145
+ **HTTP mode** works with any MCP server and any protocol revision. It reads JSON-RPC only to apply the tool policy, and it streams everything else.
146
+
147
+ **Stdio mode** gives every MCP session its own server process, so two callers never share one. The HTTP side is the MCP SDK's Streamable HTTP transport, which serves protocol revisions up to 2025-11-25.
148
+
149
+ ## Per-tool policy
150
+
151
+ With the policy on, `lumoauth` asks LumoAuth about each tool and hides the tools that a caller may not run.
152
+
153
+ **Every tool is denied until you grant it.** Set it up once:
154
+
155
+ 1. **Create the server's own application.** Open **Applications**, click **New application** and choose **Machine to machine**. Copy the **Client ID** and the **Client secret**, which is shown only once.
156
+ 2. **Allow the scope.** On the application's **Configuration** tab, set **Scopes** to `mcp:authorize`. The form also asks for a redirect URI, which this application does not use, so enter any `https://` URL. Click **Save configuration**.
157
+ 3. **Connect it to the MCP server.** Edit the server. In the step **Who may connect and how**, select the application under **Per-tool authorization**.
158
+ 4. **Give `lumoauth` the credentials.** Set `LUMOAUTH_MCP_CLIENT_ID` and `LUMOAUTH_MCP_CLIENT_SECRET`, then restart it. The policy is now on; `--no-tool-policy` turns it off.
159
+ 5. **Grant access.** Open **Relationships**. Under **Namespaces**, create the namespace that you need, with the relation `invoke`. Then, under **Tuples**, add one relationship for each grant:
160
+
161
+ | To grant | Object namespace | Object ID | Relation | Subject |
162
+ | --- | --- | --- | --- | --- |
163
+ | Every tool on the server | `mcp_server` | `mcp_0123456789abcdef01234567` | `invoke` | `user` and the user's id |
164
+ | One tool | `mcp_tool` | `mcp_0123456789abcdef01234567/refund` | `invoke` | `agent` and the agent's id |
165
+
166
+ Relationships are part of the Fine-grained authorization add-on. Without it, every tool is denied.
167
+
168
+ ## Check the setup
169
+
170
+ `npx lumoauth check` prints what the registration says, the discovery document and the `401` challenge. It also prints what the authorization server advertises: PKCE, client metadata documents and dynamic registration.
171
+
172
+ ```console
173
+ $ npx lumoauth check
174
+ LumoAuth
175
+ issuer https://app.lumoauth.dev/orgs/acme/api/v1
176
+ MCP server mcp_0123456789abcdef01234567
177
+ resource http://localhost:8080/mcp
178
+ scopes mcp:read
179
+ DPoP accepted, not required
180
+ tool policy not configured
181
+ ```
182
+
183
+ ## Options
184
+
185
+ Run `npx lumoauth --help` for all of them. The common ones:
186
+
187
+ | Option | Environment variable | Meaning |
188
+ | --- | --- | --- |
189
+ | `--org` | `LUMOAUTH_ORG_ID` | Organization |
190
+ | `--server` | `LUMOAUTH_MCP_SERVER_ID` | Registered MCP server id |
191
+ | `--lumoauth-url` | `LUMOAUTH_URL` | `https://eu.app.lumoauth.dev` for the EU region |
192
+ | `--upstream` | | The MCP endpoint to protect |
193
+ | `--stdio` | | The command after `--` is a stdio server |
194
+ | `--port`, `--host` | `PORT` | Where to listen (default `0.0.0.0:8080`) |
195
+ | `--path` | | Public path of the MCP endpoint (default: the Resource URI's path) |
196
+ | `--scope` | | A scope that every request needs (repeatable) |
197
+ | `--public` | | A path that needs no token, such as `/health` (repeatable) |
198
+
199
+ ## Troubleshooting
200
+
201
+ | What you see | Why | What to do |
202
+ | --- | --- | --- |
203
+ | `LumoAuth has no active MCP server` at start-up | The server id or the organization slug is wrong. | Copy both again from the portal. |
204
+ | `MCP server … is registered as Public` at start-up | LumoAuth issues no tokens for a server with this mode or with the stdio transport. | Choose **OAuth 2.1 protected** and the **Streamable HTTP** transport. |
205
+ | `Protected resource … does not match expected …` | The client connects to a URL that differs from the Resource URI. `localhost` and `127.0.0.1` count as different. | Use the Resource URI exactly. |
206
+ | `invalid_dpop_proof` or `DPoP proof required` | **Require DPoP** is on and the client sends no proof. | Switch it off, then restart `lumoauth`. |
207
+ | `invalid_scope` … `not allowed for this client` | The application does not allow a scope that the client asks for. | Add the scope to the application's **Scopes**. Many clients add `offline_access` on their own. |
208
+ | `Invalid Redirect URL` on a LumoAuth page | The client's redirect URI is not registered. LumoAuth accepts a changing port only on `127.0.0.1` and `[::1]`, not on `localhost`. | Create an application with the exact URI, and give the client a fixed callback port. |
209
+ | `Dynamic client registration is not enabled` | The client tried to register itself, which is off by default. | Give the client a client ID, as in [step 4](#4-sign-in-from-a-client). |
210
+ | The list of tools is empty | The per-tool policy is on and the caller has no grant. | See [Per-tool policy](#per-tool-policy). |
211
+ | A registration change has no effect | `lumoauth` reads the registration at start-up. | Restart `lumoauth`. |
212
+
213
+ ## License
214
+
215
+ MIT