mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add MCP tools for ChatGPT (#19102)
Addresses https://github.com/coder/internal/issues/772. Adds the toolset query parameter to the `/api/experimental/mcp/http` endpoint, which, when set to "chatgpt", exposes new `fetch` and `search` tools compatible with ChatGPT, as described in the [ChatGPT docs](https://platform.openai.com/docs/mcp). These tools are exposed in isolation because in my usage I found that ChatGPT refuses to connect to Coder if it sees additional MCP tools. <img width="1248" height="908" alt="Screenshot 2025-07-30 at 16 36 56" src="https://github.com/user-attachments/assets/ca31e57b-d18b-4998-9554-7a96a141527a" />
This commit is contained in:
@@ -36,6 +36,8 @@ const (
|
||||
ToolNameCreateTemplate = "coder_create_template"
|
||||
ToolNameDeleteTemplate = "coder_delete_template"
|
||||
ToolNameWorkspaceBash = "coder_workspace_bash"
|
||||
ToolNameChatGPTSearch = "search"
|
||||
ToolNameChatGPTFetch = "fetch"
|
||||
)
|
||||
|
||||
func NewDeps(client *codersdk.Client, opts ...func(*Deps)) (Deps, error) {
|
||||
@@ -56,6 +58,13 @@ type Deps struct {
|
||||
report func(ReportTaskArgs) error
|
||||
}
|
||||
|
||||
func (d Deps) ServerURL() 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
|
||||
@@ -194,6 +203,8 @@ var All = []GenericTool{
|
||||
UploadTarFile.Generic(),
|
||||
UpdateTemplateActiveVersion.Generic(),
|
||||
WorkspaceBash.Generic(),
|
||||
ChatGPTSearch.Generic(),
|
||||
ChatGPTFetch.Generic(),
|
||||
}
|
||||
|
||||
type ReportTaskArgs struct {
|
||||
|
||||
Reference in New Issue
Block a user