ulysses/static/js
Abylaikhan Zulbukharov 1d80bf5e65
feat(mcp): add Streamable HTTP transport with OAuth 2.0 (#1033)
* feat(mcp): add Streamable HTTP transport with OAuth 2.0

  Odysseus could only reach MCP servers over stdio and SSE, so modern
  remote servers like https://mcp.higgsfield.ai/mcp (Streamable HTTP,
  gated behind OAuth) could not be connected.

  Add an `http` transport that connects via the SDK's
  streamablehttp_client and authenticates with the SDK's
  OAuthClientProvider: RFC 9728 protected-resource discovery, RFC 8414
  authorization-server metadata, Dynamic Client Registration,
  authorization-code + PKCE, and token refresh. A small bridge
  (src/mcp_oauth.py) connects the SDK's blocking callback to the existing
  web callback route via an asyncio.Future keyed by the OAuth `state`,
  and the dynamic client registration plus tokens persist per-server in a
  new encrypted `oauth_tokens` column.

  The connect runs as a bounded background task so the "Add server"
  request returns immediately; redirect_handler publishes needs_auth +
  auth_url to connection state as soon as discovery/DCR completes (which
  can exceed the bounded wait), and the UI polls until connected. Remote
  users finish via the existing paste-back flow. The Google OAuth path is
  left unchanged.

  - core/database.py: encrypted oauth_tokens column + migration
  - src/mcp_oauth.py: OAuth provider, DB-backed TokenStorage, state registry
  - src/mcp_manager.py: http dispatch, background connect, _connect_http
  - routes/mcp_routes.py: http validation, needs_auth/auth_url, callback bridge
  - static/js/settings.js: Streamable HTTP option + OAuth flow with polling
  - tests: 5 new unit tests (transport dispatch, registry, token storage)

  Verified against the live Higgsfield server: discovery, DCR (client_id
  issued), loopback redirect accepted, and a PKCE authorization URL with
  needs_auth status. No regressions (full suite delta is only the 5 added
  passing tests).

