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>
31 lines
821 B
Go
31 lines
821 B
Go
// pkg/mcp/tools_lifecycle.go
|
|
package mcp
|
|
|
|
import (
|
|
"context"
|
|
|
|
"dappco.re/go/core/gui/pkg/lifecycle"
|
|
"github.com/modelcontextprotocol/go-sdk/mcp"
|
|
)
|
|
|
|
// --- app_quit ---
|
|
|
|
type AppQuitInput struct{}
|
|
type AppQuitOutput struct {
|
|
Success bool `json:"success"`
|
|
}
|
|
|
|
func (s *Subsystem) appQuit(_ context.Context, _ *mcp.CallToolRequest, _ AppQuitInput) (*mcp.CallToolResult, AppQuitOutput, error) {
|
|
// Broadcast the will-terminate action which triggers application shutdown
|
|
err := s.core.ACTION(lifecycle.ActionWillTerminate{})
|
|
if err != nil {
|
|
return nil, AppQuitOutput{}, err
|
|
}
|
|
return nil, AppQuitOutput{Success: true}, nil
|
|
}
|
|
|
|
// --- Registration ---
|
|
|
|
func (s *Subsystem) registerLifecycleTools(server *mcp.Server) {
|
|
mcp.AddTool(server, &mcp.Tool{Name: "app_quit", Description: "Quit the application"}, s.appQuit)
|
|
}
|