From aa7111bc19aeacd905a7f61a3e11db9604bbef76 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Tue, 1 Dec 2026 16:17:57 +0000 Subject: [PATCH] Give the Outpost MCP server and its tools icons Co-Authored-By: Claude Opus 5.5 --- internal/mcpserver/icons.go | 67 ++++++++++++++++++++++ internal/mcpserver/icons/outpost-dark.svg | 11 ++++ internal/mcpserver/icons/outpost-light.svg | 11 ++++ internal/mcpserver/icons_test.go | 52 +++++++++++++++++ internal/mcpserver/server.go | 48 +++++++++------- 5 files changed, 168 insertions(+), 21 deletions(-) create mode 100644 internal/mcpserver/icons.go create mode 100644 internal/mcpserver/icons/outpost-dark.svg create mode 100644 internal/mcpserver/icons/outpost-light.svg create mode 100644 internal/mcpserver/icons_test.go diff --git a/internal/mcpserver/icons.go b/internal/mcpserver/icons.go new file mode 100644 index 0000000..5151701 --- /dev/null +++ b/internal/mcpserver/icons.go @@ -0,0 +1,67 @@ +package mcpserver + +import ( + "embed" + "encoding/base64" + "strings" + + "github.com/modelcontextprotocol/go-sdk/mcp" +) + +// The brand mark, as the web app shows it. Kept beside the server so the icons travel inline as +// data URIs: a client shows them without fetching anything from the Outpost site. +// +//go:embed icons/outpost-light.svg icons/outpost-dark.svg +var brand embed.FS + +// Each tool's picture is a Lucide glyph (ISC licence), the set the web app draws its steps with. +var toolGlyphs = map[string]string{ + "whoami": ``, + "machines_list": ``, + "sessions_list": ``, + "session_read": ``, + "folders_list": ``, + "agent_create": ``, + "session_start": ``, + "session_answer": ``, + "session_send": ``, + "session_stop": ``, +} + +// Ink for a glyph on each theme's background, the colours of the brand mark's strokes. +const ( + inkOnLight = "#172033" + inkOnDark = "#F7F8F5" +) + +func svgURI(svg []byte) string { + return "data:image/svg+xml;base64," + base64.StdEncoding.EncodeToString(svg) +} + +// serverIcons is the brand mark for light and dark backgrounds; light first, for a client that +// takes the first it can show. +func serverIcons() []mcp.Icon { + light, _ := brand.ReadFile("icons/outpost-light.svg") + dark, _ := brand.ReadFile("icons/outpost-dark.svg") + return []mcp.Icon{ + {Source: svgURI(light), MIMEType: "image/svg+xml", Sizes: []string{"any"}, Theme: mcp.IconThemeLight}, + {Source: svgURI(dark), MIMEType: "image/svg+xml", Sizes: []string{"any"}, Theme: mcp.IconThemeDark}, + } +} + +// toolIcons is a tool's glyph inked for light and dark backgrounds; nil for a tool without one. +func toolIcons(name string) []mcp.Icon { + glyph, ok := toolGlyphs[name] + if !ok { + return nil + } + ink := func(color string) string { + return svgURI([]byte(strings.Join([]string{ + ``, glyph, ``}, ""))) + } + return []mcp.Icon{ + {Source: ink(inkOnLight), MIMEType: "image/svg+xml", Sizes: []string{"any"}, Theme: mcp.IconThemeLight}, + {Source: ink(inkOnDark), MIMEType: "image/svg+xml", Sizes: []string{"any"}, Theme: mcp.IconThemeDark}, + } +} diff --git a/internal/mcpserver/icons/outpost-dark.svg b/internal/mcpserver/icons/outpost-dark.svg new file mode 100644 index 0000000..e913ac5 --- /dev/null +++ b/internal/mcpserver/icons/outpost-dark.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/internal/mcpserver/icons/outpost-light.svg b/internal/mcpserver/icons/outpost-light.svg new file mode 100644 index 0000000..e700fe8 --- /dev/null +++ b/internal/mcpserver/icons/outpost-light.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/internal/mcpserver/icons_test.go b/internal/mcpserver/icons_test.go new file mode 100644 index 0000000..678f9fa --- /dev/null +++ b/internal/mcpserver/icons_test.go @@ -0,0 +1,52 @@ +package mcpserver + +import ( + "context" + "encoding/base64" + "strings" + "testing" + + "github.com/modelcontextprotocol/go-sdk/mcp" +) + +func TestServerAndEveryToolCarryIcons(t *testing.T) { + ctx := context.Background() + st, ct := mcp.NewInMemoryTransports() + ss, err := (&Server{}).mcp().Connect(ctx, st, nil) + if err != nil { + t.Fatal(err) + } + defer ss.Close() + cs, err := mcp.NewClient(&mcp.Implementation{Name: "test"}, nil).Connect(ctx, ct, nil) + if err != nil { + t.Fatal(err) + } + defer cs.Close() + + check := func(what string, icons []mcp.Icon) { + t.Helper() + themes := map[mcp.IconTheme]bool{} + for _, ic := range icons { + b64, ok := strings.CutPrefix(ic.Source, "data:image/svg+xml;base64,") + svg, err := base64.StdEncoding.DecodeString(b64) + if !ok || err != nil || !strings.HasPrefix(strings.TrimSpace(string(svg)), "