server

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package server provides the MCP server implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MCPServer

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

MCPServer represents an MCP server that can be used to handle MCP protocol messages. It supports both static tool registration and dynamic provider-based tools.

func NewMCPServer

func NewMCPServer(name, version string, logger *log.Logger) *MCPServer

NewMCPServer creates a new MCP server with the specified name and version.

func (*MCPServer) AddTool

func (s *MCPServer) AddTool(ctx context.Context, tool *types.Tool, handler ToolHandler) error

AddTool adds a tool to the MCP server.

func (*MCPServer) GetAddress

func (s *MCPServer) GetAddress() string

GetAddress returns the HTTP address for the server.

func (*MCPServer) RegisterProvider

func (s *MCPServer) RegisterProvider(ctx context.Context, provider plugin.Provider) error

RegisterProvider registers a tool provider with the server.

func (*MCPServer) ServeHTTP

func (s *MCPServer) ServeHTTP() error

ServeHTTP starts the HTTP server.

func (*MCPServer) ServeStdio

func (s *MCPServer) ServeStdio() error

ServeStdio serves the MCP server over standard I/O.

func (*MCPServer) SetAddress

func (s *MCPServer) SetAddress(addr string)

SetAddress sets the HTTP address for the server.

func (*MCPServer) Shutdown

func (s *MCPServer) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the HTTP server.

func (*MCPServer) UnregisterProvider

func (s *MCPServer) UnregisterProvider(ctx context.Context, providerID string) error

UnregisterProvider removes a tool provider from the server.

type ToolCallRequest

type ToolCallRequest struct {
	Name       string
	Parameters map[string]interface{}
	Session    *types.ClientSession
}

ToolCallRequest represents a request to execute a tool.

type ToolHandler

type ToolHandler func(ctx context.Context, request ToolCallRequest) (interface{}, error)

ToolHandler is a function that handles tool calls.

Jump to

Keyboard shortcuts

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