* fix(mcp): address PR #1033 review feedback

  - mcp_oauth: derive redirect URI from OAUTH_REDIRECT_BASE_URL/APP_PUBLIC_URL
    (default http://localhost:7000) instead of hardcoding the port
  - mcp_oauth: leave OAuth scope unset so the SDK derives it from the server's
    WWW-Authenticate/protected-resource metadata; hardcoding an OIDC scope broke
    non-OpenID MCP servers (verified: Higgsfield still gets its server-derived
    scope)
  - mcp_oauth: prune abandoned OAuth flows (_prune_stale + _pending_ts) so the
    module-level registries can't grow unbounded
  - mcp_oauth: persist tokens/client-info in a single DB session/commit
    (_update) instead of a load+save double round-trip
  - mcp_manager: cancel and drop the background connect task in
    disconnect_server so a deleted server stops publishing status
  - database: document why the oauth_tokens migration uses TEXT while the model
    declares EncryptedText (encryption is applied at the Python layer)
  - settings.js: surface persistent OAuth-poll failures and an explicit timeout
    message instead of silently swallowing errors
  - tests: cover the stale-flow pruning

* static/js/settings.js now shows an in-flight loading state on the buttons that fire requests:
2026-06-05 02:40:52 +02:00
..
calendar Ignore non-string calendar date inputs (#1649) 2026-06-03 14:16:58 +09:00
color fix: theme color parsing breaks on #rgb shorthand hex (#1213) 2026-06-03 00:30:03 +09:00
compare Isolate HTML popup openers (#2501) 2026-06-04 20:52:41 +02:00
editor fix: computeSnap throws when ctx.otherLayers is not an array (#1716) 2026-06-03 13:34:25 +09:00
emailLibrary Harden email HTML URL sanitization (#2496) 2026-06-04 20:47:47 +02:00
markdown Ignore non-string markdown table rows (#1648) 2026-06-03 14:17:02 +09:00
model fix: model cost/info matches first substring key (gpt-4o-mini billed as gpt-4o) (#1439) 2026-06-04 03:05:37 +01:00
research Whitelist research source links (#2499) 2026-06-04 20:41:35 +02:00
util fix: monthly schedule label shows 21th/22th/31th (ordinal suffix for days >20) (#1577) 2026-06-03 08:57:47 +09:00
a11y.js Improve accessibility across core flows (#86) 2026-06-01 22:04:00 +02:00
admin.js feat(provider): add GitHub Copilot provider with device-flow auth (#1480) 2026-06-04 21:13:14 +02:00
assistant.js Rename Character copy to Persona 2026-06-02 12:42:15 +09:00
calendar.js Fix calendar routing and user-local time context (#408) 2026-06-04 13:20:04 +01:00
censor.js Ignore censor preference storage errors (#1652) 2026-06-03 14:16:55 +09:00
chat.js feat: Add workspace: confine agent tools to a folder (#1103) 2026-06-05 00:06:37 +02:00
chatRenderer.js Harden chat streaming DOM sinks (#2498) 2026-06-04 20:49:37 +02:00
chatStream.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
codeRunner.js Isolate HTML popup openers (#2501) 2026-06-04 20:52:41 +02:00
colorPicker.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
cookbook-diagnosis.js Cookbook polish: auto-reconnect, ctx slider fixes, scoring, lots of UI 2026-06-03 20:25:25 +09:00
cookbook-hwfit.js Cookbook polish: auto-reconnect, ctx slider fixes, scoring, lots of UI 2026-06-03 20:25:25 +09:00
cookbook.js Cookbook polish: auto-reconnect, ctx slider fixes, scoring, lots of UI 2026-06-03 20:25:25 +09:00
cookbookDownload.js Cookbook polish: auto-reconnect, ctx slider fixes, scoring, lots of UI 2026-06-03 20:25:25 +09:00
cookbookProgressSignal.js Don't falsely declare a dependency build stale (#1568) (#1768) 2026-06-03 13:23:35 +09:00
cookbookRunning.js fix(cookbook): don't mark successful dependency installs as crashed (#1315) 2026-06-04 12:55:06 +01:00
cookbookServe.js Cookbook polish: auto-reconnect, ctx slider fixes, scoring, lots of UI 2026-06-03 20:25:25 +09:00
document.js Render emoji shortcodes as icons in chat (#345) (#629) 2026-06-05 02:28:42 +02:00
documentLibrary.js Whitelist research source links (#2499) 2026-06-04 20:41:35 +02:00
dragSort.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
emailInbox.js fix: reply-all Cc's the user's own other addresses (multi-account) (#672) 2026-06-02 11:42:20 +09:00
emailLibrary.js fix: guard sp.destroy() in _loadScheduled against null spinner (#1495) 2026-06-03 08:12:47 +09:00
emojiPicker.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
emojiShortcodes.js Render emoji shortcodes as icons in chat (#345) (#629) 2026-06-05 02:28:42 +02:00
escMenuStack.js fix: make transient dropdown/popup menus close on Escape 2026-06-01 14:23:22 -04:00
fileHandler.js feat(ui): allow expanding consolidated file chip regardless of count (#1849) (#2086) 2026-06-04 14:02:52 +01:00
gallery.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
galleryEditor.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
group.js Harden chat streaming DOM sinks (#2498) 2026-06-04 20:49:37 +02:00
init.js fix(ui): keep minimized windows above composer (#1197) 2026-06-02 23:31:09 +09:00
keyboard-shortcuts.js Ignore AltGr keystrokes in Ctrl+Alt keyboard shortcuts (#825) 2026-06-02 11:12:54 +09:00
langIcons.js fix: langIcon throws on an explicit null opts argument (#1740) 2026-06-03 13:29:21 +09:00
markdown.js Render emoji shortcodes as icons in chat (#345) (#629) 2026-06-05 02:28:42 +02:00
memory.js feat: allow memory import without session (#493) 2026-06-01 22:32:17 +09:00
modalManager.js feat: Claude Agent integration + cookbook reconnect + UI polish 2026-06-04 08:27:26 +09:00
modalSnap.js Polish email and cookbook flows 2026-06-02 22:42:07 +09:00
modelPicker.js fix(models): stabilize proxy endpoint refresh behavior 2026-06-04 04:56:11 +01:00
models.js fix(models): stabilize proxy endpoint refresh behavior 2026-06-04 04:56:11 +01:00
modelSort.js Ignore invalid model sort inputs (#1653) 2026-06-03 14:16:52 +09:00
MODULE_SUMMARY.md docs: fix stale documentation references (#1769) 2026-06-03 13:23:21 +09:00
notes.js Guard image and QR DOM attributes (#2500) 2026-06-04 20:51:23 +02:00
package.json Fix test suite: ESM module loading and stub isolation (#844) 2026-06-02 11:29:29 +09:00
platform.js Ignore AltGr keystrokes in Ctrl+Alt keyboard shortcuts (#825) 2026-06-02 11:12:54 +09:00
presets.js Keep presets loading with bad local state (#1417) 2026-06-03 04:09:28 +09:00
providers.js Show the serving provider in the model-info card (#2185) 2026-06-04 18:22:31 +02:00
rag.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
researchSynapse.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
search-chat.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
search.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
section-management.js Fix Models section collapse dead pause and missing animation 2026-06-01 16:53:46 +02:00
sessions.js fix: live-resume chat stream on session re-entry (#2539) (#2561) 2026-06-04 17:56:15 +02:00
settings.js feat(mcp): add Streamable HTTP transport with OAuth 2.0 (#1033) 2026-06-05 02:40:52 +02:00
sidebar-layout.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
signature.js Guard image and QR DOM attributes (#2500) 2026-06-04 20:51:23 +02:00
skills.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
slashAutocomplete.js Cookbook: scoring fixes, UI polish, false-finished + stale-state bug fixes 2026-06-03 16:32:20 +09:00
slashCommands.js feat: Add workspace: confine agent tools to a folder (#1103) 2026-06-05 00:06:37 +02:00
spinner.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
storage.js feat: Add workspace: confine agent tools to a folder (#1103) 2026-06-05 00:06:37 +02:00
tasks.js feat: Claude Agent integration + cookbook reconnect + UI polish 2026-06-04 08:27:26 +09:00
theme.js fix: theme color parsing breaks on #rgb shorthand hex (#1213) 2026-06-03 00:30:03 +09:00
tileManager.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
tourAutoplay.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
tourHints.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
tts-ai.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
ui.js Revert "fix(ui): allow manual prompt bar resize (#1201)" 2026-06-03 23:03:58 +09:00
voiceRecorder.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
windowDrag.js fix(ui): modal drag + removed startDrag func (#2430) 2026-06-04 20:34:18 +02:00
windowResize.js Make tool windows resizable by dragging edges or corners 2026-06-01 19:49:23 +02:00
workspace.js feat: Add workspace: confine agent tools to a folder (#1103) 2026-06-05 00:06:37 +02:00