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).
(ctx context.Context, req *mcp.CallToolRequest)
| 19 | // It checks the context first (set by HTTP/stateless servers from stored |
| 20 | // session capabilities), then falls back to the go-sdk Session (for stdio). |
| 21 | func clientSupportsUI(ctx context.Context, req *mcp.CallToolRequest) bool { |
| 22 | // Check context first (works for HTTP/stateless servers) |
| 23 | if supported, ok := ghcontext.HasUISupport(ctx); ok { |
| 24 | return supported |
| 25 | } |
| 26 | // Fall back to go-sdk session (works for stdio/stateful servers) |
| 27 | if req != nil && req.Session != nil { |
| 28 | params := req.Session.InitializeParams() |
| 29 | if params != nil && params.Capabilities != nil { |
| 30 | _, hasUI := params.Capabilities.Extensions[mcpAppsExtensionKey] |
| 31 | return hasUI |
| 32 | } |
| 33 | } |
| 34 | return false |
| 35 | } |
| 36 | |
| 37 | // uiSubmitted reports whether the call is itself an MCP App form submission. |
| 38 | // The form re-invokes its tool with _ui_submitted=true; such calls must execute |
no outgoing calls