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 ¶
- func InitializeConfigs(ctx context.Context, cfg ServerConfig) (map[string]sources.Source, map[string]auth.AuthService, ...)
- func NameValidation(name string) error
- func NewStdioSession(s *Server, stdin io.Reader, stdout io.Writer) *stdioSession
- func UnmarshalResourceConfig(ctx context.Context, raw []byte) (SourceConfigs, AuthServiceConfigs, EmbeddingModelConfigs, ToolConfigs, ...)
- func UnmarshalYAMLAuthServiceConfig(ctx context.Context, name string, r map[string]any) (auth.AuthServiceConfig, error)
- func UnmarshalYAMLEmbeddingModelConfig(ctx context.Context, name string, r map[string]any) (embeddingmodels.EmbeddingModelConfig, error)
- func UnmarshalYAMLPromptConfig(ctx context.Context, name string, r map[string]any) (prompts.PromptConfig, error)
- func UnmarshalYAMLSourceConfig(ctx context.Context, name string, r map[string]any) (sources.SourceConfig, error)
- func UnmarshalYAMLToolConfig(ctx context.Context, name string, r map[string]any) (tools.ToolConfig, error)
- func UnmarshalYAMLToolsetConfig(ctx context.Context, name string, r map[string]any) (tools.ToolsetConfig, error)
- type AuthServiceConfigs
- type EmbeddingModelConfigs
- type MockPrompt
- func (p MockPrompt) Manifest() prompts.Manifest
- func (p MockPrompt) McpManifest() prompts.McpManifest
- func (p MockPrompt) ParseArgs(data map[string]any, claimsMap map[string]map[string]any) (parameters.ParamValues, error)
- func (p MockPrompt) SubstituteParams(vals parameters.ParamValues) (any, error)
- func (p MockPrompt) ToConfig() prompts.PromptConfig
- type MockTool
- func (t MockTool) Authorized(verifiedAuthServices []string) bool
- func (t MockTool) EmbedParams(ctx context.Context, paramValues parameters.ParamValues, ...) (parameters.ParamValues, error)
- func (t MockTool) GetAuthTokenHeaderName(tools.SourceProvider) (string, error)
- func (t MockTool) GetParameters() parameters.Parameters
- func (t MockTool) Invoke(context.Context, tools.SourceProvider, parameters.ParamValues, ...) (any, util.ToolboxError)
- func (t MockTool) Manifest() tools.Manifest
- func (t MockTool) McpManifest() tools.McpManifest
- func (t MockTool) ParseParams(data map[string]any, claimsMap map[string]map[string]any) (parameters.ParamValues, error)
- func (t MockTool) RequiresClientAuthorization(tools.SourceProvider) (bool, error)
- func (t MockTool) ToConfig() tools.ToolConfig
- type PromptConfigs
- type PromptsetConfigs
- type ProtectedResourceMetadata
- type Server
- type ServerConfig
- type SourceConfigs
- type StringLevel
- type ToolConfigs
- type ToolsetConfigs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitializeConfigs ¶
func NameValidation ¶
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 ¶
func UnmarshalResourceConfig ¶
func UnmarshalResourceConfig(ctx context.Context, raw []byte) (SourceConfigs, AuthServiceConfigs, EmbeddingModelConfigs, ToolConfigs, ToolsetConfigs, PromptConfigs, error)
func UnmarshalYAMLEmbeddingModelConfig ¶
func UnmarshalYAMLEmbeddingModelConfig(ctx context.Context, name string, r map[string]any) (embeddingmodels.EmbeddingModelConfig, error)
func UnmarshalYAMLToolConfig ¶
Types ¶
type AuthServiceConfigs ¶
type AuthServiceConfigs map[string]auth.AuthServiceConfig
type EmbeddingModelConfigs ¶
type EmbeddingModelConfigs map[string]embeddingmodels.EmbeddingModelConfig
type MockPrompt ¶
MockPrompt is used to mock prompts in tests
func (MockPrompt) Manifest ¶
func (p MockPrompt) Manifest() prompts.Manifest
func (MockPrompt) McpManifest ¶
func (p MockPrompt) McpManifest() prompts.McpManifest
func (MockPrompt) ParseArgs ¶
func (p MockPrompt) ParseArgs(data map[string]any, claimsMap map[string]map[string]any) (parameters.ParamValues, error)
func (MockPrompt) SubstituteParams ¶
func (p MockPrompt) SubstituteParams(vals parameters.ParamValues) (any, error)
func (MockPrompt) ToConfig ¶
func (p MockPrompt) ToConfig() prompts.PromptConfig
type MockTool ¶
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 ¶
func (MockTool) EmbedParams ¶
func (t MockTool) EmbedParams(ctx context.Context, paramValues parameters.ParamValues, embeddingModelsMap map[string]embeddingmodels.EmbeddingModel) (parameters.ParamValues, error)
func (MockTool) GetAuthTokenHeaderName ¶
func (t MockTool) GetAuthTokenHeaderName(tools.SourceProvider) (string, error)
func (MockTool) GetParameters ¶
func (t MockTool) GetParameters() parameters.Parameters
func (MockTool) Invoke ¶
func (t MockTool) Invoke(context.Context, tools.SourceProvider, parameters.ParamValues, tools.AccessToken) (any, util.ToolboxError)
func (MockTool) McpManifest ¶
func (t MockTool) McpManifest() tools.McpManifest
func (MockTool) ParseParams ¶
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 ¶
func (t MockTool) RequiresClientAuthorization(tools.SourceProvider) (bool, error)
func (MockTool) ToConfig ¶
func (t MockTool) ToConfig() tools.ToolConfig
type PromptConfigs ¶
type PromptConfigs map[string]prompts.PromptConfig
type PromptsetConfigs ¶
type PromptsetConfigs map[string]prompts.PromptsetConfig
type ProtectedResourceMetadata ¶
type ProtectedResourceMetadata struct {
// REQUIRED. The protected resource's resource identifier (a URL using the https scheme).
Resource string `json:"resource"`
// REQUIRED. Array containing a list of OAuth authorization server issuer identifiers.
AuthorizationServers []string `json:"authorization_servers,omitempty"`
// OPTIONAL. URL of the protected resource's JSON Web Key (JWK) Set document.
JWKSURI string `json:"jwks_uri,omitempty"`
// RECOMMENDED. Array containing a list of scope values used to request access.
ScopesSupported []string `json:"scopes_supported,omitempty"`
// OPTIONAL. Array containing a list of the supported methods of sending an
// OAuth 2.0 bearer token (e.g., "header", "body", "query").
BearerMethodsSupported []string `json:"bearer_methods_supported,omitempty"`
// OPTIONAL. Array containing a list of the JWS signing algorithms (alg values)
// supported by the protected resource for signing resource responses.
ResourceSigningAlgValuesSupported []string `json:"resource_signing_alg_values_supported,omitempty"`
// RECOMMENDED. Human-readable name of the protected resource intended for display.
ResourceName string `json:"resource_name,omitempty"`
// OPTIONAL. URL of a page containing human-readable developer documentation.
ResourceDocumentation string `json:"resource_documentation,omitempty"`
// OPTIONAL. URL of a page containing human-readable policy requirements.
ResourcePolicyURI string `json:"resource_policy_uri,omitempty"`
// OPTIONAL. URL of a page containing human-readable terms of service.
ResourceTOSURI string `json:"resource_tos_uri,omitempty"`
// OPTIONAL. Boolean indicating support for mutual-TLS client certificate-bound
// access tokens. If omitted, the default is false.
TLSClientCertificateBoundAccessTokens *bool `json:"tls_client_certificate_bound_access_tokens,omitempty"`
// OPTIONAL. Array containing a list of authorization details type values supported.
AuthorizationDetailsTypesSupported []string `json:"authorization_details_types_supported,omitempty"`
// OPTIONAL. Array containing a list of JWS alg values supported for DPoP proof JWTs.
DPoPSigningAlgValuesSupported []string `json:"dpop_signing_alg_values_supported,omitempty"`
// OPTIONAL. Boolean specifying whether the protected resource always requires
// the use of DPoP-bound access tokens. If omitted, the default is false.
DPoPBoundAccessTokensRequired *bool `json:"dpop_bound_access_tokens_required,omitempty"`
// OPTIONAL. A JWT containing metadata parameters about the protected resource
// as claims. Consists of the entire signed JWT string.
SignedMetadata string `json:"signed_metadata,omitempty"`
}
ProtectedResourceMetadata represents the OAuth 2.0 Protected Resource Metadata document as defined in RFC 9728. Reference: https://datatracker.ietf.org/doc/html/rfc9728
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) ServeStdio ¶
ServeStdio starts a new stdio session for mcp.
type ServerConfig ¶
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
// EnableAPI indicates if the /api endpoint is enabled.
EnableAPI bool
// ToolboxUrl specifies the URL to advertise in the MCP PRM file as the resource field.
ToolboxUrl string
// McpPrmFile specifies the path to a manual Protected Resource Metadata (PRM) JSON file. If provided, overrides auto-generation.
McpPrmFile string
// 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
// PollInterval sets the polling frequency for configuration file updates.
PollInterval int
}
type SourceConfigs ¶
type SourceConfigs map[string]sources.SourceConfig
type StringLevel ¶
type StringLevel string
func (*StringLevel) String ¶
func (s *StringLevel) String() string
String is used by both fmt.Print and by Cobra in help text
type ToolConfigs ¶
type ToolConfigs map[string]tools.ToolConfig
type ToolsetConfigs ¶
type ToolsetConfigs map[string]tools.ToolsetConfig