Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions internal/mcpserver/icons.go
Original file line number Diff line number Diff line change
@@ -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": `<circle cx="12" cy="8" r="5"/><path d="M20 21a8 8 0 0 0-16 0"/>`,
"machines_list": `<rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/>`,
"sessions_list": `<path d="M8 5h13"/><path d="M13 12h8"/><path d="M13 19h8"/><path d="M3 10a2 2 0 0 0 2 2h3"/><path d="M3 5v12a2 2 0 0 0 2 2h3"/>`,
"session_read": `<path d="M15 12h-5"/><path d="M15 8h-5"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3"/>`,
"folders_list": `<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/>`,
"agent_create": `<path d="M12 8V4H8"/><rect width="16" height="12" x="4" y="8" rx="2"/><path d="M2 14h2"/><path d="M20 14h2"/><path d="M15 13v2"/><path d="M9 13v2"/>`,
"session_start": `<path d="M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z"/><circle cx="12" cy="12" r="10"/>`,
"session_answer": `<path d="M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"/><path d="M8 12h6a2 2 0 0 1 2 2v1"/><path d="m11 15-3-3 3-3"/>`,
"session_send": `<path d="M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z"/><path d="M6 12h16"/>`,
"session_stop": `<circle cx="12" cy="12" r="10"/><rect x="9" y="9" width="6" height="6" rx="1"/>`,
}

// 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{
`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="`, color,
`" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`, glyph, `</svg>`}, "")))
}
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},
}
}
11 changes: 11 additions & 0 deletions internal/mcpserver/icons/outpost-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions internal/mcpserver/icons/outpost-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions internal/mcpserver/icons_test.go
Original file line number Diff line number Diff line change
@@ -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)), "<svg") || ic.MIMEType != "image/svg+xml" {
t.Errorf("%s: icon is not an inline SVG: %.60q", what, ic.Source)
}
themes[ic.Theme] = true
}
if !themes[mcp.IconThemeLight] || !themes[mcp.IconThemeDark] {
t.Errorf("%s: want a light and a dark icon, got %d icons", what, len(icons))
}
}
check("server", cs.InitializeResult().ServerInfo.Icons)
tools, err := cs.ListTools(ctx, nil)
if err != nil {
t.Fatal(err)
}
if len(tools.Tools) != len(toolGlyphs) {
t.Errorf("%d tools but %d glyphs", len(tools.Tools), len(toolGlyphs))
}
for _, tool := range tools.Tools {
check(tool.Name, tool.Icons)
}
}
48 changes: 27 additions & 21 deletions internal/mcpserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ func logged(next http.Handler) http.Handler {
})
}

// withIcons gives a tool its picture.
func withIcons(t *mcp.Tool) *mcp.Tool {
t.Icons = toolIcons(t.Name)
return t
}

