RegisterUIResources registers MCP App UI resources with the server. These are static resources (not templates) that serve HTML content for MCP App-enabled tools. The HTML is built from React/Primer components in the ui/ directory using `script/build-ui`. Resource metadata follows the stable 2026-01
(s *mcp.Server, readOnly bool)
| 14 | // Resource metadata follows the stable 2026-01-26 MCP Apps spec: |
| 15 | // https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx |
| 16 | func RegisterUIResources(s *mcp.Server, readOnly bool) { |
| 17 | // Register the get_me UI resource |
| 18 | s.AddResource( |
| 19 | &mcp.Resource{ |
| 20 | URI: GetMeUIResourceURI, |
| 21 | Name: "get_me_ui", |
| 22 | Description: "MCP App UI for the get_me tool", |
| 23 | MIMEType: MCPAppMIMEType, |
| 24 | }, |
| 25 | func(_ context.Context, _ *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error) { |
| 26 | html := MustGetUIAsset("get-me.html") |
| 27 | return &mcp.ReadResourceResult{ |
| 28 | Contents: []*mcp.ResourceContents{ |
| 29 | { |
| 30 | URI: GetMeUIResourceURI, |
| 31 | MIMEType: MCPAppMIMEType, |
| 32 | Text: html, |
| 33 | Meta: mcp.Meta{ |
| 34 | "ui": map[string]any{ |
| 35 | // Allow loading images from GitHub's avatar CDN. |
| 36 | "csp": map[string]any{ |
| 37 | "resourceDomains": []string{"https://avatars.githubusercontent.com"}, |
| 38 | }, |
| 39 | // Profile card renders inline within chat without a host border. |
| 40 | "prefersBorder": false, |
| 41 | }, |
| 42 | }, |
| 43 | }, |
| 44 | }, |
| 45 | }, nil |
| 46 | }, |
| 47 | ) |
| 48 | |
| 49 | if readOnly { |
| 50 | return |
| 51 | } |
| 52 | |
| 53 | // Register the issue_write UI resource |
| 54 | s.AddResource( |
| 55 | &mcp.Resource{ |
| 56 | URI: IssueWriteUIResourceURI, |
| 57 | Name: "issue_write_ui", |
| 58 | Description: "MCP App UI for creating and updating GitHub issues", |
| 59 | MIMEType: MCPAppMIMEType, |
| 60 | }, |
| 61 | func(_ context.Context, _ *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error) { |
| 62 | html := MustGetUIAsset("issue-write.html") |
| 63 | return &mcp.ReadResourceResult{ |
| 64 | Contents: []*mcp.ResourceContents{ |
| 65 | { |
| 66 | URI: IssueWriteUIResourceURI, |
| 67 | MIMEType: MCPAppMIMEType, |
| 68 | Text: html, |
| 69 | Meta: mcp.Meta{ |
| 70 | "ui": map[string]any{ |
| 71 | // No external origins required; documents the secure default. |
| 72 | "csp": map[string]any{}, |
| 73 | // Form surface benefits from a host-provided border. |