INNER CODE UNIT · Go

fnModel

wgpsec/cloudsword · cmd/mcpServer.go:29

func fnModel(m global.Module) server.ToolHandlerFunc {
	return func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
		for _, b := range global.GetBasicOptionsWithId(m.ID) {
			v, ok := req.Params.Arguments[b.Key].(string)
			if !ok && b.Required {
				return nil, fmt.Errorf("invalid name parameter%s", b.Key)
			}
			if b.Key == global.Detail {
				value := strings.ToLower(v)
				if utils.Contains([]string{"0", "false", "f", "no", "n"}, value) {
					v = global.False
				} else if utils.Contains([]string{"1", "true", "t", "yes", "y"}, value) {
					v = global.True
				} else {
					logger.Println.Error(fmt.Sprintf("%s 的值类型错误,请设置成 True 或者 False。", b.Key))
				}
			}
			global.UpdateBasicOptionValue(b.Key, v)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…