server

package
v0.27.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Overview

Copyright 2024 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NameValidation added in v0.26.0

func NameValidation(name string) error

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 NewStdioSession added in v0.6.0

func NewStdioSession(s *Server, stdin io.Reader, stdout io.Writer) *stdioSession

func UnmarshalYAMLAuthServiceConfig added in v0.27.0

func UnmarshalYAMLAuthServiceConfig(ctx context.Context, name string, r map[string]any) (auth.AuthServiceConfig, error)

func UnmarshalYAMLEmbeddingModelConfig added in v0.27.0

func UnmarshalYAMLEmbeddingModelConfig(ctx context.Context, name string, r map[string]any) (embeddingmodels.EmbeddingModelConfig, error)

func UnmarshalYAMLPromptConfig added in v0.27.0

func UnmarshalYAMLPromptConfig(ctx context.Context, name string, r map[string]any) (prompts.PromptConfig, error)

func UnmarshalYAMLSourceConfig added in v0.27.0

func UnmarshalYAMLSourceConfig(ctx context.Context, name string, r map[string]any) (sources.SourceConfig, error)

func UnmarshalYAMLToolConfig added in v0.27.0

func UnmarshalYAMLToolConfig(ctx context.Context, name string, r map[string]any) (tools.ToolConfig, error)

func UnmarshalYAMLToolsetConfig added in v0.27.0

func UnmarshalYAMLToolsetConfig(ctx context.Context, name string, r map[string]any) (tools.ToolsetConfig, error)

Types

type AuthServiceConfigs added in v0.2.0

type AuthServiceConfigs map[string]auth.AuthServiceConfig

type EmbeddingModelConfigs added in v0.25.0

type EmbeddingModelConfigs map[string]embeddingmodels.EmbeddingModelConfig

type MockPrompt added in v0.27.0

type MockPrompt struct {
	Name        string
	Description string
	Args        prompts.Arguments
}

MockPrompt is used to mock prompts in tests

func (MockPrompt) Manifest added in v0.27.0

func (p MockPrompt) Manifest() prompts.Manifest

func (MockPrompt) McpManifest added in v0.27.0

func (p MockPrompt) McpManifest() prompts.McpManifest

func (MockPrompt) ParseArgs added in v0.27.0

func (p MockPrompt) ParseArgs(data map[string]any, claimsMap map[string]map[string]any) (parameters.ParamValues, error)

func (MockPrompt) SubstituteParams added in v0.27.0

func (p MockPrompt) SubstituteParams(vals parameters.ParamValues) (any, error)

func (MockPrompt) ToConfig added in v0.27.0

func (p MockPrompt) ToConfig() prompts.PromptConfig

type MockTool added in v0.27.0

type MockTool struct {
	Name        string
	Description string
	Params      []parameters.Parameter
	// contains filtered or unexported fields
}

MockTool is used to mock tools in tests

func (MockTool) Authorized added in v0.27.0

func (t MockTool) Authorized(verifiedAuthServices []string) bool

func (MockTool) EmbedParams added in v0.27.0

func (t MockTool) EmbedParams(ctx context.Context, paramValues parameters.ParamValues, embeddingModelsMap map[string]embeddingmodels.EmbeddingModel) (parameters.ParamValues, error)

func (MockTool) GetAuthTokenHeaderName added in v0.27.0

func (t MockTool) GetAuthTokenHeaderName(tools.SourceProvider) (string, error)

func (MockTool) GetParameters added in v0.27.0

func (t MockTool) GetParameters() parameters.Parameters

func (MockTool) Invoke added in v0.27.0

func (MockTool) Manifest added in v0.27.0

func (t MockTool) Manifest() tools.Manifest

func (MockTool) McpManifest added in v0.27.0

func (t MockTool) McpManifest() tools.McpManifest

func (MockTool) ParseParams added in v0.27.0

func (t MockTool) ParseParams(data map[string]any, claimsMap map[string]map[string]any) (parameters.ParamValues, error)

claims is a map of user info decoded from an auth token

func (MockTool) RequiresClientAuthorization added in v0.27.0

