Files
github--github-mcp-server/pkg/github/ui_capability.go
Matt Holloway a94f95b43f Enhance client support checks for MCP Apps UI rendering (#2051)
* enhance client support checks for MCP Apps UI rendering

* update dependencies and enhance MCP Apps UI support handling

* chore: regenerate license files

Auto-generated by license-check workflow

* retrigger CI

* update test

* introduce constants for client names and remove wrong ide name for mcp apps support

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-02-24 13:41:19 +00:00

33 lines
1.1 KiB
Go

package github
import (
"context"
ghcontext "github.com/github/github-mcp-server/pkg/context"
"github.com/modelcontextprotocol/go-sdk/mcp"
)
// mcpAppsExtensionKey is the capability extension key that clients use to
// advertise MCP Apps UI support.
const mcpAppsExtensionKey = "io.modelcontextprotocol/ui"
// clientSupportsUI reports whether the MCP client that sent this request
// supports MCP Apps UI rendering.
// It checks the context first (set by HTTP/stateless servers from stored
// session capabilities), then falls back to the go-sdk Session (for stdio).
func clientSupportsUI(ctx context.Context, req *mcp.CallToolRequest) bool {
// Check context first (works for HTTP/stateless servers)
if supported, ok := ghcontext.HasUISupport(ctx); ok {
return supported
}
// Fall back to go-sdk session (works for stdio/stateful servers)
if req != nil && req.Session != nil {
params := req.Session.InitializeParams()
if params != nil && params.Capabilities != nil {
_, hasUI := params.Capabilities.Extensions[mcpAppsExtensionKey]
return hasUI
}
}
return false
}