mcptest

package
v0.27.1 Latest Latest
Warning

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

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

Documentation

Overview

Package mcptest implements helper functions for testing MCP servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server encapsulates an MCP server and manages resources like pipes and context.

func NewServer

func NewServer(t *testing.T, tools ...server.ServerTool) (*Server, error)

NewServer starts a new MCP server with the provided tools and returns the server instance.

func NewUnstartedServer

func NewUnstartedServer(t *testing.T) *Server

NewUnstartedServer creates a new MCP server instance with the given name, but does not start the server. Useful for tests where you need to add tools before starting the server.

func (*Server) AddTool

func (s *Server) AddTool(tool mcp.Tool, handler server.ToolHandlerFunc)

AddTool adds a tool to an unstarted server.

func (*Server) AddTools

func (s *Server) AddTools(tools ...server.ServerTool)

AddTools adds multiple tools to an unstarted server.

func (*Server) Client

func (s *Server) Client() *client.Client

Client returns an MCP client connected to the server. The client is already initialized, i.e. you do _not_ need to call Client.Initialize().

func (*Server) Close

func (s *Server) Close()

Close stops the server and cleans up resources like temporary directories.

func (*Server) Start

func (s *Server) Start() error

Start starts the server in a goroutine. Make sure to defer Close() after Start(). When using NewServer(), the returned server is already started.

Jump to

Keyboard shortcuts

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