MCPcopy
hub / github.com/modelcontextprotocol/registry / fetchFromHTTP

Function fetchFromHTTP

internal/importer/importer.go:131–148  ·  view source on GitHub ↗
(ctx context.Context, url string)

Source from the content-addressed store, hash-verified

129}
130
131func fetchFromHTTP(ctx context.Context, url string) ([]byte, error) {
132 req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
133 if err != nil {
134 return nil, fmt.Errorf("failed to create HTTP request: %w", err)
135 }
136
137 resp, err := http.DefaultClient.Do(req)
138 if err != nil {
139 return nil, fmt.Errorf("failed to fetch from HTTP: %w", err)
140 }
141 defer resp.Body.Close()
142
143 if resp.StatusCode != http.StatusOK {
144 return nil, fmt.Errorf("HTTP request failed with status: %d", resp.StatusCode)
145 }
146
147 return io.ReadAll(resp.Body)
148}
149
150func fetchFromRegistryAPI(ctx context.Context, baseURL string) ([]*apiv0.ServerJSON, error) {
151 var allRecords []*apiv0.ServerJSON

Callers 2

readSeedFileFunction · 0.85
fetchFromRegistryAPIFunction · 0.85

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…