Skip to content

Commit 163e134

Browse files
Add specific icons for each repository resource type
- repository_content: repo icon - repository_content_branch: git-branch icon - repository_content_commit: git-commit icon (new) - repository_content_tag: tag icon - repository_content_pr: git-pull-request icon Resources now have explicit icons set rather than relying on toolset fallback.
1 parent a8cc231 commit 163e134

File tree

6 files changed

+24
-3
lines changed

6 files changed

+24
-3
lines changed

pkg/github/repository_resource.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"strings"
1515

1616
"github.com/github/github-mcp-server/pkg/inventory"
17+
"github.com/github/github-mcp-server/pkg/octicons"
1718
"github.com/github/github-mcp-server/pkg/raw"
1819
"github.com/github/github-mcp-server/pkg/translations"
1920
"github.com/google/go-github/v79/github"
@@ -37,6 +38,7 @@ func GetRepositoryResourceContent(t translations.TranslationHelperFunc) inventor
3738
Name: "repository_content",
3839
URITemplate: repositoryResourceContentURITemplate.Raw(),
3940
Description: t("RESOURCE_REPOSITORY_CONTENT_DESCRIPTION", "Repository Content"),
41+
Icons: octicons.Icons("repo"),
4042
},
4143
repositoryResourceContentsHandlerFunc(repositoryResourceContentURITemplate),
4244
)
@@ -50,6 +52,7 @@ func GetRepositoryResourceBranchContent(t translations.TranslationHelperFunc) in
5052
Name: "repository_content_branch",
5153
URITemplate: repositoryResourceBranchContentURITemplate.Raw(),
5254
Description: t("RESOURCE_REPOSITORY_CONTENT_BRANCH_DESCRIPTION", "Repository Content for specific branch"),
55+
Icons: octicons.Icons("git-branch"),
5356
},
5457
repositoryResourceContentsHandlerFunc(repositoryResourceBranchContentURITemplate),
5558
)
@@ -63,6 +66,7 @@ func GetRepositoryResourceCommitContent(t translations.TranslationHelperFunc) in
6366
Name: "repository_content_commit",
6467
URITemplate: repositoryResourceCommitContentURITemplate.Raw(),
6568
Description: t("RESOURCE_REPOSITORY_CONTENT_COMMIT_DESCRIPTION", "Repository Content for specific commit"),
69+
Icons: octicons.Icons("git-commit"),
6670
},
6771
repositoryResourceContentsHandlerFunc(repositoryResourceCommitContentURITemplate),
6872
)
@@ -76,6 +80,7 @@ func GetRepositoryResourceTagContent(t translations.TranslationHelperFunc) inven
7680
Name: "repository_content_tag",
7781
URITemplate: repositoryResourceTagContentURITemplate.Raw(),
7882
Description: t("RESOURCE_REPOSITORY_CONTENT_TAG_DESCRIPTION", "Repository Content for specific tag"),
83+
Icons: octicons.Icons("tag"),
7984
},
8085
repositoryResourceContentsHandlerFunc(repositoryResourceTagContentURITemplate),
8186
)
@@ -89,6 +94,7 @@ func GetRepositoryResourcePrContent(t translations.TranslationHelperFunc) invent
8994
Name: "repository_content_pr",
9095
URITemplate: repositoryResourcePrContentURITemplate.Raw(),
9196
Description: t("RESOURCE_REPOSITORY_CONTENT_PR_DESCRIPTION", "Repository Content for specific pull request"),
97+
Icons: octicons.Icons("git-pull-request"),
9298
},
9399
repositoryResourceContentsHandlerFunc(repositoryResourcePrContentURITemplate),
94100
)

pkg/inventory/registry.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,31 @@ func (r *Inventory) RegisterTools(ctx context.Context, s *mcp.Server, deps any)
178178

179179
// RegisterResourceTemplates registers all available resource templates with the server.
180180
// The context is used for feature flag evaluation.
181+
// Icons are automatically applied from the toolset metadata if not already set.
181182
func (r *Inventory) RegisterResourceTemplates(ctx context.Context, s *mcp.Server, deps any) {
182183
for _, res := range r.AvailableResourceTemplates(ctx) {
183-
s.AddResourceTemplate(&res.Template, res.Handler(deps))
184+
// Make a shallow copy to avoid mutating the original
185+
templateCopy := res.Template
186+
// Apply icons from toolset metadata if not already set
187+
if len(templateCopy.Icons) == 0 {
188+
templateCopy.Icons = res.Toolset.Icons()
189+
}
190+
s.AddResourceTemplate(&templateCopy, res.Handler(deps))
184191
}
185192
}
186193

187194
// RegisterPrompts registers all available prompts with the server.
188195
// The context is used for feature flag evaluation.
196+
// Icons are automatically applied from the toolset metadata if not already set.
189197
func (r *Inventory) RegisterPrompts(ctx context.Context, s *mcp.Server) {
190198
for _, prompt := range r.AvailablePrompts(ctx) {
191-
s.AddPrompt(&prompt.Prompt, prompt.Handler)
199+
// Make a shallow copy to avoid mutating the original
200+
promptCopy := prompt.Prompt
201+
// Apply icons from toolset metadata if not already set
202+
if len(promptCopy.Icons) == 0 {
203+
promptCopy.Icons = prompt.Toolset.Icons()
204+
}
205+
s.AddPrompt(&promptCopy, prompt.Handler)
192206
}
193207
}
194208

324 Bytes
Loading
448 Bytes
Loading

pkg/octicons/octicons_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestEmbeddedIconsExist(t *testing.T) {
108108
expectedIcons := []string{
109109
"apps", "beaker", "bell", "check-circle", "codescan",
110110
"comment-discussion", "copilot", "dependabot", "file", "git-branch",
111-
"git-merge", "git-pull-request", "issue-opened", "logo-gist", "mark-github",
111+
"git-commit", "git-merge", "git-pull-request", "issue-opened", "logo-gist", "mark-github",
112112
"organization", "people", "person", "project", "repo", "repo-forked",
113113
"shield", "shield-lock", "star", "star-fill", "tag", "tools", "workflow",
114114
}

script/fetch-icons

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ DEFAULT_ICONS=(
2525
dependabot
2626
file
2727
git-branch
28+
git-commit
2829
git-merge
2930
git-pull-request
3031
issue-opened

0 commit comments

Comments
 (0)