Documentation
¶
Index ¶
- func CreateTestContentDir(t testing.TB, opts *ContentDirOptions) string
- func DefaultMetadata() string
- func GetFreePort() (int, error)
- func MustGetFreePort(t testing.TB) int
- func NewTestFlags(t testing.TB, contentDir string, opts *FlagOptions) *pflag.FlagSet
- type ContentDirOptions
- type FlagOptions
- type RunnerFunc
- type Service
- type TestClient
- func (tc *TestClient) CallTool(ctx context.Context, name string, args map[string]any) (*mcp.CallToolResult, error)
- func (tc *TestClient) Close()
- func (tc *TestClient) GetPrompt(ctx context.Context, name string, args map[string]string) (*mcp.GetPromptResult, error)
- func (tc *TestClient) InitializeResult() *mcp.InitializeResult
- func (tc *TestClient) ListPrompts(ctx context.Context) (*mcp.ListPromptsResult, error)
- func (tc *TestClient) ListResources(ctx context.Context) (*mcp.ListResourcesResult, error)
- func (tc *TestClient) ListTools(ctx context.Context) (*mcp.ListToolsResult, error)
- func (tc *TestClient) ReadResource(ctx context.Context, uri string) (*mcp.ReadResourceResult, error)
- type TestEnv
- type TestEnvContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTestContentDir ¶
func CreateTestContentDir(t testing.TB, opts *ContentDirOptions) string
CreateTestContentDir creates a temp content directory with metadata and optional resources. Returns the content directory path.
func DefaultMetadata ¶
func DefaultMetadata() string
DefaultMetadata returns the default test metadata YAML
func MustGetFreePort ¶
MustGetFreePort returns a free port or fails the test
func NewTestFlags ¶
NewTestFlags creates a configured pflag.FlagSet for testing
Types ¶
type ContentDirOptions ¶
type ContentDirOptions struct {
Metadata string // Custom metadata YAML (uses default if empty)
Resources map[string]string // filename -> content (no resources if nil)
Prompts map[string]string // filename -> content (no prompts if nil)
}
ContentDirOptions configures CreateTestContentDir
type FlagOptions ¶
type FlagOptions struct {
Port int // Uses free port if 0
Transport string // Defaults to "sse"
AuthType string // Defaults to "none"
Host string // Defaults to "localhost"
Scheme string // Defaults to "" (uses config default "acdc")
}
FlagOptions configures NewTestFlags
type RunnerFunc ¶
type TestClient ¶ added in v0.3.0
type TestClient struct {
Session *mcp.ClientSession
// contains filtered or unexported fields
}
TestClient wraps an MCP ClientSession for testing via stdio or SSE transport.
func NewSSETestClient ¶ added in v0.3.0
func NewSSETestClient(t testing.TB, contentOpts *ContentDirOptions) *TestClient
NewSSETestClient creates a test client connected to an ACDC server via SSE transport. It starts the server, creates an MCP client, and connects via SSE.
func NewStdioTestClient ¶ added in v0.3.0
func NewStdioTestClient(t testing.TB, contentOpts *ContentDirOptions) *TestClient
NewStdioTestClient creates a test client connected to an ACDC server via stdio transport. It starts the server, creates an MCP client, and connects them via pipes.
func (*TestClient) CallTool ¶ added in v0.3.0
func (tc *TestClient) CallTool(ctx context.Context, name string, args map[string]any) (*mcp.CallToolResult, error)
CallTool calls a tool by name with the given arguments
func (*TestClient) Close ¶ added in v0.3.0
func (tc *TestClient) Close()
Close stops the client and server
func (*TestClient) GetPrompt ¶ added in v0.3.0
func (tc *TestClient) GetPrompt(ctx context.Context, name string, args map[string]string) (*mcp.GetPromptResult, error)
GetPrompt gets a prompt by name with arguments
func (*TestClient) InitializeResult ¶ added in v0.3.0
func (tc *TestClient) InitializeResult() *mcp.InitializeResult
InitializeResult returns the server's initialize response
func (*TestClient) ListPrompts ¶ added in v0.3.0
func (tc *TestClient) ListPrompts(ctx context.Context) (*mcp.ListPromptsResult, error)
ListPrompts returns all prompts from the server
func (*TestClient) ListResources ¶ added in v0.3.0
func (tc *TestClient) ListResources(ctx context.Context) (*mcp.ListResourcesResult, error)
ListResources returns all resources from the server
func (*TestClient) ListTools ¶ added in v0.3.0
func (tc *TestClient) ListTools(ctx context.Context) (*mcp.ListToolsResult, error)
ListTools returns all tools from the server
func (*TestClient) ReadResource ¶ added in v0.3.0
func (tc *TestClient) ReadResource(ctx context.Context, uri string) (*mcp.ReadResourceResult, error)
ReadResource reads a resource by URI
type TestEnv ¶
type TestEnv interface {
Start() (map[string]any, error)
Stop() error
GetContext() TestEnvContext
}