testserver

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package testserver provides a simple MCP test server for automated testing. It can run as either stdio or HTTP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartHTTP

func StartHTTP(t *testing.T) string

StartHTTP starts the test server as HTTP and returns the URL. The server is automatically stopped when the test completes.

func StdioCmd

func StdioCmd() (command string, args []string)

StdioCmd returns the command and args needed to run the test server in stdio mode. This requires the testserver binary to be built first (go build ./cmd/testserver). The returned command can be used with config.MCPServer.

Types

type Server

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

Server is a simple MCP test server with predefined tools.

func New

func New() *Server

New creates a new test server with predefined tools.

func (*Server) RunHTTP

func (s *Server) RunHTTP(ctx context.Context, addr string) (string, error)

RunHTTP runs the server as an HTTP server on the given address. Returns the actual address the server is listening on.

func (*Server) RunStdio

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

RunStdio runs the server using stdio transport. This is typically called from a test binary or main function.

Jump to

Keyboard shortcuts

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