(ctx context.Context)
| 134 | } |
| 135 | |
| 136 | func (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 | |
| 164 | func (p *StreamableHTTPServerProxy) Shutdown(_ context.Context) error { |
| 165 | if p.client == nil { |
no test coverage detected