Commit 05b9db831 for llama.cpp

commit 05b9db8310f2648f7e91233384854f0bb1adcbfe
Author: Aleksander Grygier <aleksander.grygier@gmail.com>
Date:   Thu Dec 3 13:38:56 2026 +0100

    ui: name the MCP server of each tool in /tools, and let MCP servers' icons load (#33598)

    * server : name the MCP server of each tool in /tools

    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)

    * server: serve the UI with COEP credentialless

    The cross-origin isolation the UI is served with (COEP require-corp) blocked images from
    hosts that send no CORP header, such as MCP server icons. With credentialless the page
    stays isolated and remote images load without credentials.

    Assisted-by: Claude (Opus 5.5 Medium)

    * ui: regenerate DESIGN.md with the danger secondary tokens

    Assisted-by: Claude (Opus 5.5 Medium)

diff --git a/tools/server/README-dev.md b/tools/server/README-dev.md
index 92085e550..c777363fd 100644
--- a/tools/server/README-dev.md
+++ b/tools/server/README-dev.md
@@ -190,6 +190,7 @@ Get a list of tools, each tool has these fields:
 - `tool` (string): the ID name of the tool, to be used in POST call. Example: `read_file`
 - `display_name` (string): the name to be displayed on UI. Example: `Read file`
 - `type` (string): `"server"` for a server tool, or `"mcp"` for a tool exposed by an MCP server
+- `mcp_server` (string, only when `type` is `"mcp"`): the name of the MCP server the tool comes from, as declared in `--mcp-servers-config`. Example: `imcp`
 - `permissions` (object): a mapping string --> boolean that indicates the permission required by this tool. This is useful for the UI to ask the user before calling the tool. For now, the only permission supported is `"write"`
 - `definition` (object): the OAI-compat definition of this tool

