server

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListPromptsResult

type ListPromptsResult struct {
	Prompts    []protocol.Prompt `json:"prompts"`
	NextCursor string            `json:"nextCursor"`
}

ListPromptsResult is the response type for prompts/list method

type ListResourcesResult

type ListResourcesResult struct {
	Resources  []protocol.Resource `json:"resources"`
	NextCursor string              `json:"nextCursor"`
}

ListResourcesResult is the response type for resources/list method

type ListToolsResult

type ListToolsResult struct {
	Tools      []protocol.Tool `json:"tools"`
	NextCursor string          `json:"nextCursor"`
}

ListToolsResult is the response type for tools/list method

type Server

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

Server represents an MCP server that can use different transports

func NewServer

func NewServer(logger zerolog.Logger, options ...ServerOption) *Server

NewServer creates a new server instance

func (*Server) GetRegistry

func (s *Server) GetRegistry() *pkg.ProviderRegistry

GetRegistry returns the server's provider registry

func (*Server) StartSSE

func (s *Server) StartSSE(ctx context.Context, port int) error

StartSSE starts the server with SSE transport on the specified port

func (*Server) StartStdio

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

StartStdio starts the server with stdio transport

func (*Server) Stop

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

Stop gracefully stops the server

type ServerOption

type ServerOption func(*Server)

func WithInitializeService

func WithInitializeService(is services.InitializeService) ServerOption

func WithPromptService

func WithPromptService(ps services.PromptService) ServerOption

func WithResourceService

func WithResourceService(rs services.ResourceService) ServerOption

func WithServerName

func WithServerName(name string) ServerOption

func WithServerVersion

func WithServerVersion(version string) ServerOption

func WithToolService

func WithToolService(ts services.ToolService) ServerOption

type StdioServer

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

StdioServer handles stdio transport for MCP protocol

func NewStdioServer

NewStdioServer creates a new stdio server instance

func (*StdioServer) Start

func (s *StdioServer) Start() error

Start begins listening for and handling messages on stdio

type Transport

type Transport interface {
	// Start starts the transport with the given context
	Start(ctx context.Context) error
	// Stop gracefully stops the transport with the given context
	Stop(ctx context.Context) error
}

Transport represents a server transport mechanism

Directories

Path Synopsis
transports
sse

Jump to

Keyboard shortcuts

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