gui/pkg/mcp/tools_keybinding.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

51 lines
1.6 KiB
Go

// pkg/mcp/tools_keybinding.go
package mcp
import (
"context"
"dappco.re/go/core/gui/pkg/keybinding"
"github.com/modelcontextprotocol/go-sdk/mcp"
)
// --- keybinding_add ---
type KeybindingAddInput struct {
Accelerator string `json:"accelerator"`
Description string `json:"description,omitempty"`
}
type KeybindingAddOutput struct {
Success bool `json:"success"`
}
func (s *Subsystem) keybindingAdd(_ context.Context, _ *mcp.CallToolRequest, input KeybindingAddInput) (*mcp.CallToolResult, KeybindingAddOutput, error) {
_, _, err := s.core.PERFORM(keybinding.TaskAdd{Accelerator: input.Accelerator, Description: input.Description})
if err != nil {
return nil, KeybindingAddOutput{}, err
}
return nil, KeybindingAddOutput{Success: true}, nil
}
// --- keybinding_remove ---
type KeybindingRemoveInput struct {
Accelerator string `json:"accelerator"`
}
type KeybindingRemoveOutput struct {
Success bool `json:"success"`
}
func (s *Subsystem) keybindingRemove(_ context.Context, _ *mcp.CallToolRequest, input KeybindingRemoveInput) (*mcp.CallToolResult, KeybindingRemoveOutput, error) {
_, _, err := s.core.PERFORM(keybinding.TaskRemove{Accelerator: input.Accelerator})
if err != nil {
return nil, KeybindingRemoveOutput{}, err
}
return nil, KeybindingRemoveOutput{Success: true}, nil
}
// --- Registration ---
func (s *Subsystem) registerKeybindingTools(server *mcp.Server) {
mcp.AddTool(server, &mcp.Tool{Name: "keybinding_add", Description: "Register a keyboard shortcut"}, s.keybindingAdd)
mcp.AddTool(server, &mcp.Tool{Name: "keybinding_remove", Description: "Unregister a keyboard shortcut"}, s.keybindingRemove)
}