@dudko.dev/agent-web 0.0.12 → 0.0.15
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 +36 -6
- package/dist/agent-web.js +93 -99
- package/dist/agent-web.js.map +1 -1
- package/dist/mcp.cjs +29 -1
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.d.cts +16 -1
- package/dist/mcp.d.ts +16 -1
- package/dist/mcp.js +28 -1
- package/dist/mcp.js.map +1 -1
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -232,13 +232,43 @@ navigates on its own — the SDK can demand authorization from inside a running
|
|
|
232
232
|
tool call, and evicting the user then would discard the run. The URL is recorded
|
|
233
233
|
on `provider.authorizationUrl` and the app decides when to use it.
|
|
234
234
|
|
|
235
|
-
|
|
235
|
+
### CORS: what the server must send
|
|
236
236
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
237
|
+
A browser tells JavaScript nothing about why it blocked a request — a CORS
|
|
238
|
+
rejection and a server that is down both arrive as `TypeError: Failed to fetch`,
|
|
239
|
+
with the real reason printed only to the devtools console. So these are worth
|
|
240
|
+
checking first rather than last:
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
Access-Control-Allow-Origin: <your origin>
|
|
244
|
+
Access-Control-Allow-Methods: GET, POST, DELETE, OPTIONS
|
|
245
|
+
Access-Control-Allow-Headers: Content-Type, Authorization, mcp-session-id,
|
|
246
|
+
MCP-Protocol-Version, Last-Event-ID
|
|
247
|
+
Access-Control-Expose-Headers: mcp-session-id, WWW-Authenticate
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Each line earns its place:
|
|
251
|
+
|
|
252
|
+
- **`MCP-Protocol-Version` in Allow-Headers** is the one that bites hardest. The
|
|
253
|
+
spec has required that header on every request *after* `initialize` since
|
|
254
|
+
2025-06-18, and CORS lists written before that date omit it. The first request
|
|
255
|
+
does not carry it, so discovery, the whole OAuth dance and `initialize` all
|
|
256
|
+
succeed — and then everything afterwards is blocked. It reads exactly like the
|
|
257
|
+
consent step failing, and sends you to debug the client.
|
|
258
|
+
- **`WWW-Authenticate` in Expose-Headers**, or the browser hides the 401
|
|
259
|
+
challenge from JS and OAuth discovery never starts.
|
|
260
|
+
- **`Last-Event-ID`** for resuming a dropped SSE stream.
|
|
261
|
+
- The authorization server's `/register`, metadata and token endpoints need CORS
|
|
262
|
+
too, `OPTIONS` included — a browser client calls them directly.
|
|
263
|
+
- If the server uses the MCP SDK's DNS-rebinding protection, its `allowedOrigins`
|
|
264
|
+
must contain your origin. Left empty, it answers **403 `Origin not allowed`**
|
|
265
|
+
to any request that carries an `Origin` header — which is every request a
|
|
266
|
+
browser makes.
|
|
267
|
+
|
|
268
|
+
When a connection does fail this way, `connectMcpHttp` no longer just repeats the
|
|
269
|
+
browser's silence: it re-probes the endpoint with a plain request and, if that
|
|
270
|
+
gets through, says which header is being refused. `diagnoseMcpCors(url)` is
|
|
271
|
+
exported so a UI can show the same sentence.
|
|
242
272
|
|
|
243
273
|
## Configuration (highlights)
|
|
244
274
|
|