server

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package server implements the Virtual MCP Server that aggregates multiple backend MCP servers into a unified interface.

The server exposes aggregated capabilities (tools, resources, prompts) and routes incoming MCP protocol requests to appropriate backend workloads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Name is the server name exposed in MCP protocol
	Name string

	// Version is the server version
	Version string

	// Host is the bind address (default: "127.0.0.1")
	Host string

	// Port is the bind port (default: 4483)
	Port int

	// EndpointPath is the MCP endpoint path (default: "/mcp")
	EndpointPath string

	// SessionTTL is the session time-to-live duration (default: 30 minutes)
	// Sessions inactive for this duration will be automatically cleaned up
	SessionTTL time.Duration

	// AuthMiddleware is the optional authentication middleware to apply to MCP routes.
	// If nil, no authentication is required.
	// This should be a composed middleware chain (e.g., TokenValidator → IdentityMiddleware).
	AuthMiddleware func(http.Handler) http.Handler

	// AuthInfoHandler is the optional handler for /.well-known/oauth-protected-resource endpoint.
	// Exposes OIDC discovery information about the protected resource.
	AuthInfoHandler http.Handler
}

Config holds the Virtual MCP Server configuration.

type Server

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

Server is the Virtual MCP Server that aggregates multiple backends.

func New

func New(
	cfg *Config,
	rt router.Router,
	backendClient vmcp.BackendClient,
	discoveryMgr discovery.Manager,
	backends []vmcp.Backend,
) *Server

New creates a new Virtual MCP Server instance.

func (*Server) Address

func (s *Server) Address() string

Address returns the server's actual listen address. If the server is started with port 0, this returns the actual bound port.

func (*Server) Ready

func (s *Server) Ready() <-chan struct{}

Ready returns a channel that is closed when the server is ready to accept connections. This is useful for testing and synchronization.

func (*Server) SessionManager

func (s *Server) SessionManager() *transportsession.Manager

SessionManager returns the session manager instance. This is useful for testing and monitoring.

func (*Server) Start

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

Start starts the Virtual MCP Server and begins serving requests.

func (*Server) Stop

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

Stop gracefully stops the Virtual MCP Server.

Directories

Path Synopsis
Package adapter provides a layer between aggregator and SDK.
Package adapter provides a layer between aggregator and SDK.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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