Initial commit: forge-tools-ssh — MCP-сервер для администрирования по SSH
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"git.totmin.ru/en2zmax/forge-toolkit"
|
||||
"git.totmin.ru/en2zmax/forge-toolkit/validate"
|
||||
"github.com/modelcontextprotocol/go-sdk/mcp"
|
||||
)
|
||||
|
||||
// toolkit.go — тонкие адаптеры к общему слою forge-tools/toolkit.
|
||||
// Локальные имена сохранены, чтобы хендлеры не зависели от пакета-источника.
|
||||
|
||||
func requestArgs(req *mcp.CallToolRequest) map[string]any {
|
||||
return toolkit.RequestArgs(req)
|
||||
}
|
||||
|
||||
func getString(args map[string]any, key, def string) string {
|
||||
return toolkit.GetString(args, key, def)
|
||||
}
|
||||
|
||||
func requireString(args map[string]any, key string) (string, error) {
|
||||
return toolkit.RequireString(args, key)
|
||||
}
|
||||
|
||||
func getInt(args map[string]any, key string, def int) int {
|
||||
return toolkit.GetInt(args, key, def)
|
||||
}
|
||||
|
||||
func getBool(args map[string]any, key string, def bool) bool {
|
||||
return toolkit.GetBool(args, key, def)
|
||||
}
|
||||
|
||||
func getStringArray(args map[string]any, key string) ([]string, bool) {
|
||||
return toolkit.GetStringArray(args, key)
|
||||
}
|
||||
|
||||
func getIntArray(args map[string]any, key string) ([]int, bool) {
|
||||
return toolkit.GetIntArray(args, key)
|
||||
}
|
||||
|
||||
func schema(properties map[string]any, required []string) map[string]any {
|
||||
return toolkit.Schema(properties, required)
|
||||
}
|
||||
|
||||
func strProps(desc string, required bool, enum ...string) map[string]any {
|
||||
return toolkit.StrProps(desc, required, enum...)
|
||||
}
|
||||
|
||||
func intProps(desc string, required bool) map[string]any {
|
||||
return toolkit.IntProps(desc, required)
|
||||
}
|
||||
|
||||
func boolProps(desc string, required bool) map[string]any {
|
||||
return toolkit.BoolProps(desc, required)
|
||||
}
|
||||
|
||||
func arrayStringProps(desc string, required bool) map[string]any {
|
||||
return toolkit.ArrayStringProps(desc, required)
|
||||
}
|
||||
|
||||
func arrayNumberProps(desc string, required bool) map[string]any {
|
||||
return toolkit.ArrayNumberProps(desc, required)
|
||||
}
|
||||
|
||||
func textResult(text string) *mcp.CallToolResult {
|
||||
return toolkit.Text(text)
|
||||
}
|
||||
|
||||
func errorResult(msg string) *mcp.CallToolResult {
|
||||
return toolkit.Error(msg)
|
||||
}
|
||||
|
||||
// patternsFn — forge-probe эмиттер паттернов (см. toolkit.PatternsFn).
|
||||
type patternsFn = toolkit.PatternsFn
|
||||
|
||||
func registerPatternTool(s *mcp.Server, tool *mcp.Tool, fn patternsFn, h mcp.ToolHandler) {
|
||||
toolkit.RegisterPatternTool(s, tool, fn, h)
|
||||
}
|
||||
|
||||
// ValidationResult — результат серверной валидации синтаксиса.
|
||||
type ValidationResult = validate.Result
|
||||
|
||||
func ValidateContent(content, fileType string) *ValidationResult {
|
||||
return validate.Content(content, fileType)
|
||||
}
|
||||
|
||||
func detectFileType(path string) string {
|
||||
return validate.DetectFileType(path)
|
||||
}
|
||||
Reference in New Issue
Block a user