gosdk

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddWidget

func AddWidget(s *mcp.Server, w gomukit.Widget) error

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

func AddWidgetTool(s *mcp.Server, w gomukit.Widget, t *mcp.Tool, h mcp.ToolHandler) error

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

func AppOnly(t *mcp.Tool, w gomukit.Widget)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL