-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtool_get_storage_info.go
More file actions
41 lines (33 loc) · 1011 Bytes
/
tool_get_storage_info.go
File metadata and controls
41 lines (33 loc) · 1011 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
//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 registerGetStorageInfo(s *server.MCPServer) {
tool := mcp.NewTool("get_storage_info",
mcp.WithDescription(
"Get device storage usage including internal and external partitions. "+
"Returns filesystem, size, used, available, and mount point from 'df -h'.",
),
mcp.WithReadOnlyHintAnnotation(true),
mcp.WithDestructiveHintAnnotation(false),
mcp.WithIdempotentHintAnnotation(true),
)
s.AddTool(tool, handleGetStorageInfo)
}
func handleGetStorageInfo(
ctx context.Context,
_ mcp.CallToolRequest,
) (*mcp.CallToolResult, error) {
logger.Tracef(ctx, "handleGetStorageInfo")
defer func() { logger.Tracef(ctx, "/handleGetStorageInfo") }()
out, err := shellExec("df -h")
if err != nil {
return mcp.NewToolResultError(fmt.Sprintf("df: %v", err)), nil
}
return mcp.NewToolResultText(out), nil
}