webmcpbridge

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// PriorityLoop is the fallback registration priority used by game.Loop.Run
	// when a game does not attach a full pkg/mcp.Bridge.
	PriorityLoop = 1
	// PriorityBridge is the full pkg/mcp.Bridge registration priority,
	// superseding any game.Loop fallback while attached.
	PriorityBridge = 2
)

Variables

This section is empty.

Functions

func IsSameOriginPath

func IsSameOriginPath(raw string) bool

IsSameOriginPath reports whether raw is a safe same-origin absolute URL path (starts with "/" and not "//", contains no backslashes, whitespace, or control characters).

func Register

func Register(Config) (unregister func())

Register is a no-op outside js/wasm web builds.

Types

type Config

type Config struct {
	// Source identifies who registered the runtime (for example "mcp.Bridge" or "game.Loop").
	Source string
	// Priority selects which active registration wins when more than one is attached.
	Priority int
	// Post schedules fn to run on the engine/graph goroutine (typically core.Scope.Post).
	// When nil, CallTool runs directly.
	Post func(fn func())
	// ListTools returns the tools currently exposed by this registration.
	ListTools func() []ToolInfo
	// CallTool invokes a named tool with JSON object arguments on the engine goroutine
	// and returns its JSON-encoded result.
	CallTool func(ctx context.Context, name string, args json.RawMessage) (json.RawMessage, error)
}

Config registers a runtime's MCP tool dispatcher on window.__nsgoMCP in js/wasm web builds.

type ToolInfo

type ToolInfo struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

ToolInfo describes one game MCP tool exposed through window.__nsgoMCP.listTools().

Jump to

Keyboard shortcuts

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