Documentation
¶
Overview ¶
Package browser implements a Resolver that asks the user via an ephemeral local HTTP server and a browser-rendered form.
Lifecycle of a single Ask call:
- bind an OS-assigned localhost port (loopback only)
- publish a one-shot HTTP server with two handlers: - GET / renders the form for the current request - POST /submit accepts the user's selections and signals done
- attempt to open the URL in the user's browser via OpenURL
- block until the form is submitted, the user cancels, or ctx is done
- tear down the HTTP server and return the answers
Only one Ask runs at a time per Resolver instance (guarded by a mutex) so a misbehaving model issuing parallel tool calls won't race for the same port. Tools may call Ask serially as much as they like.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Resolver ¶
type Resolver struct {
// Host is the bind address; defaults to 127.0.0.1.
Host string
// OpenURL is the function used to launch the user's browser. Defaults
// to platform-appropriate `open` / `xdg-open` / `rundll32`. Tests can
// inject a stub.
OpenURL func(url string) error
// Logger receives one-line status messages (server start, browser
// launch, errors). When nil, messages go to io.Discard so an MCP
// server using stdio doesn't get polluted output.
Logger io.Writer
// contains filtered or unexported fields
}
Resolver implements server.Resolver by hosting an ephemeral form.
func New ¶
func New() *Resolver
New returns a Resolver with defaults appropriate for stdio MCP usage: loopback binding, platform-appropriate browser launcher, no logging.
func (*Resolver) Ask ¶
func (r *Resolver) Ask(ctx context.Context, req askuserquestion.Request) ([]askuserquestion.Answer, error)
Ask implements server.Resolver.
Click to show internal directories.
Click to hide internal directories.