func (t MockTool) RequiresClientAuthorization(tools.SourceProvider) (bool, error)

func (MockTool) ToConfig added in v0.27.0

func (t MockTool) ToConfig() tools.ToolConfig

type PromptConfigs added in v0.20.0

type PromptConfigs map[string]prompts.PromptConfig

type PromptsetConfigs added in v0.20.0

type PromptsetConfigs map[string]prompts.PromptsetConfig

type Server

type Server struct {
	ResourceMgr *resources.ResourceManager
	// contains filtered or unexported fields
}

Server contains info for running an instance of Toolbox. Should be instantiated with NewServer().

func NewServer

func NewServer(ctx context.Context, cfg ServerConfig) (*Server, error)

NewServer returns a Server object based on provided Config.

func (*Server) Listen added in v0.0.3

func (s *Server) Listen(ctx context.Context) error

Listen starts a listener for the given Server instance.

func (*Server) Serve added in v0.0.3

func (s *Server) Serve(ctx context.Context) error

Serve starts an HTTP server for the given Server instance.

func (*Server) ServeStdio added in v0.6.0

func (s *Server) ServeStdio(ctx context.Context, stdin io.Reader, stdout io.Writer) error

ServeStdio starts a new stdio session for mcp.

func (*Server) Shutdown added in v0.0.5

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server without interrupting any active connections. It uses http.Server.Shutdown() and has the same functionality.

type ServerConfig added in v0.0.2

type ServerConfig struct {
	// Server version
	Version string
	// Address is the address of the interface the server will listen on.
	Address string
	// Port is the port the server will listen on.
	Port int
	// SourceConfigs defines what sources of data are available for tools.
	SourceConfigs SourceConfigs
	// AuthServiceConfigs defines what sources of authentication are available for tools.
	AuthServiceConfigs AuthServiceConfigs
	// EmbeddingModelConfigs defines a models used to embed parameters.
	EmbeddingModelConfigs EmbeddingModelConfigs
	// ToolConfigs defines what tools are available.
	ToolConfigs ToolConfigs
	// ToolsetConfigs defines what tools are available.
	ToolsetConfigs ToolsetConfigs
	// PromptConfigs defines what prompts are available
	PromptConfigs PromptConfigs
	// PromptsetConfigs defines what prompts are available
	PromptsetConfigs PromptsetConfigs
	// LoggingFormat defines whether structured loggings are used.
	LoggingFormat logFormat
	// LogLevel defines the levels to log.
	LogLevel StringLevel
	// TelemetryGCP defines whether GCP exporter is used.
	TelemetryGCP bool
	// TelemetryOTLP defines OTLP collector url for telemetry exports.
	TelemetryOTLP string
	// TelemetryServiceName defines the value of service.name resource attribute.
	TelemetryServiceName string
	// Stdio indicates if Toolbox is listening via MCP stdio.
	Stdio bool
	// DisableReload indicates if the user has disabled dynamic reloading for Toolbox.
	DisableReload bool
	// UI indicates if Toolbox UI endpoints (/ui) are available.
	UI bool
	// Specifies a list of origins permitted to access this server.
	AllowedOrigins []string
	// Specifies a list of hosts permitted to access this server.
	AllowedHosts []string
	// UserAgentMetadata specifies additional metadata to append to the User-Agent string.
	UserAgentMetadata []string
}

type SourceConfigs added in v0.0.2

type SourceConfigs map[string]sources.SourceConfig

type StringLevel added in v0.0.3

type StringLevel string

func (*StringLevel) Set added in v0.0.3

func (s *StringLevel) Set(v string) error

validate log level flag

func (*StringLevel) String added in v0.0.3

func (s *StringLevel) String() string

String is used by both fmt.Print and by Cobra in help text

func (*StringLevel) Type added in v0.0.3

func (s *StringLevel) Type() string

Type is used in Cobra help text

type ToolConfigs added in v0.0.2

type ToolConfigs map[string]tools.ToolConfig

type ToolsetConfigs added in v0.0.2

type ToolsetConfigs map[string]tools.ToolsetConfig

Directories

Path Synopsis
mcp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL