diff --git a/README.md b/README.md index be2a417..ac92374 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ cremote [options] ### Commands +- `version`: Show version information for CLI and daemon - `open-tab`: Open a new tab and return its ID - `load-url`: Load a URL in a tab - `fill-form`: Fill a form field with a value diff --git a/client/client.go b/client/client.go index b7282e5..1ffe019 100644 --- a/client/client.go +++ b/client/client.go @@ -58,6 +58,25 @@ func (c *Client) CheckStatus() (bool, error) { return response.Success, nil } +// GetVersion gets the daemon version +func (c *Client) GetVersion() (string, error) { + response, err := c.SendCommand("version", map[string]string{}) + if err != nil { + return "", err + } + + if !response.Success { + return "", fmt.Errorf("failed to get version: %s", response.Error) + } + + // The version should be in the Data field as a string + if version, ok := response.Data.(string); ok { + return version, nil + } + + return "", fmt.Errorf("unexpected version response format") +} + // TabInfo contains information about a tab type TabInfo struct { ID string `json:"id"` diff --git a/daemon/daemon.go b/daemon/daemon.go index 7e919c3..f005f94 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -21,6 +21,8 @@ import ( "github.com/go-rod/rod/lib/proto" ) +const Version = "2.0.0" + // Daemon is the main server that manages browser connections type Daemon struct { browser *rod.Browser @@ -226,6 +228,12 @@ func (d *Daemon) handleCommand(w http.ResponseWriter, r *http.Request) { var response Response switch cmd.Action { + case "version": + response = Response{ + Success: true, + Data: Version, + } + case "open-tab": timeoutStr := cmd.Params["timeout"] diff --git a/main.go b/main.go index 50e5f06..a9fdc1b 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,8 @@ import ( "git.teamworkapps.com/shortcut/cremote/client" ) +const Version = "2.0.0" + var ( // Global flags daemonHost = flag.String("host", "localhost", "Daemon host") @@ -149,6 +151,19 @@ func main() { // Parse the appropriate subcommand switch os.Args[1] { + case "version": + fmt.Printf("cremote CLI version %s\n", Version) + + // Also get daemon version if possible + c := client.NewClient("localhost", 8989) + daemonVersion, err := c.GetVersion() + if err != nil { + fmt.Printf("Daemon: Unable to connect (%v)\n", err) + } else { + fmt.Printf("Daemon version %s\n", daemonVersion) + } + return + case "open-tab": openTabCmd.Parse(os.Args[2:]) @@ -487,6 +502,7 @@ func main() { func printUsage() { fmt.Println("Usage: cremote [options]") fmt.Println("Commands:") + fmt.Println(" version Show version information for CLI and daemon") fmt.Println(" open-tab Open a new tab and return its ID") fmt.Println(" load-url Load a URL in a tab") fmt.Println(" fill-form Fill a form field with a value") diff --git a/mcp/README.md b/mcp/README.md index 508b2e1..a025d1a 100644 --- a/mcp/README.md +++ b/mcp/README.md @@ -32,6 +32,20 @@ This is a Model Context Protocol (MCP) server that exposes cremote's web automat ## Available Tools (27 Total) +### Version Information + +#### `version_cremotemcp` +Get version information for MCP server and daemon. + +```json +{ + "name": "version_cremotemcp", + "arguments": {} +} +``` + +Returns version information for both the MCP server and the connected daemon. + ### Core Web Automation Tools (10 tools) #### 1. `web_navigate_cremotemcp` diff --git a/mcp/cremote-mcp b/mcp/cremote-mcp index 2923d02..0d74570 100755 Binary files a/mcp/cremote-mcp and b/mcp/cremote-mcp differ diff --git a/mcp/main.go b/mcp/main.go index a1dd1a4..571bb1c 100644 --- a/mcp/main.go +++ b/mcp/main.go @@ -14,6 +14,8 @@ import ( "github.com/mark3labs/mcp-go/server" ) +const Version = "2.0.0" + // CremoteServer wraps the cremote client for MCP type CremoteServer struct { client *client.Client @@ -80,6 +82,30 @@ func main() { // Create MCP server mcpServer := server.NewMCPServer("cremote-mcp", "2.0.0") + // Register version tool + mcpServer.AddTool(mcp.Tool{ + Name: "version_cremotemcp", + Description: "Get version information for MCP server and daemon", + InputSchema: mcp.ToolInputSchema{ + Type: "object", + Properties: map[string]any{}, + Required: []string{}, + }, + }, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + // Get daemon version + daemonVersion, err := cremoteServer.client.GetVersion() + if err != nil { + daemonVersion = fmt.Sprintf("Unable to connect: %v", err) + } + + return &mcp.CallToolResult{ + Content: []mcp.Content{ + mcp.NewTextContent(fmt.Sprintf("MCP Server version: %s\nDaemon version: %s", Version, daemonVersion)), + }, + IsError: false, + }, nil + }) + // Register web_navigate tool mcpServer.AddTool(mcp.Tool{ Name: "web_navigate",