-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtool_end_call.go
More file actions
43 lines (34 loc) · 920 Bytes
/
tool_end_call.go
File metadata and controls
43 lines (34 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//go:build linux
package main
import (
"context"
"fmt"
"github.com/facebookincubator/go-belt/tool/logger"
"github.com/mark3labs/mcp-go/mcp"
"github.com/mark3labs/mcp-go/server"
)
func registerEndCall(s *server.MCPServer) {
tool := mcp.NewTool("end_call",
mcp.WithDescription(
"Hang up the current phone call using 'input keyevent KEYCODE_ENDCALL'.",
),
mcp.WithDestructiveHintAnnotation(true),
mcp.WithIdempotentHintAnnotation(true),
)
s.AddTool(tool, handleEndCall)
}
func handleEndCall(
ctx context.Context,
_ mcp.CallToolRequest,
) (*mcp.CallToolResult, error) {
logger.Tracef(ctx, "handleEndCall")
defer func() { logger.Tracef(ctx, "/handleEndCall") }()
out, err := shellExec("input keyevent KEYCODE_ENDCALL")
if err != nil {
return mcp.NewToolResultError(fmt.Sprintf("end call: %v", err)), nil
}
if out == "" {
out = "call ended"
}
return mcp.NewToolResultText(out), nil
}