server

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package server provides the MCP server implementation for Speedgrapher.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(cfg Config) (*mcp.Server, error)

NewServer creates the server and registers fog, slop, seo, and vale tools. Deprecated: Use New(version, opts...) instead.

func NewStreamableHandler

func NewStreamableHandler(s *mcp.Server, opts *mcp.StreamableHTTPOptions) http.Handler

NewStreamableHandler creates streamable HTTP handler using mcp.NewStreamableHTTPHandler. Deprecated: Use Server.HTTPHandler or Server.ServeHTTP instead.

func RunStdio

func RunStdio(ctx context.Context, s *mcp.Server) error

RunStdio runs stdio transport using s.Run(ctx, &mcp.StdioTransport{}). Deprecated: Use Server.Run instead.

func RunStreamableHTTP

func RunStreamableHTTP(ctx context.Context, s *mcp.Server, addr string) error

RunStreamableHTTP starts an http.Server with graceful shutdown on context cancellation. Deprecated: Use Server.ServeHTTP instead.

Types

type Config

type Config struct {
	WorkspaceDir string
	Version      string
}

Config holds legacy configuration parameters for initializing the Speedgrapher MCP server.

type Option added in v0.10.0

type Option func(*Server)

Option defines a functional option for configuring a Server.

func WithAllowedOrigins added in v0.10.0

func WithAllowedOrigins(origins ...string) Option

WithAllowedOrigins sets the allowed CORS origins.

func WithIdleTimeout added in v0.10.0

func WithIdleTimeout(d time.Duration) Option

WithIdleTimeout sets the HTTP server IdleTimeout.

func WithInstructions added in v0.10.0

func WithInstructions(instructions string) Option

WithInstructions sets custom MCP server instructions.

func WithReadTimeout added in v0.10.0

func WithReadTimeout(d time.Duration) Option

WithReadTimeout sets the HTTP server ReadTimeout.

func WithServerConfig added in v0.10.0

func WithServerConfig(cfg config.ServerConfig) Option

WithServerConfig configures allowed origins and timeouts from config.ServerConfig.

func WithShutdownTimeout added in v0.10.0

func WithShutdownTimeout(d time.Duration) Option

WithShutdownTimeout sets the HTTP server ShutdownTimeout.

func WithWorkspaceDir added in v0.10.0

func WithWorkspaceDir(dir string) Option

WithWorkspaceDir sets the workspace directory for the server and registered tools.

func WithWriteTimeout added in v0.10.0

func WithWriteTimeout(d time.Duration) Option

WithWriteTimeout sets the HTTP server WriteTimeout.

type Server added in v0.10.0

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

Server encapsulates the MCP server and its lifecycle configuration.

func New added in v0.10.0

func New(version string, opts ...Option) *Server

New creates a new Server instance.

func (*Server) Connect added in v0.10.0

func (s *Server) Connect(ctx context.Context, transport mcp.Transport, initOpts *mcp.ServerSessionOptions) (*mcp.ServerSession, error)

Connect connects the server to a transport for in-memory or custom testing sessions.

func (*Server) HTTPHandler added in v0.10.0

func (s *Server) HTTPHandler() http.Handler

HTTPHandler returns the HTTP handler wrapping the streamable MCP handler.

func (*Server) MCPServer added in v0.10.0

func (s *Server) MCPServer() *mcp.Server

MCPServer returns the underlying mcp.Server instance.

func (*Server) RegisterHandlers added in v0.10.0

func (s *Server) RegisterHandlers() error

RegisterHandlers wires all tools idempotently using sync.Once.

func (*Server) Run added in v0.10.0

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

Run starts the MCP server using Stdio transport with clean disconnect handling.

func (*Server) ServeHTTP added in v0.10.0

func (s *Server) ServeHTTP(ctx context.Context, addr string) error

ServeHTTP starts the server over HTTP using StreamableHTTP with graceful shutdown.

Jump to

Keyboard shortcuts

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