MCPcopy Index your code
hub / github.com/coder/coder / RegisterChatGPTTools

Method RegisterChatGPTTools

coderd/mcp/mcp.go:103–122  ·  view source on GitHub ↗

ChatGPT tools are the search and fetch tools as defined in https://platform.openai.com/docs/mcp. We do not expose any extra ones because ChatGPT has an undocumented "Safety Scan" feature. In my experiments, if I included extra tools in the MCP server, ChatGPT would often - but not always - refuse to

(client *codersdk.Client, opts ...func(*toolsdk.Deps))

Source from the content-addressed store, hash-verified

101// In my experiments, if I included extra tools in the MCP server, ChatGPT would often - but not always -
102// refuse to add Coder as a connector.
103func (s *Server) RegisterChatGPTTools(client *codersdk.Client, opts ...func(*toolsdk.Deps)) error {
104 if client == nil {
105 return xerrors.New("client cannot be nil: MCP HTTP server requires authenticated client")
106 }
107
108 // Create tool dependencies
109 toolDeps, err := toolsdk.NewDeps(client, opts...)
110 if err != nil {
111 return xerrors.Errorf("failed to initialize tool dependencies: %w", err)
112 }
113
114 for _, tool := range toolsdk.All {
115 if tool.Name != toolsdk.ToolNameChatGPTSearch && tool.Name != toolsdk.ToolNameChatGPTFetch {
116 continue
117 }
118
119 s.mcpServer.AddTools(mcpFromSDK(tool, toolDeps))
120 }
121 return nil
122}
123
124// mcpFromSDK adapts a toolsdk.Tool to go-mcp's server.ServerTool
125func mcpFromSDK(sdkTool toolsdk.GenericTool, tb toolsdk.Deps) server.ServerTool {

Callers 1

mcpHTTPHandlerMethod · 0.95

Calls 4

NewDepsFunction · 0.92
mcpFromSDKFunction · 0.70
NewMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected