-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtool_get_timezone.go
More file actions
44 lines (35 loc) · 986 Bytes
/
tool_get_timezone.go
File metadata and controls
44 lines (35 loc) · 986 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
44
//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 registerGetTimezone(s *server.MCPServer) {
tool := mcp.NewTool("get_timezone",
mcp.WithDescription(
"Get the current device timezone from 'getprop persist.sys.timezone'.",
),
mcp.WithReadOnlyHintAnnotation(true),
mcp.WithDestructiveHintAnnotation(false),
mcp.WithIdempotentHintAnnotation(true),
)
s.AddTool(tool, handleGetTimezone)
}
func handleGetTimezone(
ctx context.Context,
_ mcp.CallToolRequest,
) (*mcp.CallToolResult, error) {
logger.Tracef(ctx, "handleGetTimezone")
defer func() { logger.Tracef(ctx, "/handleGetTimezone") }()
out, err := shellExec("getprop persist.sys.timezone")
if err != nil {
return mcp.NewToolResultError(fmt.Sprintf("getprop: %v", err)), nil
}
if out == "" {
out = "timezone not set"
}
return mcp.NewToolResultText(out), nil
}