server

package
v0.1.0-rc4 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package server wires the mcpsmithy tool engine to the MCP SDK.

The MCP framing (initialize, tools/list, tools/call, list-changed notifications) and transports (stdio, Streamable HTTP) live in github.com/modelcontextprotocol/go-sdk/mcp. This package owns the bridge: turn each Engine tool into an mcp.Tool, decode arguments, and pipe results back as CallToolResult.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine interface {
	Tools() map[string]config.Tool
	Execute(ctx context.Context, name string, params map[string]any) (string, error)
}

Engine is the interface that tool engines must implement to be served by the MCP server. Both tools.Engine (config-driven) and setup.Engine (config-authoring) satisfy this interface.

type Option

type Option func(*Server)

Option configures a Server.

func WithHTTP

func WithHTTP(addr string) Option

WithHTTP configures the server to use Streamable HTTP bound to addr (e.g. ":8080").

type Server

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

Server adapts an Engine to mcp.Server. It supports two transports: stdio (default) and Streamable HTTP, selected via Option.

func New

func New(eng Engine, opts ...Option) *Server

New creates a server using the stdio transport by default.

func (*Server) Serve

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

Serve starts the configured transport and blocks until ctx is cancelled or the underlying connection closes.

func (*Server) SwapEngine

func (s *Server) SwapEngine(eng Engine)

SwapEngine atomically replaces the running engine. Adding/removing tools triggers tools/list_changed notifications via the SDK.

Jump to

Keyboard shortcuts

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