mcp

package
v0.0.63 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunSSEServer

func RunSSEServer(mcpSrv *mcpserver.MCPServer, addr, sseEndpoint, messageEndpoint string, ctx context.Context) error

RunSSEServer runs the server with SSE transport

func RunStdioServer

func RunStdioServer(mcpSrv *mcpserver.MCPServer, stdin io.Reader, stdout io.Writer) error

RunStdioServer runs the server with STDIO transport

func RunStreamableHTTPServer

func RunStreamableHTTPServer(mcpSrv *mcpserver.MCPServer, addr, endpoint string, ctx context.Context) error

RunStreamableHTTPServer runs the server with Streamable HTTP transport

Types

type Server

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

Server represents an MCP CAPI server instance

func NewServer

func NewServer(opts ServerOptions) (*Server, error)

NewServer creates a new MCP CAPI server with the given options

func (*Server) Context

func (s *Server) Context() context.Context

Context returns the server's context

func (*Server) RegisterTools

func (s *Server) RegisterTools(registerFunc func(*handlers.ServerContext) ([]handlers.ToolRegistration, error)) error

RegisterTools registers MCP tools using the provided registration function

func (*Server) Run

func (s *Server) Run() error

Run starts the server with the configured transport

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown gracefully shuts down the server

type ServerOptions

type ServerOptions struct {
	// KubeconfigPath is the path to the kubeconfig file
	KubeconfigPath string

	// Transport is the type of transport to use
	Transport TransportType

	// HTTPAddr is the HTTP server address (for SSE and Streamable HTTP transports)
	HTTPAddr string

	// SSEEndpoint is the SSE endpoint path (for SSE transport)
	SSEEndpoint string

	// MessageEndpoint is the message endpoint path (for SSE transport)
	MessageEndpoint string

	// HTTPEndpoint is the HTTP endpoint path (for Streamable HTTP transport)
	HTTPEndpoint string

	// ServerName is the name of the MCP server
	ServerName string

	// ServerVersion is the version of the MCP server
	ServerVersion string

	// StdioInput is the input stream for stdio transport (default: os.Stdin)
	StdioInput io.Reader

	// StdioOutput is the output stream for stdio transport (default: os.Stdout)
	StdioOutput io.Writer
}

ServerOptions holds configuration options for the MCP server

func DefaultServerOptions

func DefaultServerOptions() ServerOptions

DefaultServerOptions returns ServerOptions with default values

type TransportType

type TransportType string

TransportType represents the type of transport for the MCP server

const (
	// TransportStdio uses standard input/output
	TransportStdio TransportType = "stdio"
	// TransportSSE uses Server-Sent Events over HTTP
	TransportSSE TransportType = "sse"
	// TransportStreamableHTTP uses streamable HTTP transport
	TransportStreamableHTTP TransportType = "streamable-http"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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