Files
github--github-mcp-server/docs/toolsets-and-icons.md
Sam Morrow 6b3c375492 feat: Add Octicon icons to MCP tools, resources, and prompts (#1603)
* 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.

* Update third-party licenses for SDK upgrade

* Address review feedback: enum size validation, mutation fix, tests

- Replace runtime size validation with compile-time enum type (Size with SizeSM=16, SizeLG=24)
- Fix RegisterFunc mutation by making shallow copy of tool before modifying Icons
- Add comprehensive tests for octicons package (URL, Icons, Size constants)
- Add toolsets tests for ToolsetMetadata.Icons(), RegisterFunc mutation prevention,
  and existing icon preservation
- Improve icon choices for better visual semantics:
  - actions: play → workflow (more specific to GitHub Actions)
  - secret_protection: key → shield-lock (better represents protection)
  - gists: code → logo-gist (dedicated gist icon exists)

* Add GitHub mark icon to server metadata

Add the mark-github octicon to the server's Implementation struct
so that MCP clients can display the GitHub logo for this server.
The icon is provided in both 16x16 and 24x24 SVG sizes.

* Fix rebase conflicts: use Registry methods and NullTranslationHelper

- Remove duplicate old toolsets functions (AvailableToolsets, GetValidToolsetIDs, GetDefaultToolsetIDs)
- Use Registry.AvailableToolsets() and Registry.HasToolset() instead
- Replace stubTranslator with translations.NullTranslationHelper
- Use new SDK Capabilities struct instead of deprecated HasTools/HasResources/HasPrompts
- Add icon-related tests to registry_test.go

* Use embedded data URIs for Octicon icons

- Embed SVG icons using go:embed for offline use and faster loading
- Convert icons to base64 data URIs at runtime
- Fall back to CDN URL for non-embedded icons
- Add test to verify all toolset icons are properly embedded
- 44 SVG files (22 icons × 2 sizes) totaling ~27KB

* Convert icons from SVG to PNG for MCP client compatibility

MCP clients don't support SVG data URIs, so convert all embedded icons
to PNG format using rsvg-convert.

Changes:
- Convert all 44 SVG icons to PNG format
- Add 8 new icons: copilot, git-merge, repo-forked, star-fill
- Update octicons.go to use PNG MIME type
- Add script/fetch-icons for easy icon management
- Update tests and toolsnaps for PNG format

* Add mark-github icon for server metadata

* Add light/dark theme icons for tools, resources, and prompts

- Switch from size-based (16/24px) to theme-based (light/dark) icons
- Use only 16x16 icons for smaller bundle size
- Generate white (inverted) icons for dark theme backgrounds
- Add icons to resources and prompts (auto-applied from toolset metadata)
- Add 'file' icon for repository content resources
- Update fetch-icons script to generate both theme variants

* Use 24px icons with SVG fill modification for themes

- Switch from 16px to 24px icons for better visibility
- Use SVG fill attribute (#24292f for light, #ffffff for dark) instead
  of ImageMagick color inversion for cleaner theme variants
- Remove ImageMagick dependency from fetch-icons script

* 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.

* fix: restore Icon fields to toolset metadata and add icons to docs

- Add Icon field to all ToolsetMetadata definitions (lost during rebase conflict resolution)
- Update doc generator to include Octicon icons in toolsets table
- Update doc generator to include icons in tool section headers
- Use Primer Octicons CDN for GitHub markdown compatibility

* feat: add icons to individual tools in documentation

* fix: use repo-local icons with picture element for GitHub theme support

- Reference icons from pkg/octicons/icons/ instead of external CDN
- Use picture element with prefers-color-scheme for light/dark mode
- GitHub markdown renderer will display these correctly

* fix: remove redundant icons from individual tools

Icons are kept on section headers and toolsets table only - having the same
icon on every tool within a section was visually noisy and redundant.

* Add icons to remote server toolsets documentation

* Fix icon paths for docs/remote-server.md

* Add remote-only toolsets with auto-generated documentation and icons guide

- Add ToolsetMetadataCopilot, ToolsetMetadataCopilotSpaces, ToolsetMetadataSupportSearch
- Add RemoteOnlyToolsets() function to return remote-only toolset metadata
- Update doc generator to auto-generate remote-only toolsets table with icons
- Create docs/toolsets-and-icons.md explaining how to add icons to toolsets
- Add link to icons guide in CONTRIBUTING.md

* Add icon validation tests and single source of truth for required icons

- Add pkg/octicons/required_icons.txt as single source of truth for icons
- Add RequiredIcons() function to read the required icons list
- Update script/fetch-icons to read from required_icons.txt
- Update octicons_test.go to use RequiredIcons() instead of hardcoded list
- Add pkg/github/toolset_icons_test.go with:
  - TestAllToolsetIconsExist: validates all toolset icons are embedded
  - TestToolsetMetadataHasIcons: ensures all toolsets have icons set
- Add 'book' icon for SupportSearch toolset
- Update docs/toolsets-and-icons.md with fetch-icons and CI validation docs

* fix: remove unused icon parameter from writeToolDoc

- Remove unused 'icon' parameter from writeToolDoc function signature
- Fix whitespace inconsistency in octicons_test.go
- Fixes lint failure: unused-parameter revive error

* fix: combine icon with name column in remote docs for proper table rendering

- Move icon from separate column to Name column with <br> separator
- Keep <picture> element for light/dark theme support
- Remove empty icon column that was collapsing to zero width
- Remove unused octiconSimpleImg function
2025-12-17 17:31:13 +01:00

6.0 KiB

Toolsets and Icons

This document explains how to work with toolsets and icons in the GitHub MCP Server.

Toolset Overview

Toolsets are logical groupings of related tools. Each toolset has metadata defined in pkg/github/tools.go:

ToolsetMetadataRepos = inventory.ToolsetMetadata{
    ID:          "repos",
    Description: "GitHub Repository related tools",
    Default:     true,
    Icon:        "repo",
}

Toolset Fields

Field Type Description
ID ToolsetID Unique identifier used in URLs and CLI flags (e.g., repos, issues)
Description string Human-readable description shown in documentation
Default bool Whether this toolset is enabled by default
Icon string Octicon name for visual representation in MCP clients

Adding Icons to Toolsets

Icons help users quickly identify toolsets in MCP-compatible clients. We use Primer Octicons for all icons.

Step 1: Choose an Octicon

Browse the Octicon gallery and select an appropriate icon. Use the base name without size suffix (e.g., repo not repo-16).

Step 2: Add Icon to Required Icons List

Icons are defined in pkg/octicons/required_icons.txt, which is the single source of truth for which icons should be embedded:

# Required icons for the GitHub MCP Server
# Add new icons below (one per line)
repo
issue-opened
git-pull-request
your-new-icon  # Add your icon here

Step 3: Fetch the Icon Files

Run the fetch-icons script to download and convert the icon:

# Fetch a specific icon
script/fetch-icons your-new-icon

# Or fetch all required icons
script/fetch-icons

This script:

  • Downloads the 24px SVG from Primer Octicons
  • Converts to PNG with light theme (dark icons for light backgrounds)
  • Converts to PNG with dark theme (white icons for dark backgrounds)
  • Saves both variants to pkg/octicons/icons/

Requirements: The script requires rsvg-convert:

  • Ubuntu/Debian: sudo apt-get install librsvg2-bin
  • macOS: brew install librsvg

Step 4: Update the Toolset Metadata

Add or update the Icon field in the toolset definition:

// In pkg/github/tools.go
ToolsetMetadataRepos = inventory.ToolsetMetadata{
    ID:          "repos",
    Description: "GitHub Repository related tools",
    Default:     true,
    Icon:        "repo",  // Add this line
}

Step 5: Regenerate Documentation

Run the documentation generator to update all markdown files:

go run ./cmd/github-mcp-server generate-docs

This updates icons in:

  • README.md - Toolsets table and tool section headers
  • docs/remote-server.md - Remote toolsets table

Remote-Only Toolsets

Some toolsets are only available in the remote GitHub MCP Server (hosted at api.githubcopilot.com). These are defined in pkg/github/tools.go with their icons, but are not registered with the local server:

// Remote-only toolsets
ToolsetMetadataCopilot = inventory.ToolsetMetadata{
    ID:          "copilot",
    Description: "Copilot related tools",
    Icon:        "copilot",
}

The RemoteOnlyToolsets() function returns the list of these toolsets for documentation generation.

To add a new remote-only toolset:

  1. Add the metadata definition in pkg/github/tools.go
  2. Add it to the slice returned by RemoteOnlyToolsets()
  3. Regenerate documentation

Tool Icon Inheritance

Individual tools inherit icons from their parent toolset. When a tool is registered with a toolset, its icons are automatically set:

// In pkg/inventory/server_tool.go
toolCopy.Icons = tool.Toolset.Icons()

This means you only need to set the icon once on the toolset, and all tools in that toolset will display the same icon.

How Icons Work in MCP

The MCP protocol supports tool icons via the icons field. We provide icons in two formats:

  1. Data URIs - Base64-encoded PNG images embedded in the tool definition
  2. Light/Dark variants - Both theme variants are provided for proper display

The octicons.Icons() function generates the MCP-compatible icon objects:

// Returns []mcp.Icon with both light and dark variants
icons := octicons.Icons("repo")

Existing Toolset Icons

Toolset Octicon Name
Context person
Repositories repo
Issues issue-opened
Pull Requests git-pull-request
Git git-branch
Users people
Organizations organization
Actions workflow
Code Security codescan
Secret Protection shield-lock
Dependabot dependabot
Discussions comment-discussion
Gists logo-gist
Security Advisories shield
Projects project
Labels tag
Stargazers star
Notifications bell
Dynamic tools
Copilot copilot
Support Search book

Troubleshooting

Icons not appearing in documentation

  1. Ensure PNG files exist in pkg/octicons/icons/ with -light.png and -dark.png suffixes
  2. Run go run ./cmd/github-mcp-server generate-docs to regenerate
  3. Check that the Icon field is set on the toolset metadata

Icons not appearing in MCP clients

  1. Verify the client supports MCP tool icons
  2. Check that the octicons package is properly generating base64 data URIs
  3. Ensure the icon name matches a file in pkg/octicons/icons/

CI Validation

The following tests run in CI to catch icon issues early:

pkg/octicons.TestEmbeddedIconsExist

Verifies that all icons listed in pkg/octicons/required_icons.txt have corresponding PNG files embedded.

pkg/github.TestAllToolsetIconsExist

Verifies that all toolset Icon fields reference icons that are properly embedded.

pkg/github.TestToolsetMetadataHasIcons

Ensures all toolsets have an Icon field set.

If any of these tests fail:

  1. Add the missing icon to pkg/octicons/required_icons.txt
  2. Run script/fetch-icons to download the icon
  3. Commit the new icon files