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

Method handleListTools

agent/x/agentmcp/api.go:42–63  ·  view source on GitHub ↗

handleListTools returns the current MCP tool cache after the manager performs startup-safe config synchronization.

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

40// handleListTools returns the current MCP tool cache after the
41// manager performs startup-safe config synchronization.
42func (api *API) handleListTools(rw http.ResponseWriter, r *http.Request) {
43 ctx := r.Context()
44 logger := api.logger.With(agentchat.Fields(ctx)...)
45
46 tools, err := api.manager.Tools(ctx, api.mcpConfigFiles())
47 if err != nil {
48 switch {
49 case errors.Is(err, context.Canceled):
50 logger.Warn(ctx, "mcp tool list canceled by caller", slog.Error(err))
51 case errors.Is(err, context.DeadlineExceeded):
52 logger.Warn(ctx, "mcp tool list timed out", slog.Error(err))
53 default:
54 logger.Warn(ctx, "mcp tool list failed", slog.Error(err))
55 }
56 }
57 if tools == nil {
58 tools = []workspacesdk.MCPToolInfo{}
59 }
60 httpapi.Write(ctx, rw, http.StatusOK, workspacesdk.ListMCPToolsResponse{
61 Tools: tools,
62 })
63}
64
65// handleCallTool proxies a tool invocation to the appropriate
66// MCP server based on the tool name prefix.

Callers

nothing calls this directly

Calls 6

FieldsFunction · 0.92
WriteFunction · 0.92
ToolsMethod · 0.80
ContextMethod · 0.65
IsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected