File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments