mcp

package
v0.0.62 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 46 Imported by: 1

Documentation

Index

Constants

View Source
const CodeRateLimitExceeded = -32029

CodeRateLimitExceeded is the JSON-RPC error code returned when a session exceeds its rate limit. The value -32029 echoes HTTP 429 and does not conflict with standard JSON-RPC codes or existing SDK application codes.

View Source
const TargetsListToolName = "targets_list"

TargetsListToolName is the base name for the generic targets list tool before mutation

Variables

This section is empty.

Functions

func NewStructuredResult added in v0.0.58

func NewStructuredResult(content string, structuredContent any, err error) *mcp.CallToolResult

NewStructuredResult creates an MCP CallToolResult with structured content. The Content field contains the JSON-serialized form of structuredContent for backward compatibility with MCP clients that don't support structuredContent.

Per the MCP specification, structuredContent must marshal to a JSON object. If structuredContent is a slice/array, it is automatically wrapped in {"items": [...]} to satisfy this requirement.

Per the MCP specification: "For backwards compatibility, a tool that returns structured content SHOULD also return the serialized JSON in a TextContent block." https://modelcontextprotocol.io/specification/2025-11-25/server/tools#structured-content

Use this for tools that return typed/structured data that MCP clients can parse programmatically.

func NewTextResult

func NewTextResult(content string, err error) *mcp.CallToolResult

NewTextResult creates an MCP CallToolResult with text content only. Use this for tools that return human-readable text output.

func ServerPromptToGoSdkPrompt added in v0.0.56

func ServerPromptToGoSdkPrompt(s *Server, serverPrompt api.ServerPrompt) (*mcp.Prompt, mcp.PromptHandler, error)

ServerPromptToGoSdkPrompt converts an api.ServerPrompt to MCP SDK types

func ServerResourceTemplateToGoSdkResourceTemplate added in v0.0.62

func ServerResourceTemplateToGoSdkResourceTemplate(_ *Server, rt api.ServerResourceTemplate) (*mcp.ResourceTemplate, mcp.ResourceHandler, error)

ServerResourceTemplateToGoSdkResourceTemplate converts an api.ServerResourceTemplate to MCP SDK types. It validates the URITemplate upfront so callers can surface a wrapped error instead of letting the SDK panic during registration on hot reload.

func ServerResourceToGoSdkResource added in v0.0.62

func ServerResourceToGoSdkResource(_ *Server, res api.ServerResource) (*mcp.Resource, mcp.ResourceHandler, error)

ServerResourceToGoSdkResource converts an api.ServerResource to MCP SDK types. It validates the URI upfront so callers can surface a wrapped error instead of letting the SDK panic during registration on hot reload.

func ServerToolToGoSdkTool added in v0.0.55

func ServerToolToGoSdkTool(s *Server, tool api.ServerTool) (*mcp.Tool, mcp.ToolHandler, error)

Types

type Configuration

type Configuration struct {
	*config.StaticConfig
	// contains filtered or unexported fields
}

func (*Configuration) ListOutput

func (c *Configuration) ListOutput() output.Output

func (*Configuration) Toolsets added in v0.0.51

func (c *Configuration) Toolsets() []api.Toolset

type PromptMutator added in v0.0.60

type PromptMutator func(prompt api.ServerPrompt) api.ServerPrompt

func WithPromptTargetParameter added in v0.0.60

func WithPromptTargetParameter(defaultTarget, targetParameterName string, isMultiTarget bool) PromptMutator

WithPromptTargetParameter adds a target selection argument to the prompt if it is cluster-aware

type ResourceFilter added in v0.0.62

type ResourceFilter func(resource api.ServerResource) bool

ResourceFilter is a function that takes a ServerResource and returns a boolean indicating whether to include it

func CompositeResourceFilter added in v0.0.62

func CompositeResourceFilter(filters ...ResourceFilter) ResourceFilter

CompositeResourceFilter combines multiple resource filters into a single filter using AND logic

type ResourceMutator added in v0.0.62

type ResourceMutator func(resource api.ServerResource) api.ServerResource

ResourceMutator is a function that transforms a ServerResource

func ComposeResourceMutators added in v0.0.62

func ComposeResourceMutators(mutators ...ResourceMutator) ResourceMutator

ComposeResourceMutators combines multiple resource mutators into a pipeline

type ResourceTemplateFilter added in v0.0.62

type ResourceTemplateFilter func(template api.ServerResourceTemplate) bool

ResourceTemplateFilter is a function that takes a ServerResourceTemplate and returns a boolean indicating whether to include it

func CompositeResourceTemplateFilter added in v0.0.62

func CompositeResourceTemplateFilter(filters ...ResourceTemplateFilter) ResourceTemplateFilter

CompositeResourceTemplateFilter combines multiple resource template filters into a single filter using AND logic

type ResourceTemplateMutator added in v0.0.62