func readOnly() *mcp.ToolAnnotations {
f := false
return &mcp.ToolAnnotations{ReadOnlyHint: true, DestructiveHint: &f, OpenWorldHint: &f}
Expand All @@ -330,7 +336,7 @@ func acts(destructive bool) *mcp.ToolAnnotations {
}

func (s *Server) mcp() *mcp.Server {
srv := mcp.NewServer(&mcp.Implementation{Name: "outpost", Title: "Outpost", Version: s.cfg.Version, WebsiteURL: s.cfg.WebURL}, &mcp.ServerOptions{
srv := mcp.NewServer(&mcp.Implementation{Name: "outpost", Title: "Outpost", Version: s.cfg.Version, WebsiteURL: s.cfg.WebURL, Icons: serverIcons()}, &mcp.ServerOptions{
Instructions: "Outpost reaches coding sessions on the user's own machines. A machine answers only once the user " +
"approves this connection in the Outpost web app. The user is normally sent there directly; when a tool's answer " +
"carries needs_approval and an approveUrl instead, give the user that link. " +
Expand All @@ -340,42 +346,42 @@ func (s *Server) mcp() *mcp.Server {
if s.extend != nil {
s.extend(srv)
}
mcp.AddTool(srv, &mcp.Tool{Name: "whoami", Title: "Who am I", Annotations: readOnly(),
Description: "The signed-in Outpost account, this connection's key, and the link that approves it on machines."}, s.whoami)
mcp.AddTool(srv, &mcp.Tool{Name: "machines_list", Title: "List machines", Annotations: readOnly(),
Description: "The user's machines: whether each is online, and whether it has approved this connection."}, s.machinesList)
mcp.AddTool(srv, &mcp.Tool{Name: "sessions_list", Title: "List sessions", Annotations: readOnly(),
mcp.AddTool(srv, withIcons(&mcp.Tool{Name: "whoami", Title: "Who am I", Annotations: readOnly(),
Description: "The signed-in Outpost account, this connection's key, and the link that approves it on machines."}), s.whoami)
mcp.AddTool(srv, withIcons(&mcp.Tool{Name: "machines_list", Title: "List machines", Annotations: readOnly(),
Description: "The user's machines: whether each is online, and whether it has approved this connection."}), s.machinesList)
mcp.AddTool(srv, withIcons(&mcp.Tool{Name: "sessions_list", Title: "List sessions", Annotations: readOnly(),
Description: "Coding sessions (Claude Code, Codex) on the user's machines: title, folder, status, and whether one is waiting on the user. " +
"Pass machine to ask one machine; otherwise every online machine that approved this connection is asked."}, s.sessionsList)
mcp.AddTool(srv, &mcp.Tool{Name: "session_read", Title: "Read a session", Annotations: readOnly(),
"Pass machine to ask one machine; otherwise every online machine that approved this connection is asked."}), s.sessionsList)
mcp.AddTool(srv, withIcons(&mcp.Tool{Name: "session_read", Title: "Read a session", Annotations: readOnly(),
Description: "The newest end of one coding session, to tell how it is getting on: its status, what it is waiting on the user for, " +
"and the last few things said, each followed by one line per step the agent has taken since, including what it asked the user and how that was answered. " +
"When waitingOn is set the session does nothing until that is answered: session_answer answers it. " +
"Take machineId and id from sessions_list. With steer access each step also carries what came of it (what a command printed, " +
"what a tool answered) and the agent's thinking is included; with view access only, it is the messages and one line per step."}, s.sessionRead)
mcp.AddTool(srv, &mcp.Tool{Name: "folders_list", Title: "List folders", Annotations: readOnly(),
"what a tool answered) and the agent's thinking is included; with view access only, it is the messages and one line per step."}), s.sessionRead)
mcp.AddTool(srv, withIcons(&mcp.Tool{Name: "folders_list", Title: "List folders", Annotations: readOnly(),
Description: "The folders the user's sessions have worked in on each machine, most recent first: where a new session is most likely wanted. " +
"A folder not listed can still be used with session_start by its full path."}, s.foldersList)
mcp.AddTool(srv, &mcp.Tool{Name: "agent_create", Title: "Create a named agent", Annotations: acts(false),
Description: "Create a named agent on an approved home machine with a permanent chat and standing instructions. Needs steer access. The chat starts idle in Ask mode. Use the returned chat URL to open it, or use session_send with its machine and session IDs to assign work."}, s.agentCreate)
mcp.AddTool(srv, &mcp.Tool{Name: "session_start", Title: "Start a session", Annotations: acts(false),
"A folder not listed can still be used with session_start by its full path."}), s.foldersList)
mcp.AddTool(srv, withIcons(&mcp.Tool{Name: "agent_create", Title: "Create a named agent", Annotations: acts(false),
Description: "Create a named agent on an approved home machine with a permanent chat and standing instructions. Needs steer access. The chat starts idle in Ask mode. Use the returned chat URL to open it, or use session_send with its machine and session IDs to assign work."}), s.agentCreate)
mcp.AddTool(srv, withIcons(&mcp.Tool{Name: "session_start", Title: "Start a session", Annotations: acts(false),
Description: "Start a new coding session on one of the user's machines: an agent (Claude Code or Codex) in a folder, with a first prompt. Needs steer access. " +
"The agent then works on the user's machine with the permissions given, so start what the user asked for, where they asked. " +
"permissions decides how much it may do unasked: ask (asks before commands and edits; the default here), accept-edits, auto, or full-access (never asks). " +
"Pass branch to give the session a git worktree of its own on a new branch, leaving the folder's checkout untouched. " +
"Answers with the new session; follow it with session_read."}, s.sessionStart)
mcp.AddTool(srv, &mcp.Tool{Name: "session_answer", Title: "Answer a session", Annotations: acts(true),
"Answers with the new session; follow it with session_read."}), s.sessionStart)
mcp.AddTool(srv, withIcons(&mcp.Tool{Name: "session_answer", Title: "Answer a session", Annotations: acts(true),
Description: "Answer what a session is waiting on the user for: a request for permission, a question, or a plan to approve. Needs steer access. " +
"This decides for the user, on their machine: accepting lets the coding agent run the command, change the files or use the tool it asked about, " +
"and accept_session lets it do the like for the rest of the session without asking. So answer only as the user has told you to, for this request; " +
"show them what is asked (session_read's waitingOn) and ask when they have not said. Declining is always safe. " +
"The answer is recorded as given through this connection, not by the user directly. The first answer wins: if someone answered already, you are told what was decided."}, s.sessionAnswer)
mcp.AddTool(srv, &mcp.Tool{Name: "session_send", Title: "Send a session a message", Annotations: acts(false),
"The answer is recorded as given through this connection, not by the user directly. The first answer wins: if someone answered already, you are told what was decided."}), s.sessionAnswer)
mcp.AddTool(srv, withIcons(&mcp.Tool{Name: "session_send", Title: "Send a session a message", Annotations: acts(false),
Description: "Send a coding session a message, as the user would type it: the next instruction, or a correction while it works. Needs steer access. " +
"The agent acts on it on the user's machine with whatever permissions the session has, so send what the user asked you to say. " +
"While the session is working the message is queued, or steers the turn under way where the agent supports that."}, s.sessionSend)
mcp.AddTool(srv, &mcp.Tool{Name: "session_stop", Title: "Stop a session's turn", Annotations: acts(false),
Description: "Stop what a session is doing now, as the Stop button does. Needs steer access. The session stays, with everything done so far; nothing is undone."}, s.sessionStop)
"While the session is working the message is queued, or steers the turn under way where the agent supports that."}), s.sessionSend)
mcp.AddTool(srv, withIcons(&mcp.Tool{Name: "session_stop", Title: "Stop a session's turn", Annotations: acts(false),
Description: "Stop what a session is doing now, as the Stop button does. Needs steer access. The session stays, with everything done so far; nothing is undone."}), s.sessionStop)
return srv
}

Expand Down
Loading