cli

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 12 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 SetGlobalConnection

func SetGlobalConnection(conn *config.ConnectionConfig)

SetGlobalConnection sets the global connection config

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 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

Jump to

Keyboard shortcuts

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