Skip to content

Commit 0164670

Browse files
Upgrade MCP Go SDK to v1.2.0-pre.1 and add Octicon icons to tools
- Upgrade MCP Go SDK from v1.1.0 to v1.2.0-pre.1 for Icon support - Add Icon field to ToolsetMetadata for Octicon name assignment - Add OcticonURL() helper to generate CDN URLs for Octicon SVGs - Add Icons() method on ToolsetMetadata to generate MCP Icon objects - Apply icons automatically in RegisterFunc when tool is registered - Add icons to all 22 toolset metadata constants with appropriate Octicons - Update server.go to use new Capabilities API (fixes deprecation warnings) This demonstrates how the toolsets refactor makes adding new features simpler: icons are defined once in ToolsetMetadata and automatically applied to all tools in that toolset during registration.
1 parent ce2e4f9 commit 0164670

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ require (
3737
github.com/go-viper/mapstructure/v2 v2.4.0
3838
github.com/google/go-querystring v1.1.0 // indirect
3939
github.com/inconshreveable/mousetrap v1.1.0 // indirect
40-
github.com/modelcontextprotocol/go-sdk v1.1.0
40+
github.com/modelcontextprotocol/go-sdk v1.2.0-pre.1
4141
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
4242
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
4343
github.com/rogpeppe/go-internal v1.13.1 // indirect

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ github.com/go-openapi/swag v0.21.1 h1:wm0rhTb5z7qpJRHBdPOMuY4QjVUMbF6/kwoYeRAOrK
1717
github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
1818
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
1919
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
20+
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
21+
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
2022
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
2123
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
2224
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
@@ -55,8 +57,8 @@ github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwX
5557
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
5658
github.com/migueleliasweb/go-github-mock v1.3.0 h1:2sVP9JEMB2ubQw1IKto3/fzF51oFC6eVWOOFDgQoq88=
5759
github.com/migueleliasweb/go-github-mock v1.3.0/go.mod h1:ipQhV8fTcj/G6m7BKzin08GaJ/3B5/SonRAkgrk0zCY=
58-
github.com/modelcontextprotocol/go-sdk v1.1.0 h1:Qjayg53dnKC4UZ+792W21e4BpwEZBzwgRW6LrjLWSwA=
59-
github.com/modelcontextprotocol/go-sdk v1.1.0/go.mod h1:6fM3LCm3yV7pAs8isnKLn07oKtB0MP9LHd3DfAcKw10=
60+
github.com/modelcontextprotocol/go-sdk v1.2.0-pre.1 h1:14+JrlEIFvUmbu5+iJzWPLk8CkpvegfKr42oXyjp3O4=
61+
github.com/modelcontextprotocol/go-sdk v1.2.0-pre.1/go.mod h1:6fM3LCm3yV7pAs8isnKLn07oKtB0MP9LHd3DfAcKw10=
6062
github.com/muesli/cache2go v0.0.0-20221011235721-518229cd8021 h1:31Y+Yu373ymebRdJN1cWLLooHH8xAr0MhKTEJGV/87g=
6163
github.com/muesli/cache2go v0.0.0-20221011235721-518229cd8021/go.mod h1:WERUkUryfUWlrHnFSO/BEUZ+7Ns8aZy7iVOGewxKzcc=
6264
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=

pkg/inventory/server_tool.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package inventory
33
import (
44
"context"
55
"encoding/json"
6+
"fmt"
67

78
"github.com/modelcontextprotocol/go-sdk/mcp"
89
)
@@ -26,6 +27,35 @@ type ToolsetMetadata struct {
2627
Description string
2728
// Default indicates this toolset should be enabled by default
2829
Default bool
30+
// Icon is the name of the Octicon to use for tools in this toolset.
31+
// Use the base name without size suffix, e.g., "repo" not "repo-16".
32+
// See https://primer.style/foundations/icons for available icons.
33+
Icon string
34+
}
35+
36+
// OcticonURL returns the CDN URL for a GitHub Octicon SVG. Size should be 16 or 24.
37+
func OcticonURL(name string, size int) string {
38+
return fmt.Sprintf("https://raw.githubusercontent.com/primer/octicons/main/icons/%s-%d.svg", name, size)
39+
}
40+
41+
// Icons returns MCP Icon objects for this toolset, or nil if no icon is set.
42+
// Icons are provided in both 16x16 and 24x24 sizes.
43+
func (tm ToolsetMetadata) Icons() []mcp.Icon {
44+
if tm.Icon == "" {
45+
return nil
46+
}
47+
return []mcp.Icon{
48+
{
49+
Source: OcticonURL(tm.Icon, 16),
50+
MIMEType: "image/svg+xml",
51+
Sizes: []string{"16x16"},
52+
},
53+
{
54+
Source: OcticonURL(tm.Icon, 24),
55+
MIMEType: "image/svg+xml",
56+
Sizes: []string{"24x24"},
57+
},
58+
}
2959
}
3060

3161
// ServerTool represents an MCP tool with metadata and a handler generator function.
@@ -81,9 +111,14 @@ func (st *ServerTool) Handler(deps any) mcp.ToolHandler {
81111
}
82112

83113
// RegisterFunc registers the tool with the server using the provided dependencies.
114+
// Icons are automatically applied from the toolset metadata if not already set.
84115
// Panics if the tool has no handler - all tools should have handlers.
85116
func (st *ServerTool) RegisterFunc(s *mcp.Server, deps any) {
86117
handler := st.Handler(deps) // This will panic if HandlerFunc is nil
118+
// Apply icons from toolset metadata if tool doesn't have icons set
119+
if len(st.Tool.Icons) == 0 {
120+
st.Tool.Icons = st.Toolset.Icons()
121+
}
87122
s.AddTool(&st.Tool, handler)
88123
}
89124

0 commit comments

Comments
 (0)