Repository navigation
Conversation
allozaur
changed the base branch from
master
to
allozaur/feat/hf-conversation-sharing
November 26, 2026 14:37
allozaur
force-pushed
the
allozaur/refactor/ui-mcp-extension-v2
branch
from
November 26, 2026 14:37
33a23ec to
4c39163
Compare
allozaur
force-pushed
the
allozaur/refactor/ui-mcp-extension-v2
branch
from
November 26, 2026 15:24
4c39163 to
86fc7bf
Compare
allozaur
force-pushed
the
allozaur/refactor/ui-mcp-extension-v2
branch
from
November 26, 2026 16:08
86fc7bf to
be3c650
Compare
allozaur
force-pushed
the
allozaur/refactor/ui-mcp-extension-v2
branch
from
November 26, 2026 16:18
be3c650 to
f88a5a3
Compare
allozaur
force-pushed
the
allozaur/refactor/ui-mcp-extension-v2
branch
from
November 26, 2026 20:04
f88a5a3 to
b6a08d7
Compare
allozaur
force-pushed
the
allozaur/refactor/ui-mcp-extension-v2
branch
from
November 27, 2026 08:51
b6a08d7 to
192676b
Compare
allozaur
force-pushed
the
allozaur/refactor/ui-mcp-extension-v2
branch
from
November 27, 2026 09:04
192676b to
10b1f24
Compare
llama-server refuses browser requests whose Origin does not match its own host unless --cors-origins allows it, and the Vite proxy forwarded the page's Origin (localhost:5173, or a LAN or Tailscale address). Loading a model, saving tools and /v1 calls failed with 403 under `vite dev`. The proxy now calls the server with its own Host and no Origin, WebSocket upgrades included. Sec-Fetch-Site still passes through, so requests from other sites stay refused. Assisted-by: Claude (Opus 5.5 Medium)
ROUTES holds the app's route ids, as page.route.id reports them, in place of hash strings and the separate *_ROUTE_ID constants. Every link and goto() goes through resolve() from $app/paths, which checks the route exists and returns its URL (#/models with the hash router). RouterService resolves the routes that take params: a chat, a project, a project's chat or new chat, and an extension's page. Tab links, sidebar items and extension navigation items carry the resolved URL's type, and checks for the current page compare page.route.id instead of the hash. svelte/no-navigation-without-resolve is on again, with type information for the app's modules so a URL typed as ResolvedPathname passes. Links that leave the app say so with rel="external"; the deep-link cleanups, which change the current page's own query, are marked as such. Assisted-by: Claude (Opus 5.5 Medium)
Extensions are how a feature outside the core plugs into the app. Each one is known by a manifest, its code is imported only when it is activated, and it adds its parts through extension points. The registry holds those contributions and removes them, running the extension's cleanup, when the extension is switched off. The app starts its built-in extensions once the stores are ready. MCP is the first one: it is registered here and contributes nothing yet, the next commits move it behind the extension points one by one. Assisted-by: Claude (Opus 5.5 Medium)
The tools store, the agentic flow, the tool policy and the tools UI no longer import MCP. The MCP extension contributes a tool provider to the `tools` point, which lists the servers' tools, normalizes their schemas, runs the calls and gives the icons and hints the UI shows, and a hook to the `flow` point, which holds the connections while a flow runs. The core reads both from the extension registry, so with the MCP extension off the tools UI and the flow work the same, just without the MCP tools. The stored tool and group keys keep their format. Assisted-by: Claude (Opus 5.5 Medium)
…ension point The sidebar, the settings and the root layout no longer import MCP code. A new extension point carries what they need instead. `settingsActions` is an action under one of an extension's settings, there while that setting is on. The MCP extension contributes Manage MCP servers under Enable MCP: the settings list it as before and open the MCP servers dialog on a desktop or tablet and their page of the settings sheet on a phone. The sidebar mounts the dialogs of contributed actions itself. The background MCP health checks move from the root layout into the extension's activation. They stop when the extension is switched off, and while Enable MCP is off no server is checked and the open connections close. Assisted-by: Claude (Opus 5.5 Medium)
…xtension points The chat form no longer imports MCP code. It reads three new extension points instead: composerCommands (slash commands of the `/` picker), composerPickers (popover pickers a command opens) and composerAttachments (attachments held outside the form's files until the message is sent). The MCP extension contributes the `/prompt` command, its prompt picker and the attached resources through them. The code that turns a picked prompt into a loading chip, then fills it or marks it failed, moved from ChatForm into the extension and works through a small composer handle. The chat store now takes the pending resource extras from composerAttachments when a message is sent. With the extension on, the form looks and behaves as before. Without it, `/prompt` and the resource list are gone and the rest of the form works unchanged. Assisted-by: Claude (Opus 5.5 Medium)
…on points The chat message and the attachments list no longer know about MCP. Two new extension points, messageRenderers and attachmentRenderers, let an extension claim a message or an attachment and draw it with its own component. The MCP extension contributes its prompt message, its prompt chip and its resource chip through them, and the resource chip now owns the preview dialog that the attachments list used to hold. A claimed attachment stays out of the built-in preview. When nothing claims an MCP prompt or resource, because the extension is off, it is drawn as a plain text attachment with its name and text, and a message that is only an MCP prompt is drawn as a normal user message with that chip. Stories that show MCP prompts or MCP attachments switch the built-in extensions on in their setup. Assisted-by: Claude (Opus 5.5 Medium)
MCP's store, service and components move into `src/lib/extensions/mcp/` (`stores/`, `services/`, `components/`), beside the glue that was already there. The core barrels (`$lib/stores`, `$lib/services`, `$lib/components/app` and its `chat`, `dialogs` and `settings` barrels) no longer export any of it, so nothing in the core can reach MCP's code except through the extension points. Inside the extension a file imports the others by relative path. The documented component barrel moves along as `components/index.ts` and is for tests and stories; the extension's own code does not import it, which removes the cycle through `tools.ts`, the tool group identity, the barrel and the servers settings. The search results block of a tool call was the last core user of mcpStore: it now takes the icon from `toolsStore.getToolIcon` and reads the CORS proxy flag from the server props, which is what mcpStore did. A new ESLint rule, `local/no-extension-internals`, enforces the rule for every extension: a module under `src/lib/extensions/<id>/` can only be imported from that folder. The registry's own files stay importable, `builtin.ts` loads each extension's entry with a dynamic import, and `tests/**` is exempt. MCP's shared data (types, enums, constants, `utils/mcp.ts`, settings keys, stored formats) stays in the core. No behaviour changes. Assisted-by: Claude (Opus 5.5 Medium)
Storybook now registers and activates the built-in extensions in the preview's `beforeAll`, the way the app does at startup, so every story and story test sees what the extensions add without asking for it. The stories that did this themselves (the chat form, the MCP prompt message, the attachments list and the sidebar) drop their own activation. The one guarded helper stays in `tests/stories/helpers/extensions.ts`. Assisted-by: Claude (Opus 5.5 Medium)
Settings has a new section, Extensions: the extensions the app knows, each with its name, its description and a switch. A switch takes effect at once and the registry remembers the choice, so a reload keeps it. An extension that failed to load or activate says why, and switching it off and on tries again. Switching MCP off now also closes its live connections and drops the resources still attached in the chat form, so nothing of it keeps running and nothing comes back unseen when it is switched on again. Its sidebar entry, its page, the `/prompt` command and its tools already went away with its contributions. Assisted-by: Claude (Opus 5.5 Medium)
Replace @modelcontextprotocol/sdk with @modelcontextprotocol/client. The client keeps the session handshake, so behaviour does not change. SDK v2 has no WebSocket client transport, so the v1 one now lives in the app. The demo MCP servers use @modelcontextprotocol/server and @modelcontextprotocol/node. Assisted-by: Claude (Opus 5.5 Medium)
…ndshake Streamable HTTP connections probe the server with server/discover (MCP 2026-07-28) and fall back to the initialize handshake on older servers. SSE and WebSocket connections keep the initialize handshake. The connection log and the server card show the negotiated protocol version. On a stateless connection, resource subscriptions use a subscriptions/listen stream. Assisted-by: Claude (Opus 5.5 Medium)
- A failed stateless probe (HTTP 5xx, unusable reply, no reply) is retried once with the session handshake, with a warning in the connection log. Authorization failures are not retried. - A subscriptions/listen stream that the server or a proxy ends is opened again with a backoff, until the connection is closed. - List calls always reach the server, the SDK cache cannot answer them. - A 404 means an expired session only on a connection that has a session. - Remove the unused protocol version constant and update comments that described the session flow as the only one. Assisted-by: Claude (Opus 5.5 Medium)
…ut down A reconnect loop kept the server's config it started with, so shutting the store down between two attempts did not stop it: the next attempt brought a connection back. Switching the MCP extension off shuts the store down, which made that reachable from Settings. The loop now checks that its config is still the registered one before each attempt and after a connect, and closes a connection that arrives too late. A shutdown with no live connection forgets the configs too. Assisted-by: Claude (Opus 5.5 Medium)
A setting can now name the extension it belongs to. Its field is drawn only while that extension is running; the stored value and its default stay, so settings export, sync and migrations see the same keys either way. The MCP request timeout is the first such field: with MCP switched off it no longer shows in Settings. Assisted-by: Claude (Opus 5.5 Medium)
A setting can name its extension (`extension` in SETTINGS_REGISTRY), so its field shows only while the extension is on and the stored value stays either way. An extension's code ships in the single bundle llama-server embeds, but none of it runs while the extension is off. The Architecture › Extensions page that came with this lives with the Storybook's Architecture section, outside this stack. Assisted-by: Claude (Opus 5.5 Medium)
An MCP prompt picked into the chat form is an attachment of the app's own kind, drawn by MCP's renderer. With the extension switched off before the message is sent, it fell back to the generic file chip with its kind as an overflowing label. It now reads as a text file once its text has loaded, the same rule a stored attachment of such a kind already follows. Assisted-by: Claude (Opus 5.5 Medium)
A tool of an MCP server llama-server runs from --mcp-servers-config is listed as <server>_<tool>, so a client could only guess the server from the name, and guess wrong when the server's name has an underscore. GET /tools now gives it in `mcp_server` for such tools. Built-in tools are listed as before. Assisted-by: Claude (Opus 5.5 Medium)
…s to A page cannot start a process, so a local MCP server that runs as a command (stdio) is one llama-server starts from --mcp-servers-config. Its tools reached Llama Chat as plain server tools, under the llama-server group, unlike the MCP servers the browser connects to by URL. The MCP extension now takes those tools over: a tool provider can claim llama-server's tools of one /tools type, and MCP claims `mcp`. They are listed one group per server, switched off and allowed like the tools of any other MCP server, and still run on llama-server. The MCP servers page shows each of these servers as a card marked as run by llama-server, and explains how to add a local server to llama-server's config. With MCP switched off, the core lists them as server tools again. Assisted-by: Claude (Opus 5.5 Medium)
…able MCP Since ggml-org#33036, MCP is off until "Enable MCP" is on. The MCP extension's tests rendered the tools panel expecting its hint about MCP servers, so they switch the setting on first. A new case checks the other side: the tools panel says nothing about MCP servers while "Enable MCP" is off. Assisted-by: Claude (Opus 5.5 Medium)
The MCP extension is on by default, so its chunk was fetched at every startup, and the SDK with zod came with it: 462 KB of JS for a user with no MCP servers. MCPService now imports the SDK for types only and loads its runtime, with the WebSocket transport, on the first connect. The extension's own chunk at startup drops to 143 KB (41 KB gzip). The SDK chunk (319 KB, 84 KB gzip) loads when a server is added or enabled. SDK v2 already picks the cfworker JSON Schema validator in browsers, so ajv was never in the bundle. Assisted-by: Claude (Opus 5.5 Medium)
A chat-only build (VITE_PUBLIC_AGENTIC=false) has no tools, so it registers no MCP extension: no MCP servers in Settings, no prompts or resources in the composer. A full build registers it, and leaves its contributions out until llama-server offers the agentic features: an extension's manifest can say whether it is available, and the registry hands out only the contributions of those that are. The answer can be "not known yet", which is the case until the server has said what it offers, and they stay out until then. Assisted-by: Claude (Opus 5.5 Medium)
An MCP server that answers 401 and publishes an OAuth authorization server can now be signed in to, in the browser, with no server of our own: the MCP SDK's auth() runs discovery, dynamic client registration, PKCE, the code exchange and refresh, and an OAuthClientProvider here keeps the client, the tokens, the verifier and the discovery state per server in localStorage, apart from the settings so tokens never travel with a settings export. A connection in the background never opens a page or registers a client: it stops with "sign in to use this server", and a server whose 401 offers no sign-in says to add a token instead. A sign-in the user starts opens the authorization page in a popup (or this tab when it is blocked); the page comes back to the app's root, which exchanges the code, checks the state, and tells every tab on a BroadcastChannel, since the cross-origin isolated UI cuts the popup off from its opener. The server then connects again. Sign-out revokes the token where the authorization server allows it. An Authorization header the user set wins: such a server is never offered a sign-in. Through llama-server's CORS proxy the transport now keeps the real server URL and the fetch sends every request through the proxy, so the resource a token is asked for and the discovery URLs are the server's own. Mirrors Hugging Face chat-ui's MCP OAuth where a static app can, and builds on the earlier attempt on the fork by LPFchan. Assisted-by: Claude (Opus 5.5 Medium)
A server that needs a sign-in shows "Sign in with <authorization server>" on its card instead of the error its connection ended with. While the authorization page is open the card waits, with a way to give up; a server whose authorization server registers no apps asks for the client ID (and secret, if any) of an app the user registered there, with the redirect URL to register it under; a signed-in server says so and offers Sign out. Signing out, and deleting a server, revoke its tokens where the authorization server allows it, close its connection and take its tools out, so the card is back to the sign-in at once. The MCP server card story has a Sign-in state for each of these. Assisted-by: Claude (Opus 5.5 Medium)
The sign-in flow is part of the MCP extension's startup chunk and imported auth and RegistrationRejectedError from the SDK, which pulled the whole SDK back into it. It now takes them from MCPService.loadSdk(), so the SDK still downloads only when a server connects or a sign-in starts or completes. Assisted-by: Claude (Opus 5.5 Medium)
allozaur
force-pushed
the
allozaur/refactor/ui-mcp-extension-v2
branch
from
November 27, 2026 09:26
10b1f24 to
02e0680
Compare
allozaur
changed the base branch from
allozaur/feat/hf-conversation-sharing
to
master
November 27, 2026 09:26
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
MCP becomes a built-in extension of Llama Chat on MCP SDK v2, and MCP servers that support OAuth can be signed in to with the browser. This is the base the Hugging Face connector builds on.
Additional information
Second in the stack on this fork: it sits on the sharing PR (#136), and the Hugging Face connector (#134) sits on it. It is #125, #61 and #63 rebuilt as one layer; those three PRs still hold the full write-ups, and are superseded once this one is the one to keep.
Rebased on 2026-11-26 onto upstream master
a866b4ade6. Upstream had meanwhile taken MCP out of the sidebar, removed its page and put it behind an Enable MCP setting (ggml-org#33036, ggml-org#33067), so one commit was reworked instead of replayed: see What changed.Known gaps, besides the ones listed in #61 and #63, which were not looked at again:
What changed
In commit order:
resolve()with typed route ids, and the Vite dev proxy calls llama-server as its own page so requests from a LAN or Tailscale address are not refused.src/lib/extensions/, the extension points MCP needs (tools, flow, settings actions, composer, renderers), all of MCP's code undersrc/lib/extensions/mcp/, a switch per extension in Settings, the move to@modelcontextprotocol/client2.x with stateless negotiation, and the MCP servers llama-server runs itself. One commit is a llama-server change:mcp_serverinGET /tools.auth(), with the sign-in on the server card.Changed in the rebase onto
a866b4ade6:navigationandpagesextension points are gone, with MCP's page and everything that only served them: nothing contributes to them now that upstream manages MCP from Settings. In their place is one point,settingsActions. MCP contributes "Manage MCP servers" under Enable MCP: a dialog on desktop and a page in the phone settings sheet, as on master.uiStore.mcpServersOpenbecamesettingsActionOpenId, opened and closed by id. The commit is retitled "ui: open the MCP servers from Settings through a settings actions extension point"; its old form isd249679233on the old branch tip33a23ec54f.Changes made while rebuilding from #125, #61 and #63:
tests/unit/token-roles.test.ts). Four files of these commits still used them; they use the type roles now (text-caption,text-body-sm,text-caption-sm), each fix folded into the commit that added the file.Testing
In
ui/apps/chat, on the tip of this branch:npm run check: no errors.npm run lint: clean.Every commit was scanned for conflict markers. Not run: the E2E suite, Storybook, the Docker and Nix builds and the CMake embed.
Requirements
Claude (Opus 5.5 Medium)