gui/pkg/mcp/tools_browser.go
Snider 62ec735c10
Some checks failed
Security Scan / security (push) Has been cancelled
Test / test (push) Has been cancelled
refactor: AX compliance sweep — replace banned stdlib imports with core primitives
Replaced fmt, strings, sort, os, io, sync, encoding/json, path/filepath,
errors, log, reflect with core.Sprintf, core.E, core.Contains, core.Trim,
core.Split, core.Join, core.JoinPath, slices.Sort, c.Fs(), c.Lock(),
core.JSONMarshal, core.ReadAll and other CoreGO v0.8.0 primitives.

Framework boundary exceptions preserved where stdlib types are required
by external interfaces (Gin, net/http, CGo, Wails, bubbletea).

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-13 09:32:01 +01:00

32 lines
873 B
Go

// pkg/mcp/tools_browser.go
package mcp
import (
"context"
"dappco.re/go/core/gui/pkg/browser"
"github.com/modelcontextprotocol/go-sdk/mcp"
)
// --- browser_open_url ---
type BrowserOpenURLInput struct {
URL string `json:"url"`
}
type BrowserOpenURLOutput struct {
Success bool `json:"success"`
}
func (s *Subsystem) browserOpenURL(_ context.Context, _ *mcp.CallToolRequest, input BrowserOpenURLInput) (*mcp.CallToolResult, BrowserOpenURLOutput, error) {
_, _, err := s.core.PERFORM(browser.TaskOpenURL{URL: input.URL})
if err != nil {
return nil, BrowserOpenURLOutput{}, err
}
return nil, BrowserOpenURLOutput{Success: true}, nil
}
// --- Registration ---
func (s *Subsystem) registerBrowserTools(server *mcp.Server) {
mcp.AddTool(server, &mcp.Tool{Name: "browser_open_url", Description: "Open a URL in the default system browser"}, s.browserOpenURL)
}