Compare commits

..

4 Commits

Author SHA1 Message Date
Yuan Teoh
72cbbe3599 Merge branch 'main' into registry-toolbox-flag 2026-01-13 11:46:35 -08:00
Yuan Teoh
239f623e93 Merge branch 'main' into registry-toolbox-flag 2026-01-12 15:56:50 -08:00
Yuan Teoh
1542566f16 bump publish version 2026-01-09 10:56:59 -08:00
Yuan Teoh
ec11b067cd feat: add remaining toolbox server flag 2026-01-09 10:55:57 -08:00
3 changed files with 88 additions and 108 deletions

View File

@@ -16,7 +16,6 @@ package server
import (
"context"
"fmt"
"regexp"
"strings"
yaml "github.com/goccy/go-yaml"
@@ -140,10 +139,6 @@ func (c *SourceConfigs) UnmarshalYAML(ctx context.Context, unmarshal func(interf
}
for name, u := range raw {
err := NameValidation(name)
if err != nil {
return err
}
// Unmarshal to a general type that ensure it capture all fields
var v map[string]any
if err := u.Unmarshal(&v); err != nil {
@@ -188,10 +183,6 @@ func (c *AuthServiceConfigs) UnmarshalYAML(ctx context.Context, unmarshal func(i
}
for name, u := range raw {
err := NameValidation(name)
if err != nil {
return err
}
var v map[string]any
if err := u.Unmarshal(&v); err != nil {
return fmt.Errorf("unable to unmarshal %q: %w", name, err)
@@ -235,10 +226,6 @@ func (c *EmbeddingModelConfigs) UnmarshalYAML(ctx context.Context, unmarshal fun
}
for name, u := range raw {
err := NameValidation(name)
if err != nil {
return err
}
// Unmarshal to a general type that ensure it capture all fields
var v map[string]any
if err := u.Unmarshal(&v); err != nil {
@@ -283,10 +270,6 @@ func (c *ToolConfigs) UnmarshalYAML(ctx context.Context, unmarshal func(interfac
}
for name, u := range raw {
err := NameValidation(name)
if err != nil {
return err
}
var v map[string]any
if err := u.Unmarshal(&v); err != nil {
return fmt.Errorf("unable to unmarshal %q: %w", name, err)
@@ -340,10 +323,6 @@ func (c *ToolsetConfigs) UnmarshalYAML(ctx context.Context, unmarshal func(inter
}
for name, toolList := range raw {
err := NameValidation(name)
if err != nil {
return err
}
(*c)[name] = tools.ToolsetConfig{Name: name, ToolNames: toolList}
}
return nil
@@ -363,10 +342,6 @@ func (c *PromptConfigs) UnmarshalYAML(ctx context.Context, unmarshal func(interf
}
for name, u := range raw {
err := NameValidation(name)
if err != nil {
return err
}
var v map[string]any
if err := u.Unmarshal(&v); err != nil {
return fmt.Errorf("unable to unmarshal prompt %q: %w", name, err)
@@ -414,31 +389,7 @@ func (c *PromptsetConfigs) UnmarshalYAML(ctx context.Context, unmarshal func(int
}
for name, promptList := range raw {
err := NameValidation(name)
if err != nil {
return err
}
(*c)[name] = prompts.PromptsetConfig{Name: name, PromptNames: promptList}
}
return nil
}
// Tools naming validation is added in the MCP v2025-11-25, but we'll be
// implementing it across Toolbox
// Tool names SHOULD be between 1 and 128 characters in length (inclusive).
// Tool names SHOULD be considered case-sensitive.
// The following SHOULD be the only allowed characters: uppercase and lowercase ASCII letters (A-Z, a-z), digits (0-9), underscore (_), hyphen (-), and dot (.)
// Tool names SHOULD NOT contain spaces, commas, or other special characters.
// Tool names SHOULD be unique within a server.
func NameValidation(name string) error {
strLen := len(name)
if strLen < 1 || strLen > 128 {
return fmt.Errorf("resource name SHOULD be between 1 and 128 characters in length (inclusive)")
}
validChars := regexp.MustCompile("^[a-zA-Z0-9_.-]+$")
isValid := validChars.MatchString(name)
if !isValid {
return fmt.Errorf("invalid character for resource name; only uppercase and lowercase ASCII letters (A-Z, a-z), digits (0-9), underscore (_), hyphen (-), and dot (.) is allowed")
}
return nil
}

View File

@@ -200,62 +200,3 @@ func TestUpdateServer(t *testing.T) {
t.Errorf("error updating server, promptset (-want +got):\n%s", diff)
}
}
func TestNameValidation(t *testing.T) {
testCases := []struct {
desc string
resourceName string
errStr string
}{
{
desc: "names with 0 length",
resourceName: "",
errStr: "resource name SHOULD be between 1 and 128 characters in length (inclusive)",
},
{
desc: "names with allowed length",
resourceName: "foo",
},
{
desc: "names with 128 length",
resourceName: strings.Repeat("a", 128),
},
{
desc: "names with more than 128 length",
resourceName: strings.Repeat("a", 129),
errStr: "resource name SHOULD be between 1 and 128 characters in length (inclusive)",
},
{
desc: "names with space",
resourceName: "foo bar",
errStr: "invalid character for resource name; only uppercase and lowercase ASCII letters (A-Z, a-z), digits (0-9), underscore (_), hyphen (-), and dot (.) is allowed",
},
{
desc: "names with commas",
resourceName: "foo,bar",
errStr: "invalid character for resource name; only uppercase and lowercase ASCII letters (A-Z, a-z), digits (0-9), underscore (_), hyphen (-), and dot (.) is allowed",
},
{
desc: "names with other special character",
resourceName: "foo!",
errStr: "invalid character for resource name; only uppercase and lowercase ASCII letters (A-Z, a-z), digits (0-9), underscore (_), hyphen (-), and dot (.) is allowed",
},
{
desc: "names with allowed special character",
resourceName: "foo_.-bar6",
},
}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
err := server.NameValidation(tc.resourceName)
if err != nil {
if tc.errStr != err.Error() {
t.Fatalf("unexpected error: %s", err)
}
}
if err == nil && tc.errStr != "" {
t.Fatalf("expect error: %s", tc.errStr)
}
})
}
}

View File

@@ -31,6 +31,18 @@
"default": "tools.yaml",
"isRequired": false
},
{
"type": "named",
"name": "--tools-files",
"description": "Multiple file paths specifying tool configurations. Files will be merged. Cannot be used with -tools-file or -tools-folder.",
"isRequired": false
},
{
"type": "named",
"name": "--tools-folder",
"description": "Directory path containing YAML tool configuration files. All .yaml and .yml files in the directory will be loaded and merged. Cannot be used with -tools-file or -tools-files.",
"isRequired": false
},
{
"type": "named",
"name": "--address",
@@ -70,6 +82,82 @@
"warn",
"error"
]
},
{
"type": "named",
"name": "--logging-format",
"description": "Specify logging format to use.",
"default": "standard",
"choices": [
"standard",
"json"
]
},
{
"type": "named",
"name": "--disable-reload",
"description": "Disables dynamic reloading of tools file.",
"format": "boolean",
"isRequired": false
},
{
"type": "named",
"name": "--prebuilt",
"description": "Use a prebuilt tool configuration by source type.",
"isRequired": false
},
{
"type": "named",
"name": "--stdio",
"description": "Listens via MCP STDIO instead of acting as a remote HTTP server.",
"format": "boolean",
"isRequired": false
},
{
"type": "named",
"name": "--telemetry-gcp",
"description": "Enable exporting directly to Google Cloud Monitoring.",
"format": "boolean",
"isRequired": false
},
{
"type": "named",
"name": "--telemetry-otlp",
"description": "Enable exporting using OpenTelemetry Protocol (OTLP) to the specified endpoint (e.g. 'http://127.0.0.1:4318').",
"isRequired": false
},
{
"type": "named",
"name": "--telemetry-service-name",
"description": "Sets the value of the service.name resource attribute for telemetry data.",
"default": "toolbox",
"isRequired": false
},
{
"type": "named",
"name": "--ui",
"description": "Launches the Toolbox UI web server.",
"format": "boolean",
"isRequired": false
},
{
"type": "named",
"name": "--allowed-origins",
"description": "Specifies a list of origins permitted to access this server.",
"default": "*",
"isRequired": false
},
{
"type": "named",
"name": "--help",
"description": "Show help for toolbox",
"isRequired": false
},
{
"type": "named",
"name": "--version",
"description": "Show version for toolbox",
"isRequired": false
}
]
}