Skip to content

feat: add MCP tools for ChatGPT #19102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: move getServerURL under Deps
  • Loading branch information
hugodutka committed Aug 4, 2025
commit f86a119669acfcd8fdfb960b3d8ef6a39dde16ac
15 changes: 4 additions & 11 deletions codersdk/toolsdk/chatgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ import (
"github.com/coder/coder/v2/codersdk"
)

func getServerURL(deps Deps) string {
serverURLCopy := *deps.coderClient.URL
serverURLCopy.Path = ""
serverURLCopy.RawQuery = ""
return serverURLCopy.String()
}

type ObjectType string

const (
Expand Down Expand Up @@ -56,7 +49,7 @@ func createObjectID(objectType ObjectType, id string) ObjectID {
}

func searchTemplates(ctx context.Context, deps Deps, query string) ([]SearchResultItem, error) {
serverURL := getServerURL(deps)
serverURL := deps.getServerURL()
templates, err := deps.coderClient.Templates(ctx, codersdk.TemplateFilter{
SearchQuery: query,
})
Expand All @@ -76,7 +69,7 @@ func searchTemplates(ctx context.Context, deps Deps, query string) ([]SearchResu
}

func searchWorkspaces(ctx context.Context, deps Deps, query string) ([]SearchResultItem, error) {
serverURL := getServerURL(deps)
serverURL := deps.getServerURL()
workspaces, err := deps.coderClient.Workspaces(ctx, codersdk.WorkspaceFilter{
FilterQuery: query,
})
Expand Down Expand Up @@ -351,7 +344,7 @@ func fetchWorkspace(ctx context.Context, deps Deps, workspaceID string) (FetchRe
ID: workspace.ID.String(),
Title: workspace.Name,
Text: string(workspaceJSON),
URL: fmt.Sprintf("%s/%s/%s", getServerURL(deps), workspace.OwnerName, workspace.Name),
URL: fmt.Sprintf("%s/%s/%s", deps.getServerURL(), workspace.OwnerName, workspace.Name),
}, nil
}

Expand All @@ -372,7 +365,7 @@ func fetchTemplate(ctx context.Context, deps Deps, templateID string) (FetchResu
ID: template.ID.String(),
Title: template.DisplayName,
Text: string(templateJSON),
URL: fmt.Sprintf("%s/templates/%s/%s", getServerURL(deps), template.OrganizationName, template.Name),
URL: fmt.Sprintf("%s/templates/%s/%s", deps.getServerURL(), template.OrganizationName, template.Name),
}, nil
}

Expand Down
7 changes: 7 additions & 0 deletions codersdk/toolsdk/toolsdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ type Deps struct {
report func(ReportTaskArgs) error
}

func (d Deps) getServerURL() string {
serverURLCopy := *d.coderClient.URL
serverURLCopy.Path = ""
serverURLCopy.RawQuery = ""
return serverURLCopy.String()
}

func WithTaskReporter(fn func(ReportTaskArgs) error) func(*Deps) {
return func(d *Deps) {
d.report = fn
Expand Down