Register MCP App UI resources in shared server constructor · github/github-mcp-server@3fbf64f · GitHub
Skip to content

Commit 3fbf64f

Browse files
Register MCP App UI resources in shared server constructor
The remote/HTTP server never called RegisterUIResources, so when the remote_mcp_ui_apps feature flag was enabled per-request, tools like issue_write and create_pull_request would advertise a ui:// resource URI in their _meta.ui block but the resource itself was not registered. The client's follow-up resources/read call then failed with -32002 'Resource not found' (the error surfaced as 'Error loading MCP App: MPC -32002: Resource not found' in VS Code). The stdio bootstrap also gated registration on featureChecker called with context.Background(), which can't see per-request flag overrides. Move RegisterUIResources into pkg/github.NewMCPServer (the shared constructor used by both stdio and HTTP), gated only on UIAssetsAvailable(). The resources are inert static HTML; the inventory still strips _meta.ui from tools per-request via stripMCPAppsMetadata, so the URI is only advertised to clients when the flag is on for that request. Fixes #2467 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f5f9c72 commit 3fbf64f

3 files changed

Lines changed: 135 additions & 9 deletions

File tree

internal/ghmcp/server.go

Lines changed: 0 additions & 9 deletions

pkg/github/server.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ func NewMCPServer(ctx context.Context, cfg *MCPServerConfig, deps ToolDependenci
102102
// Register GitHub tools/resources/prompts from the inventory.
103103
inv.RegisterAll(ctx, ghServer, deps)
104104

105+
// Register MCP App UI resources whenever the embedded UI assets are
106+
// available. The resources are static HTML and are only referenced by
107+
// tools when the remote_mcp_ui_apps feature flag is enabled for the
108+
// request (the inventory strips the _meta.ui block otherwise via
109+
// stripMCPAppsMetadata), so registering them unconditionally is safe.
110+
// Registering here — rather than in the stdio bootstrap — ensures the
111+
// remote/HTTP server also serves them, fixing the "-32002 Resource not
112+
// found" error clients hit after the tool returns a ui:// URI.
113+
if UIAssetsAvailable() {
114+
RegisterUIResources(ghServer)
115+
}
116+
105117
return ghServer, nil
106118
}
107119

pkg/github/ui_resources_test.go

Lines changed: 123 additions & 0 deletions

0 commit comments

Comments
 (0)