cli

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatText = "text"
	FormatJSON = "json"
)

Output format constants

View Source
const (
	ConnectionCreating   = "🔄 Creating MCP service...\n"
	ConnectionStarting   = "🚀 Starting process: %s %s\n"
	ConnectionConnecting = "🌐 Connecting to URL: %s\n"
	ConnectionTimeout    = "⏳ Establishing connection (timeout: %s)...\n"
	ConnectionSuccess    = "✅ Connected successfully\n"
	ConnectionFailed     = "❌ Connection failed\n"
)

Connection message constants

Variables

This section is empty.

Functions

func BuildOAuthConfig added in v0.8.3

func BuildOAuthConfig(cmd *cobra.Command, connConfig *config.ConnectionConfig) (*oauth.Config, error)

BuildOAuthConfig translates --oauth-* flags into an *oauth.Config. Returns (nil, nil) when no OAuth flag was supplied. The function is shared by the CLI parseConnectionConfig path and the TUI launcher in main.go which processes the same persistent flags before handing the connection config to the screen manager.

func ConformFailedError added in v0.8.3

func ConformFailedError() error

ConformFailedError returns the sentinel for tests to assert via errors.Is without importing the unexported variable.

func SetGlobalConnection

func SetGlobalConnection(conn *config.ConnectionConfig)

SetGlobalConnection sets the global connection config

func VerifyFailedError added in v0.8.3

func VerifyFailedError() error

VerifyFailedError returns the sentinel for tests that need to assert the non-zero exit path without importing the unexported variable.

Types

type BaseCommand

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

BaseCommand provides common functionality for all CLI commands

func NewBaseCommand

func NewBaseCommand() *BaseCommand

NewBaseCommand creates a new base command

func (*BaseCommand) CloseClient

func (c *BaseCommand) CloseClient() error

CloseClient properly closes the MCP client

func (*BaseCommand) CreateClient

func (c *BaseCommand) CreateClient(cmd *cobra.Command) error

CreateClient creates and initializes an MCP client

func (*BaseCommand) GetOutputFormat

func (c *BaseCommand) GetOutputFormat() OutputFormat

GetOutputFormat returns the current output format

func (*BaseCommand) GetService

func (c *BaseCommand) GetService() mcp.Service

GetService returns the MCP service

func (*BaseCommand) HandleError

func (c *BaseCommand) HandleError(err error, operation string) error

HandleError provides consistent error handling across commands

func (*BaseCommand) PostRunE

func (c *BaseCommand) PostRunE(cmd *cobra.Command, args []string) error

PostRunE is a common post-run function that cleans up the client

func (*BaseCommand) PreRunE

func (c *BaseCommand) PreRunE(cmd *cobra.Command, args []string) error

PreRunE is a common pre-run function that sets up the client

func (*BaseCommand) SetOutputFormat

func (c *BaseCommand) SetOutputFormat(cmd *cobra.Command) error

SetOutputFormat sets the output format for the command

func (*BaseCommand) ValidateConnection

func (c *BaseCommand) ValidateConnection() error

ValidateConnection checks if the client is connected

func (*BaseCommand) WithContext

func (c *BaseCommand) WithContext() (context.Context, context.CancelFunc)

WithContext creates a context with timeout for the command

func (*BaseCommand) WithTimeout

func (c *BaseCommand) WithTimeout(timeout time.Duration) *BaseCommand

WithTimeout sets the command timeout

type CapabilitiesCommand added in v0.8.3

type CapabilitiesCommand struct {
	BaseCommand
}

CapabilitiesCommand surfaces the negotiated MCP capabilities for the connected server plus the client capabilities mcp-tui sent during initialize. Output is JSON (the only format) so the command is scripting-friendly: pipe to jq, diff against a fixture, etc. There is no text variant — the rendered view lives in the TUI Capabilities tab (Ctrl+D).

func NewCapabilitiesCommand added in v0.8.3

func NewCapabilitiesCommand() *CapabilitiesCommand

NewCapabilitiesCommand creates a new capabilities command.

func (*CapabilitiesCommand) CreateCommand added in v0.8.3

func (c *CapabilitiesCommand) CreateCommand() *cobra.Command

CreateCommand creates the cobra command. Connection flags are inherited from the persistent flags on the root command (see main.go).

func (*CapabilitiesCommand) RunE added in v0.8.3

func (c *CapabilitiesCommand) RunE(cmd *cobra.Command, args []string) error

RunE executes the capabilities command. Failure to retrieve the snapshot is treated as a hard error — if we got past PreRunE (which establishes the connection), the snapshot must be populated. Any nil here is a programming error in the service.

type ConformCommand added in v0.8.3

type ConformCommand struct {
	BaseCommand
}

ConformCommand exposes the end-to-end conformance suite as a CLI subcommand. It runs every protocol scenario plus all verify probes, prints a per-scenario PASS/FAIL summary, and (with --report-junit) writes a JUnit XML report.

Usage:

