Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func runDebugMetaAds(cmd *cobra.Command, args []string) error {
body["ad_account_id"] = debugMetaAdAccountID
}

c := client.NewREST(getWebAPIURL(), token)
c := client.NewREST(getWebAPIURL(), token, Version)
result, err := c.Post("/api/debug/meta-ads", body)
if err != nil {
return fmt.Errorf("debug query failed: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func maybeAutoRefresh(cache *ToolsCache) {
func runAutoRefresh(baseURL, token string) error {
cache, _ := loadToolsCache()

hashResult, err := client.FetchToolsHash(baseURL)
hashResult, err := client.FetchToolsHash(baseURL, Version)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func fetchAndCacheTools(baseURL, token string, verbose bool) (*ToolsCache, error
}

// Fetch and store the current hash
if hashResult, err := client.FetchToolsHash(baseURL); err == nil {
if hashResult, err := client.FetchToolsHash(baseURL, Version); err == nil {
cache.Hash = hashResult.Hash
}

Expand Down
10 changes: 8 additions & 2 deletions internal/client/mcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,14 @@ type ToolsHashResult struct {
// FetchToolsHash retrieves the combined tools hash from the server.
// baseURL is the MCP base URL (e.g. https://mcp.pipeboard.co).
// This endpoint requires no authentication.
func FetchToolsHash(baseURL string) (*ToolsHashResult, error) {
resp, err := http.Get(baseURL + "/api/tools-hash")
func FetchToolsHash(baseURL, version string) (*ToolsHashResult, error) {
req, err := http.NewRequest("GET", baseURL+"/api/tools-hash", nil)
if err != nil {
return nil, fmt.Errorf("creating request: %w", err)
}
req.Header.Set("User-Agent", "pipeboard-cli/"+version)

resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, fmt.Errorf("fetching tools hash: %w", err)
}
Expand Down
7 changes: 5 additions & 2 deletions internal/client/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ import (
type RESTClient struct {
baseURL string
token string
userAgent string
httpClient *http.Client
}

// NewREST creates a REST API client.
func NewREST(baseURL, token string) *RESTClient {
// NewREST creates a REST API client. version is used in the User-Agent header.
func NewREST(baseURL, token, version string) *RESTClient {
return &RESTClient{
baseURL: baseURL,
token: token,
userAgent: "pipeboard-cli/" + version,
httpClient: &http.Client{},
}
}
Expand All @@ -39,6 +41,7 @@ func (c *RESTClient) Post(path string, body interface{}) (map[string]interface{}

req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+c.token)
req.Header.Set("User-Agent", c.userAgent)

resp, err := c.httpClient.Do(req)
if err != nil {
Expand Down
Loading