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

Method fetchTools

aibridge/mcp/proxy_streamable_http.go:136–162  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

134}
135
136func (p *StreamableHTTPServerProxy) fetchTools(ctx context.Context) (_ map[string]*Tool, outErr error) {
137 ctx, span := p.tracer.Start(ctx, "StreamableHTTPServerProxy.Init.fetchTools", trace.WithAttributes(p.traceAttributes()...))
138 defer tracing.EndSpanErr(span, &outErr)
139
140 tools, err := p.client.ListTools(ctx, mcp.ListToolsRequest{})
141 if err != nil {
142 return nil, xerrors.Errorf("list MCP tools: %w", err)
143 }
144
145 out := make(map[string]*Tool, len(tools.Tools))
146 for _, tool := range tools.Tools {
147 encodedID := EncodeToolID(p.serverName, tool.Name)
148 out[encodedID] = &Tool{
149 Client: p.client,
150 ID: encodedID,
151 Name: tool.Name,
152 ServerName: p.serverName,
153 ServerURL: p.serverURL,
154 Description: tool.Description,
155 Params: tool.InputSchema.Properties,
156 Required: tool.InputSchema.Required,
157 Logger: p.logger,
158 }
159 }
160 span.SetAttributes(append(p.traceAttributes(), attribute.Int(tracing.MCPToolCount, len(out)))...)
161 return out, nil
162}
163
164func (p *StreamableHTTPServerProxy) Shutdown(_ context.Context) error {
165 if p.client == nil {

Callers 1

InitMethod · 0.95

Calls 7

traceAttributesMethod · 0.95
EndSpanErrFunction · 0.92
EncodeToolIDFunction · 0.85
IntMethod · 0.80
StartMethod · 0.65
ListToolsMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected