Initial commit: omnichannel-mcp — MCP-сервер управления платформой Omnichannel
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/modelcontextprotocol/go-sdk/mcp"
|
||||
)
|
||||
|
||||
// maintain.go — обслуживание: очистка старых версий.
|
||||
|
||||
func registerMaintainTools(s *mcp.Server) {
|
||||
// cleanup_old_versions не эмитит паттерн по конкретному ресурсу: операция
|
||||
// затрагивает всю БД версий, поэтому используем release-паттерн стенда.
|
||||
addPatternTool(s, &mcp.Tool{
|
||||
Name: "cleanup_old_versions",
|
||||
Description: "Удалить версии compose/env и логи миграций старше N дней (текущие версии не трогаются). Разрушительно: требует confirm=\"true\".",
|
||||
InputSchema: schema(map[string]any{
|
||||
"server": serverProp(),
|
||||
"days": intProps("Порог в днях (по умолчанию 90)", false),
|
||||
"confirm": boolProps("Подтверждение разрушительной операции (обязательно true)", true),
|
||||
}, []string{"confirm"}),
|
||||
}, releasePatterns, func(ctx context.Context, req *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
args := requestArgs(req)
|
||||
if res := confirmGate(args, "cleanup_old_versions"); res != nil {
|
||||
return res, nil
|
||||
}
|
||||
days := getInt(args, "days", 90)
|
||||
if days <= 0 {
|
||||
return errorResult("days должен быть положительным"), nil
|
||||
}
|
||||
api, res := openAPI(ctx, args, true)
|
||||
if res != nil {
|
||||
return res, nil
|
||||
}
|
||||
defer api.Close()
|
||||
return result(api.CleanupOldVersions(ctx, days))
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user