Documentation
¶
Overview ¶
Package gosdk adapts gomukit widgets to the official Go MCP SDK (github.com/modelcontextprotocol/go-sdk). It is the only gomukit package that imports the SDK; the core stays SDK-agnostic.
Typical wiring:
table := &gomukit.Table{URI: "ui://demo/users", Columns: ...}
server := mcp.NewServer(&mcp.Implementation{Name: "demo"}, gosdk.EnableUI(nil))
gosdk.AddWidgetToolFor(server, table, &mcp.Tool{Name: "list_users"}, listUsers)
Index ¶
- func AddWidget(s *mcp.Server, w gomukit.Widget) error
- func AddWidgetTool(s *mcp.Server, w gomukit.Widget, t *mcp.Tool, h mcp.ToolHandler) error
- func AddWidgetToolFor[In, Out any](s *mcp.Server, w gomukit.Widget, t *mcp.Tool, h mcp.ToolHandlerFor[In, Out]) error
- func AppOnly(t *mcp.Tool, w gomukit.Widget)
- func ClientSupportsUI(ss *mcp.ServerSession) bool
- func EnableUI(opts *mcp.ServerOptions) *mcp.ServerOptions
- func WithAppData(res *mcp.CallToolResult, data map[string]any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddWidget ¶
AddWidget registers w's template as a ui:// resource on s. The document is rendered once and served from memory. Registering the same URI on the same server again is a no-op.
func AddWidgetTool ¶
AddWidgetTool registers t with its _meta linked to w (registering w's resource first if needed) and installs the raw handler h.
func AddWidgetToolFor ¶
func AddWidgetToolFor[In, Out any](s *mcp.Server, w gomukit.Widget, t *mcp.Tool, h mcp.ToolHandlerFor[In, Out]) error
AddWidgetToolFor is AddWidgetTool with the SDK's typed-handler variant: input/output schemas are inferred from In and Out.
func AppOnly ¶
AppOnly links t to w and marks it app-only (visibility: ["app"]): callable from the widget UI, hidden from the model. Use it for row-action and submit tools the model should not invoke directly. Register the tool separately (e.g. via AddWidgetTool, which keeps the merged visibility).
func ClientSupportsUI ¶
func ClientSupportsUI(ss *mcp.ServerSession) bool
ClientSupportsUI reports whether the session's client declared the MCP Apps extension. Servers MAY branch on it (e.g. return richer text for non-UI clients); attaching _meta.ui unconditionally is also spec-legal — hosts ignore unknown metadata.
func EnableUI ¶
func EnableUI(opts *mcp.ServerOptions) *mcp.ServerOptions
EnableUI declares the MCP Apps extension (io.modelcontextprotocol/ui) in the server capabilities. It mutates and returns opts so it composes with mcp.NewServer; passing nil allocates fresh options.
Note: explicitly setting Capabilities disables the SDK's historical default of advertising {"logging":{}}; tool/resource capabilities are still inferred from registered features.
func WithAppData ¶
func WithAppData(res *mcp.CallToolResult, data map[string]any)
WithAppData merges data into the result's _meta. Result _meta is delivered to the widget but hidden from the model, per the MCP Apps spec.
Types ¶
This section is empty.