type ResourceTemplateMutator func(template api.ServerResourceTemplate) api.ServerResourceTemplate

ResourceTemplateMutator is a function that transforms a ServerResourceTemplate

func ComposeResourceTemplateMutators added in v0.0.62

func ComposeResourceTemplateMutators(mutators ...ResourceTemplateMutator) ResourceTemplateMutator

ComposeResourceTemplateMutators combines multiple resource template mutators into a pipeline

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(configuration Configuration, targetProvider internalk8s.Provider) (*Server, error)

func (*Server) Close

func (s *Server) Close()

func (*Server) GetEnabledPrompts added in v0.0.56

func (s *Server) GetEnabledPrompts() []string

GetEnabledPrompts returns the names of the currently enabled prompts

func (*Server) GetEnabledResourceTemplates added in v0.0.62

func (s *Server) GetEnabledResourceTemplates() []string

GetEnabledResourceTemplates returns the URI templates of the currently enabled resource templates

func (*Server) GetEnabledResources added in v0.0.62

func (s *Server) GetEnabledResources() []string

GetEnabledResources returns the URIs of the currently enabled resources

func (*Server) GetEnabledTools

func (s *Server) GetEnabledTools() []string

func (*Server) GetMetrics added in v0.0.57

func (s *Server) GetMetrics() *metrics.Metrics

GetMetrics returns the metrics system for use by the HTTP server.

func (*Server) GetTargetParameterName added in v0.0.53

func (s *Server) GetTargetParameterName() string

GetTargetParameterName returns the parameter name used for target identification in MCP requests

func (*Server) ReloadConfiguration added in v0.0.56

func (s *Server) ReloadConfiguration(newConfig *config.StaticConfig) error

ReloadConfiguration reloads the configuration and reinitializes the server. This is intended to be called by the server lifecycle manager when configuration changes are detected.

The reload is fully transactional: s.configuration is not mutated until applyToolsets has successfully recomputed and committed the SDK surface against the candidate config. A rejected reload leaves s.configuration, the SDK, and the enabled-X bookkeeping at their previous consistent values, so concurrent readers (rate-limit closure, confirmation rules, list output...) can never observe a new-but-rejected configuration.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP() *mcp.StreamableHTTPHandler

func (*Server) ServeSse

func (s *Server) ServeSse() *mcp.SSEHandler

func (*Server) ServeStdio

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

func (*Server) Shutdown added in v0.0.57

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

Shutdown gracefully shuts down the server, flushing any pending metrics.

type ToolCallRequest added in v0.0.55

type ToolCallRequest struct {
	Name string
	// contains filtered or unexported fields
}

func GoSdkToolCallParamsToToolCallRequest added in v0.0.55

func GoSdkToolCallParamsToToolCallRequest(toolCallParams *mcp.CallToolParamsRaw) (*ToolCallRequest, error)

func GoSdkToolCallRequestToToolCallRequest added in v0.0.55

func GoSdkToolCallRequestToToolCallRequest(request *mcp.CallToolRequest) (*ToolCallRequest, error)

func (*ToolCallRequest) GetArguments added in v0.0.55

func (ToolCallRequest *ToolCallRequest) GetArguments() map[string]any

func (*ToolCallRequest) GetString added in v0.0.55

func (ToolCallRequest *ToolCallRequest) GetString(key, defaultValue string) string

type ToolFilter added in v0.0.53

type ToolFilter func(tool api.ServerTool) bool

ToolFilter is a function that takes a ServerTool and returns a boolean indicating whether to include the tool

func CompositeFilter added in v0.0.53

func CompositeFilter(filters ...ToolFilter) ToolFilter

func ShouldIncludeTargetListTool added in v0.0.53

func ShouldIncludeTargetListTool(targetName string, isMultiTarget bool) ToolFilter

type ToolMutator added in v0.0.53

type ToolMutator func(tool api.ServerTool) api.ServerTool

func ComposeMutators added in v0.0.57

func ComposeMutators(mutators ...ToolMutator) ToolMutator

ComposeMutators combines multiple mutators into a single mutator that applies them in order

func WithTargetListTool added in v0.0.57

func WithTargetListTool(defaultTarget, targetParameterName string, p targetLister) ToolMutator

WithTargetListTool mutates the generic "targets_list" tool to have the correct name, description, and handler based on the provider's target parameter name. For example, with ACM provider (targetParameterName="cluster"), it becomes "cluster_list".

func WithTargetParameter added in v0.0.53

func WithTargetParameter(defaultCluster, targetParameterName string, isMultiTarget bool) ToolMutator

WithTargetParameter adds a target selection parameter to the tool's input schema if the tool is cluster-aware

func WithToolOverrides added in v0.0.60

func WithToolOverrides(overrides map[string]config.ToolOverride) ToolMutator

WithToolOverrides returns a mutator that applies per-tool configuration overrides (such as custom descriptions) from the user's config file.

Jump to

Keyboard shortcuts

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