Documentation
¶
Overview ¶
Package commands implements individual commands for the MCP CLI.
Package commands implements individual commands for the MCP CLI.
Index ¶
- Constants
- Variables
- func AliasCmd() *cobra.Command
- func CallCmd() *cobra.Command
- func FormatAndPrintResponse(cmd *cobra.Command, resp map[string]any, err error) error
- func GetPromptCmd() *cobra.Command
- func IsValidFormat(format string) bool
- func LoadProxyConfig() (map[string]map[string]string, error)
- func MockCmd() *cobra.Command
- func NewCmd() *cobra.Command
- func ProcessFlags(args []string) []string
- func PromptsCmd() *cobra.Command
- func ProxyCmd() *cobra.Command
- func ProxyStartCmd() *cobra.Command
- func ProxyToolCmd() *cobra.Command
- func ReadResourceCmd() *cobra.Command
- func ResourcesCmd() *cobra.Command
- func RootCmd() *cobra.Command
- func SaveProxyConfig(config map[string]map[string]string) error
- func ScanCmd() *cobra.Command
- func ShellCmd() *cobra.Command
- func ToolsCmd() *cobra.Command
- func VersionCmd() *cobra.Command
- type MockTransport
- type ServerConfig
Constants ¶
const ( FlagFormat = "--format" FlagFormatShort = "-f" FlagParams = "--params" FlagParamsShort = "-p" FlagHelp = "--help" FlagHelpShort = "-h" )
flags.
const ( EntityTypeTool = "tool" EntityTypePrompt = "prompt" EntityTypeRes = "resource" )
entity types.
Variables ¶
var ( // FormatOption is the format option for the command, valid values are "table", "json", and // "pretty". // Default is "table". FormatOption = "table" // ParamsString is the params for the command. ParamsString string )
var CreateClientFunc = func(args []string) (*client.Client, error) { if len(args) == 0 { return nil, ErrCommandRequired } isHTTP := func(str string) bool { return strings.HasPrefix(str, "http://") || strings.HasPrefix(str, "https://") } if len(args) == 1 { server, found := alias.GetServerCommand(args[0]) if found { if isHTTP(server) { return client.NewHTTP(server), nil } cmdParts := client.ParseCommandString(server) return client.NewStdio(cmdParts), nil } } if len(args) == 1 && isHTTP(args[0]) { return client.NewHTTP(args[0]), nil } return client.NewStdio(args), nil }
CreateClientFunc is the function used to create MCP clients. This can be replaced in tests to use a mock transport.
var (
ErrCommandRequired = fmt.Errorf("command to execute is required when using stdio transport")
)
sentinel errors.
var TemplatesPath = os.Getenv("HOME") + "/.mcpt/templates"
TemplatesPath information placeholder.
var Version = "dev"
Version information placeholder.
Functions ¶
func FormatAndPrintResponse ¶
FormatAndPrintResponse formats and prints an MCP response in the format specified by FormatOption.
func IsValidFormat ¶ added in v0.4.2
IsValidFormat returns true if the format is valid.
func LoadProxyConfig ¶
LoadProxyConfig loads the proxy configuration from the config file.
func ProcessFlags ¶
ProcessFlags processes command line flags, sets the format option, and returns the remaining arguments. Supported format options: json, pretty, and table.
For example, if the input arguments are ["tools", "--format", "pretty", "npx", "-y", "@modelcontextprotocol/server-filesystem", "~"], it would return ["npx", "-y", "@modelcontextprotocol/server-filesystem", "~"] and set the format option to "pretty".
func ProxyStartCmd ¶
ProxyStartCmd creates the proxy start command.
func ReadResourceCmd ¶
ReadResourceCmd creates the read-resource command.
func SaveProxyConfig ¶
SaveProxyConfig saves the proxy configuration to the config file.
Types ¶
type MockTransport ¶
MockTransport implements the transport.Transport interface for testing.
type ServerConfig ¶ added in v0.4.1
type ServerConfig struct {
Headers map[string]string `json:"headers,omitempty"`
Env map[string]string `json:"env,omitempty"`
Config map[string]interface{} `json:"config,omitempty"`
Source string `json:"source"`
Type string `json:"type,omitempty"`
Command string `json:"command,omitempty"`
URL string `json:"url,omitempty"`
Path string `json:"path,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Args []string `json:"args,omitempty"`
}
ServerConfig represents a configuration for a server.