diff --git a/tools/server/README.md b/tools/server/README.md
index 6dda4de48..f43490ee2 100644
--- a/tools/server/README.md
+++ b/tools/server/README.md
@@ -393,7 +393,7 @@ The same JSON can be passed inline with `--mcp-servers-json`. Each entry under `
 | `cwd` | working directory of the child process |
 | `timeout_ms` | per-tool-call timeout (default: 30000) |

-Every server is spawned once at startup to list its tools, then stopped, and respawned on demand when one of its tools is called. Tools are exposed as `<server>_<tool>` alongside the built-in ones: they show up in Llama Chat and in `GET /tools`, and the model calls them like any other tool. A name colliding with an already registered tool is skipped. This is independent of `--tools`, MCP servers can be the only tools available.
+Every server is spawned once at startup to list its tools, then stopped, and respawned on demand when one of its tools is called. Tools are exposed as `<server>_<tool>` alongside the built-in ones: they show up in Llama Chat, which lists each of these servers on its MCP servers page, and in `GET /tools`, with `"type": "mcp"` and the server's name in `mcp_server`. The model calls them like any other tool. A name colliding with an already registered tool is skipped. This is independent of `--tools`, MCP servers can be the only tools available.

 The child process runs with the same privileges as the server, so only declare commands you trust. As with `--tools`, `--cors-origins` then defaults to `localhost`.

diff --git a/tools/server/server-http.cpp b/tools/server/server-http.cpp
index d1f31e3ae..fc81f4713 100644
--- a/tools/server/server-http.cpp
+++ b/tools/server/server-http.cpp
@@ -537,7 +537,9 @@ bool server_http_context::init_listener(const common_params & params) {
                         return false;
                     }
                     if (isolation) {
-                        res.set_header("Cross-Origin-Embedder-Policy", "require-corp");
+                        // credentialless, not require-corp: remote images such as MCP server icons
+                        // load straight from their host, without credentials
+                        res.set_header("Cross-Origin-Embedder-Policy", "credentialless");
                         res.set_header("Cross-Origin-Opener-Policy",   "same-origin");
                     }
                     res.set_header("Cache-Control", cache_control);
diff --git a/tools/server/server-tools.cpp b/tools/server/server-tools.cpp
index 4596274cd..bb2684547 100644
--- a/tools/server/server-tools.cpp
+++ b/tools/server/server-tools.cpp
@@ -2826,6 +2826,13 @@ struct server_mcp_tool : server_tool {

     std::string type() const override { return "mcp"; }

+    // names the server, so a client can group its tools without splitting <server>_<tool>
+    json to_json() const override {
+        json res = server_tool::to_json();
+        res["mcp_server"] = server_name;
+        return res;
+    }
+
     json get_definition() const override {
         json schema = def.input_schema;
         if (schema.is_null() || !schema.is_object()) {
diff --git a/tools/server/server-tools.h b/tools/server/server-tools.h
index 03ef99cda..c65580dd4 100644
--- a/tools/server/server-tools.h
+++ b/tools/server/server-tools.h
@@ -30,7 +30,7 @@ struct server_tool {
     // should_stop: true once the caller stopped waiting, e.g. the client dropped the connection; a null should_stop means "never stop"
     virtual json invoke(json params, stream * st = nullptr, const std::function<bool()> & should_stop = nullptr) const = 0;

-    json to_json() const;
+    virtual json to_json() const;
 };

 struct server_tools_runtime; // impl detail, defined in server-tools.cpp
diff --git a/tools/server/tests/unit/test_mcp_servers.py b/tools/server/tests/unit/test_mcp_servers.py
index 7a9f0bea5..6500d4324 100644
--- a/tools/server/tests/unit/test_mcp_servers.py
+++ b/tools/server/tests/unit/test_mcp_servers.py
@@ -77,6 +77,9 @@ def test_mcp_tools_listed_in_tools_endpoint():
         # Verify tool structure
         echo_tool = next(t for t in mcp_tools if get_tool_name(t) == "echo_echo")
         assert "description" in echo_tool or "definition" in echo_tool
+        assert echo_tool["type"] == "mcp"
+        assert echo_tool["mcp_server"] == "echo"
+        assert all("mcp_server" not in t for t in tools if t["type"] != "mcp")
     finally:
         server.stop()

diff --git a/ui/apps/chat/DESIGN.md b/ui/apps/chat/DESIGN.md
index ae905de93..0a36be8ee 100644
--- a/ui/apps/chat/DESIGN.md
+++ b/ui/apps/chat/DESIGN.md
@@ -114,6 +114,8 @@ colors:
   action-primary-hover: 'color-mix(in oklch, {colors.action-primary} 90%, transparent)'
   action-danger: '{colors.fill-danger}'
   action-danger-hover: 'color-mix(in oklch, {colors.action-danger} 90%, transparent)'
+  action-danger-secondary: 'color-mix(in oklch, {colors.fill-danger} 8%, transparent)'
+  action-danger-secondary-hover: 'color-mix(in oklch, {colors.fill-danger} 16%, transparent)'
   action-quiet: 'oklch(0.97 0 0 / 0.3)'
   action-quiet-hover: '{colors.neutral-100}'
   action-ghost-hover: 'oklch(0.556 0 0 / 0.1)'
@@ -165,6 +167,8 @@ colors:
   action-primary-hover-dark: 'color-mix(in oklch, {colors.action-primary-dark} 90%, transparent)'
   action-danger-dark: 'color-mix(in oklch, {colors.fill-danger-dark} 58%, transparent)'
   action-danger-hover-dark: 'color-mix(in oklch, {colors.fill-danger-dark} 68%, transparent)'
+  action-danger-secondary-dark: 'color-mix(in oklch, {colors.fill-danger-dark} 12%, transparent)'
+  action-danger-secondary-hover-dark: 'color-mix(in oklch, {colors.fill-danger-dark} 22%, transparent)'
   action-quiet-dark: 'oklch(0.708 0 0 / 0.15)'
   action-quiet-hover-dark: 'oklch(0.708 0 0 / 0.25)'
   action-ghost-hover-dark: 'oklch(0.708 0 0 / 0.1)'