gui/pkg/mcp/tools_environment.go
Snider b559562dd9
Some checks failed
Security Scan / security (pull_request) Failing after 28s
Test / test (pull_request) Failing after 1m59s
fix(dx): use coreerr.E() and go-io, update CLAUDE.md, add tests
- Replace 90+ fmt.Errorf calls with coreerr.E() from go-log across
  display, window, systray, keybinding, contextmenu, and mcp packages
- Replace os.ReadFile/WriteFile/MkdirAll with coreio.Local in
  window/layout.go and window/state.go
- Update CLAUDE.md: fix key files table for new package structure,
  document error handling and file I/O conventions, add missing deps
- Add 37 tests for window package (task handlers, persistence,
  tiling modes, snap positions, workflow layouts)
- Window coverage: 47.1% → 69.8%

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 09:05:35 +00:00

55 lines
1.7 KiB
Go

// pkg/mcp/tools_environment.go
package mcp
import (
"context"
"forge.lthn.ai/core/gui/pkg/environment"
coreerr "forge.lthn.ai/core/go-log"
"github.com/modelcontextprotocol/go-sdk/mcp"
)
// --- theme_get ---
type ThemeGetInput struct{}
type ThemeGetOutput struct {
Theme environment.ThemeInfo `json:"theme"`
}
func (s *Subsystem) themeGet(_ context.Context, _ *mcp.CallToolRequest, _ ThemeGetInput) (*mcp.CallToolResult, ThemeGetOutput, error) {
result, _, err := s.core.QUERY(environment.QueryTheme{})
if err != nil {
return nil, ThemeGetOutput{}, err
}
theme, ok := result.(environment.ThemeInfo)
if !ok {
return nil, ThemeGetOutput{}, coreerr.E("mcp.themeGet", "unexpected result type", nil)
}
return nil, ThemeGetOutput{Theme: theme}, nil
}
// --- theme_system ---
type ThemeSystemInput struct{}
type ThemeSystemOutput struct {
Info environment.EnvironmentInfo `json:"info"`
}
func (s *Subsystem) themeSystem(_ context.Context, _ *mcp.CallToolRequest, _ ThemeSystemInput) (*mcp.CallToolResult, ThemeSystemOutput, error) {
result, _, err := s.core.QUERY(environment.QueryInfo{})
if err != nil {
return nil, ThemeSystemOutput{}, err
}
info, ok := result.(environment.EnvironmentInfo)
if !ok {
return nil, ThemeSystemOutput{}, coreerr.E("mcp.themeSystem", "unexpected result type", nil)
}
return nil, ThemeSystemOutput{Info: info}, nil
}
// --- Registration ---
func (s *Subsystem) registerEnvironmentTools(server *mcp.Server) {
mcp.AddTool(server, &mcp.Tool{Name: "theme_get", Description: "Get the current application theme"}, s.themeGet)
mcp.AddTool(server, &mcp.Tool{Name: "theme_system", Description: "Get system environment and theme information"}, s.themeSystem)
}