1package proto
2
3import "fmt"
4
5// MCPState represents the current state of an MCP client
6type MCPState int
7
8const (
9 MCPStateDisabled MCPState = iota
10 MCPStateStarting
11 MCPStateConnected
12 MCPStateError
13)
14
15func (s MCPState) MarshalText() ([]byte, error) {
16 return []byte(s.String()), nil
17}
18
19func (s *MCPState) UnmarshalText(data []byte) error {
20 switch string(data) {
21 case "disabled":
22 *s = MCPStateDisabled
23 case "starting":
24 *s = MCPStateStarting
25 case "connected":
26 *s = MCPStateConnected
27 case "error":
28 *s = MCPStateError
29 default:
30 return fmt.Errorf("unknown mcp state: %s", data)
31 }
32 return nil
33}
34
35func (s MCPState) String() string {
36 switch s {
37 case MCPStateDisabled:
38 return "disabled"
39 case MCPStateStarting:
40 return "starting"
41 case MCPStateConnected:
42 return "connected"
43 case MCPStateError:
44 return "error"
45 default:
46 return "unknown"
47 }
48}
49
50// MCPEventType represents the type of MCP event
51type MCPEventType string
52
53const (
54 MCPEventStateChanged MCPEventType = "state_changed"
55)
56
57func (t MCPEventType) MarshalText() ([]byte, error) {
58 return []byte(t), nil
59}
60
61func (t *MCPEventType) UnmarshalText(data []byte) error {
62 *t = MCPEventType(data)
63 return nil
64}
65
66// MCPEvent represents an event in the MCP system
67type MCPEvent struct {
68 Type MCPEventType `json:"type"`
69 Name string `json:"name"`
70 State MCPState `json:"state"`
71 Error error `json:"error,omitempty"`
72 ToolCount int `json:"tool_count,omitempty"`
73}