23 lines
637 B
Go
23 lines
637 B
Go
package system
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/modelcontextprotocol/go-sdk/mcp"
|
|
)
|
|
|
|
// registerPing 注册 ping 工具:无参数健康检查,返回 pong 与服务器时间。
|
|
func registerPing(s *mcp.Server) {
|
|
mcp.AddTool(s, &mcp.Tool{
|
|
Name: "ping",
|
|
Description: "健康检查。返回 pong 与服务器当前时间,用于确认 aio-mcp 连接正常。",
|
|
}, func(_ context.Context, _ *mcp.CallToolRequest, _ struct{}) (*mcp.CallToolResult, any, error) {
|
|
return &mcp.CallToolResult{
|
|
Content: []mcp.Content{
|
|
&mcp.TextContent{Text: "pong " + time.Now().Format(time.RFC3339)},
|
|
},
|
|
}, nil, nil
|
|
})
|
|
}
|