Skip to content

Commit 09fd6ba

Browse files
tommaso-moromattdholloway
authored andcommitted
add avatar resource domain
1 parent 206f7f3 commit 09fd6ba

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

pkg/github/ui_resources.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package github
2+
3+
import (
4+
"context"
5+
6+
"github.com/modelcontextprotocol/go-sdk/mcp"
7+
)
8+
9+
// RegisterUIResources registers MCP App UI resources with the server.
10+
// These are static resources (not templates) that serve HTML content for
11+
// MCP App-enabled tools.
12+
func RegisterUIResources(s *mcp.Server) {
13+
// Register the get_me UI resource
14+
s.AddResource(
15+
&mcp.Resource{
16+
URI: GetMeUIResourceURI,
17+
Name: "get_me_ui",
18+
Description: "MCP App UI for the get_me tool",
19+
MIMEType: "text/html",
20+
},
21+
func(_ context.Context, _ *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error) {
22+
return &mcp.ReadResourceResult{
23+
// MCP Apps UI metadata - CSP configuration to allow loading GitHub avatars
24+
// See: https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/draft/apps.mdx
25+
Meta: mcp.Meta{
26+
"ui": map[string]any{
27+
"csp": map[string]any{
28+
// Allow loading images from GitHub's avatar CDN
29+
"resourceDomains": []string{"https://avatars.githubusercontent.com"},
30+
},
31+
},
32+
},
33+
Contents: []*mcp.ResourceContents{
34+
{
35+
URI: GetMeUIResourceURI,
36+
MIMEType: "text/html",
37+
Text: GetMeUIHTML,
38+
},
39+
},
40+
}, nil
41+
},
42+
)
43+
}

0 commit comments

Comments
 (0)