mcp

package
v0.0.60 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 39 Imported by: 1

Documentation

Index

Constants

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 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 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) 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.

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