mcp-tui conform <url>                       # run all scenarios + HTTP probes
mcp-tui conform --cmd npx --args ...        # run all scenarios against stdio
mcp-tui conform --scenario tools.list <url> # run one scenario
mcp-tui conform --report-junit out.xml <url>
mcp-tui conform --sampling-stub "ok" --cmd npx --args "@mcp/server-everything,stdio"

func NewConformCommand added in v0.8.3

func NewConformCommand() *ConformCommand

NewConformCommand creates a new conform command.

func (*ConformCommand) CreateCommand added in v0.8.3

func (c *ConformCommand) CreateCommand() *cobra.Command

CreateCommand registers the cobra command. The conform command does NOT inherit BaseCommand.PreRunE — the runner drives its own connection so the CLI's persistent-session machinery would just spawn a duplicate.

func (*ConformCommand) RunE added in v0.8.3

func (c *ConformCommand) RunE(cmd *cobra.Command, args []string) error

RunE drives the conformance run end-to-end. The flow:

  1. Resolve target from positional/--url/--cmd flags.
  2. Build a conform.Runner with target options.
  3. Run scenarios (one or all).
  4. Print text summary.
  5. Optionally write JUnit XML.
  6. Return errConformFailed when any scenario failed (cobra exits 1).

type OutputFormat

type OutputFormat string

OutputFormat represents supported output formats

const (
	OutputFormatText OutputFormat = "text"
	OutputFormatJSON OutputFormat = "json"
)

type PromptCommand

type PromptCommand struct {
	*BaseCommand
}

PromptCommand handles prompt-related CLI operations

func NewPromptCommand

func NewPromptCommand() *PromptCommand

NewPromptCommand creates a new prompt command

func (*PromptCommand) CreateCommand

func (pc *PromptCommand) CreateCommand() *cobra.Command

CreateCommand creates the cobra command for prompts

type ResourceCommand

type ResourceCommand struct {
	*BaseCommand
}

ResourceCommand handles resource-related CLI operations

func NewResourceCommand

func NewResourceCommand() *ResourceCommand

NewResourceCommand creates a new resource command

func (*ResourceCommand) CreateCommand

func (rc *ResourceCommand) CreateCommand() *cobra.Command

CreateCommand creates the cobra command for resources

type ServerCommand

type ServerCommand struct {
	BaseCommand
}

ServerCommand handles server information operations

func NewServerCommand

func NewServerCommand() *ServerCommand

NewServerCommand creates a new server command

func (*ServerCommand) CreateCommand

func (c *ServerCommand) CreateCommand() *cobra.Command

CreateCommand creates the cobra command

func (*ServerCommand) RunE

func (c *ServerCommand) RunE(cmd *cobra.Command, args []string) error

RunE executes the server command

type ToolCommand

type ToolCommand struct {
	*BaseCommand
}

ToolCommand handles tool-related CLI operations

func NewToolCommand

func NewToolCommand() *ToolCommand

NewToolCommand creates a new tool command

func (*ToolCommand) CreateCommand

func (tc *ToolCommand) CreateCommand() *cobra.Command

CreateCommand creates the cobra command for tools

type VerifyCommand added in v0.8.3

type VerifyCommand struct {
	BaseCommand
}

VerifyCommand exposes the behavior probes from internal/cli/verify as a CLI subcommand. Unlike the other CLI commands it does NOT establish a persistent MCP session in PreRunE — each probe drives its own short-lived connection so users can run a single probe against a URL without the SDK handshake overhead.

Usage:

mcp-tui verify <url>                    # run all HTTP probes
mcp-tui verify --cmd npx --args ...     # run all probes (incl. stdio)
mcp-tui verify --probe cross-origin <url>
mcp-tui verify --json <url>             # machine-readable output

func NewVerifyCommand added in v0.8.3

func NewVerifyCommand() *VerifyCommand

NewVerifyCommand creates a new verify command.

func (*VerifyCommand) CreateCommand added in v0.8.3

func (c *VerifyCommand) CreateCommand() *cobra.Command

CreateCommand creates the cobra command. The verify command does NOT inherit BaseCommand.PreRunE — probes drive their own connections so we don't pay for a persistent SDK session every invocation.

func (*VerifyCommand) RunE added in v0.8.3

func (c *VerifyCommand) RunE(cmd *cobra.Command, args []string) error

RunE dispatches to the verify package. The flow:

  1. Resolve the target from --url / positional arg / --cmd flags.
  2. Filter the probe list by --probe (if set).
  3. Execute probes; collect ProbeResult slice.
  4. Format as JSON or human text.
  5. Exit 0 iff all passed (cobra returns nil → main exits 0; we set exit 1 by writing to os.Stderr and returning a sentinel error).

Directories

Path Synopsis
Package conform implements the end-to-end MCP conformance suite.
Package conform implements the end-to-end MCP conformance suite.
Package verify implements behavior probes for MCP servers introduced in SDK v1.4.0–v1.6.0.
Package verify implements behavior probes for MCP servers introduced in SDK v1.4.0–v1.6.0.

Jump to

Keyboard shortcuts

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