-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtool_make_call.go
More file actions
50 lines (41 loc) · 1.23 KB
/
tool_make_call.go
File metadata and controls
50 lines (41 loc) · 1.23 KB
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
44
45
46
47
48
49
50
//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 registerMakeCall(s *server.MCPServer) {
tool := mcp.NewTool("make_call",
mcp.WithDescription(
"Initiate a phone call to a number using 'am start -a android.intent.action.CALL'. "+
"The call is placed immediately (not just dialed).",
),
mcp.WithString("number",
mcp.Required(),
mcp.Description("Phone number to call (e.g. '+1234567890')"),
),
mcp.WithDestructiveHintAnnotation(true),
mcp.WithIdempotentHintAnnotation(false),
)
s.AddTool(tool, handleMakeCall)
}
func handleMakeCall(
ctx context.Context,
request mcp.CallToolRequest,
) (*mcp.CallToolResult, error) {
logger.Tracef(ctx, "handleMakeCall")
defer func() { logger.Tracef(ctx, "/handleMakeCall") }()
number, err := request.RequireString("number")
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
cmd := fmt.Sprintf("am start -a android.intent.action.CALL -d tel:%s", shellQuote(number))
out, err := shellExec(cmd)
if err != nil {
return mcp.NewToolResultError(fmt.Sprintf("make call: %v", err)), nil
}
return mcp.NewToolResultText(out), nil
}