Skip to content

Commit 9fc7341

Browse files
peppescgclaude
andauthored
chore: migrate to updated registry server API (#474)
Regenerate client from latest swagger and update all call sites to match the breaking API path changes in toolhive-registry-server: - GET /extension/v0/registries → GET /v1/registries - GET /registry/v0.1/servers → GET /registry/{registryName}/v0.1/servers - GET /registry/v0.1/servers/{serverName}/versions/{version} → GET /registry/{registryName}/v0.1/servers/{serverName}/versions/{version} Update MSW fixtures and test imports accordingly. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ff94a71 commit 9fc7341

File tree

16 files changed

+1961
-2953
lines changed

16 files changed

+1961
-2953
lines changed

src/app/catalog/[repoName]/[serverName]/[version]/actions.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,21 @@ import { getAuthenticatedClient } from "@/lib/api-client";
55
export async function getServerDetails(serverName: string, version: string) {
66
const api = await getAuthenticatedClient();
77

8+
const registriesResult = await api.getV1Registries({ client: api.client });
9+
const registryName = registriesResult.data?.registries?.[0]?.name;
10+
11+
if (!registryName) {
12+
return {
13+
error: new Error("No registry available"),
14+
data: null,
15+
response: null,
16+
};
17+
}
18+
819
const { error, data, response } =
9-
await api.getRegistryV01ServersByServerNameVersionsByVersion({
20+
await api.getRegistryByRegistryNameV01ServersByServerNameVersionsByVersion({
1021
path: {
22+
registryName,
1123
serverName,
1224
version,
1325
},

src/app/catalog/actions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mockedGetRegistryV01Servers } from "@mocks/fixtures/registry_v0_1_servers/get";
1+
import { mockedGetRegistryV01Servers } from "@mocks/fixtures/registry_registryName_v0_1_servers/get";
22
import { HttpResponse } from "msw";
33
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
44
import { getServers } from "./actions";

src/app/catalog/actions.ts

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ export async function getRegistries(): Promise<
1111
GithubComStacklokToolhiveRegistryServerInternalServiceRegistryInfo[]
1212
> {
1313
const api = await getAuthenticatedClient();
14-
const registries = await api.getExtensionV0Registries({
14+
const registries = await api.getV1Registries({
1515
client: api.client,
1616
});
17-
1817
if (registries.error) {
1918
console.error("[catalog] Failed to fetch registries:", registries.error);
2019
throw registries.error;
@@ -23,6 +22,7 @@ export async function getRegistries(): Promise<
2322
if (!registries.data) {
2423
return [];
2524
}
25+
// console.log("registries", JSON.stringify(registries.data, null, 2));
2626

2727
return registries.data.registries ?? [];
2828
}
@@ -38,38 +38,21 @@ interface ServerListParams {
3838
search?: string;
3939
}
4040

41+
/**
42+
* Fetches MCP servers using the first available registry as default.
43+
* Used when no specific registry is selected by the user.
44+
*/
4145
export async function getServers(
4246
params?: ServerListParams,
4347
): Promise<ServerListResult> {
44-
const api = await getAuthenticatedClient();
45-
const servers = await api.getRegistryV01Servers({
46-
client: api.client,
47-
query: {
48-
version: "latest",
49-
cursor: params?.cursor || undefined,
50-
limit: params?.limit,
51-
search: params?.search || undefined,
52-
},
53-
});
48+
const registries = await getRegistries();
49+
const defaultRegistry = registries[0]?.name;
5450

55-
if (servers.error) {
56-
console.error("[catalog] Failed to fetch servers:", servers.error);
57-
throw servers.error;
58-
}
59-
60-
if (!servers.data) {
51+
if (!defaultRegistry) {
6152
return { servers: [] };
6253
}
6354

64-
const data = servers.data;
65-
const items = Array.isArray(data?.servers) ? data.servers : [];
66-
67-
return {
68-
servers: items
69-
.map((item) => item?.server)
70-
.filter((server): server is V0ServerJson => server != null),
71-
nextCursor: data.metadata?.nextCursor,
72-
};
55+
return getServersByRegistryName(defaultRegistry, params);
7356
}
7457

7558
/**

src/app/catalog/page.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getRegistries, getServers, getServersByRegistryName } from "./actions";
1+
import { getRegistries, getServersByRegistryName } from "./actions";
22
import { ServersWrapper } from "./components/servers-wrapper";
33
import { CATALOG_PAGE_SIZE } from "./constants";
44

@@ -20,12 +20,12 @@ export default async function CatalogPage({ searchParams }: CatalogPageProps) {
2020
search: search || undefined,
2121
};
2222

23-
const [registries, { servers, nextCursor }] = await Promise.all([
24-
getRegistries(),
25-
registryName
26-
? getServersByRegistryName(registryName, paginationParams)
27-
: getServers(paginationParams),
28-
]);
23+
const registries = await getRegistries();
24+
const selectedRegistry = registryName ?? registries[0]?.name;
25+
26+
const { servers, nextCursor } = selectedRegistry
27+
? await getServersByRegistryName(selectedRegistry, paginationParams)
28+
: { servers: [], nextCursor: undefined };
2929

3030
return (
3131
<ServersWrapper

src/generated/index.ts

Lines changed: 38 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

33
export {
4-
deleteExtensionV0RegistriesByRegistryName,
5-
deleteRegistryByRegistryNameV01ServersByServerNameVersionsByVersion,
6-
deleteRegistryByRegistryNameV01xDevToolhiveSkillsByNamespaceByNameVersionsByVersion,
74
deleteV1EntriesByTypeByNameVersionsByVersion,
85
deleteV1RegistriesByName,
96
deleteV1SourcesByName,
10-
getExtensionV0Registries,
11-
getExtensionV0RegistriesByRegistryName,
127
getHealth,
138
getOpenapiJson,
149
getReadiness,
@@ -19,9 +14,6 @@ export {
1914
getRegistryByRegistryNameV01xDevToolhiveSkillsByNamespaceByName,
2015
getRegistryByRegistryNameV01xDevToolhiveSkillsByNamespaceByNameVersions,
2116
getRegistryByRegistryNameV01xDevToolhiveSkillsByNamespaceByNameVersionsByVersion,
22-
getRegistryV01Servers,
23-
getRegistryV01ServersByServerNameVersions,
24-
getRegistryV01ServersByServerNameVersionsByVersion,
2517
getV1Registries,
2618
getV1RegistriesByName,
2719
getV1RegistriesByNameEntries,
@@ -30,51 +22,28 @@ export {
3022
getV1SourcesByNameEntries,
3123
getVersion,
3224
type Options,
33-
postByRegistryNameV01Publish,
34-
postRegistryByRegistryNameV01xDevToolhiveSkills,
35-
postRegistryV01Publish,
3625
postV1Entries,
37-
putExtensionV0RegistriesByRegistryName,
3826
putV1EntriesByTypeByNameClaims,
3927
putV1RegistriesByName,
4028
putV1SourcesByName,
4129
} from "./sdk.gen";
4230
export type {
4331
ClientOptions,
44-
DeleteExtensionV0RegistriesByRegistryNameData,
45-
DeleteExtensionV0RegistriesByRegistryNameError,
46-
DeleteExtensionV0RegistriesByRegistryNameErrors,
47-
DeleteExtensionV0RegistriesByRegistryNameResponse,
48-
DeleteExtensionV0RegistriesByRegistryNameResponses,
49-
DeleteRegistryByRegistryNameV01ServersByServerNameVersionsByVersionData,
50-
DeleteRegistryByRegistryNameV01ServersByServerNameVersionsByVersionError,
51-
DeleteRegistryByRegistryNameV01ServersByServerNameVersionsByVersionErrors,
52-
DeleteRegistryByRegistryNameV01ServersByServerNameVersionsByVersionResponse,
53-
DeleteRegistryByRegistryNameV01ServersByServerNameVersionsByVersionResponses,
54-
DeleteRegistryByRegistryNameV01xDevToolhiveSkillsByNamespaceByNameVersionsByVersionData,
55-
DeleteRegistryByRegistryNameV01xDevToolhiveSkillsByNamespaceByNameVersionsByVersionError,
56-
DeleteRegistryByRegistryNameV01xDevToolhiveSkillsByNamespaceByNameVersionsByVersionErrors,
57-
DeleteRegistryByRegistryNameV01xDevToolhiveSkillsByNamespaceByNameVersionsByVersionResponse,
58-
DeleteRegistryByRegistryNameV01xDevToolhiveSkillsByNamespaceByNameVersionsByVersionResponses,
5932
DeleteV1EntriesByTypeByNameVersionsByVersionData,
6033
DeleteV1EntriesByTypeByNameVersionsByVersionError,
6134
DeleteV1EntriesByTypeByNameVersionsByVersionErrors,
35+
DeleteV1EntriesByTypeByNameVersionsByVersionResponse,
36+
DeleteV1EntriesByTypeByNameVersionsByVersionResponses,
6237
DeleteV1RegistriesByNameData,
6338
DeleteV1RegistriesByNameError,
6439
DeleteV1RegistriesByNameErrors,
40+
DeleteV1RegistriesByNameResponse,
41+
DeleteV1RegistriesByNameResponses,
6542
DeleteV1SourcesByNameData,
6643
DeleteV1SourcesByNameError,
6744
DeleteV1SourcesByNameErrors,
68-
GetExtensionV0RegistriesByRegistryNameData,
69-
GetExtensionV0RegistriesByRegistryNameError,
70-
GetExtensionV0RegistriesByRegistryNameErrors,
71-
GetExtensionV0RegistriesByRegistryNameResponse,
72-
GetExtensionV0RegistriesByRegistryNameResponses,
73-
GetExtensionV0RegistriesData,
74-
GetExtensionV0RegistriesError,
75-
GetExtensionV0RegistriesErrors,
76-
GetExtensionV0RegistriesResponse,
77-
GetExtensionV0RegistriesResponses,
45+
DeleteV1SourcesByNameResponse,
46+
DeleteV1SourcesByNameResponses,
7847
GetHealthData,
7948
GetHealthResponse,
8049
GetHealthResponses,
@@ -123,60 +92,61 @@ export type {
12392
GetRegistryByRegistryNameV01xDevToolhiveSkillsErrors,
12493
GetRegistryByRegistryNameV01xDevToolhiveSkillsResponse,
12594
GetRegistryByRegistryNameV01xDevToolhiveSkillsResponses,
126-
GetRegistryV01ServersByServerNameVersionsByVersionData,
127-
GetRegistryV01ServersByServerNameVersionsByVersionError,
128-
GetRegistryV01ServersByServerNameVersionsByVersionErrors,
129-
GetRegistryV01ServersByServerNameVersionsByVersionResponse,
130-
GetRegistryV01ServersByServerNameVersionsByVersionResponses,
131-
GetRegistryV01ServersByServerNameVersionsData,
132-
GetRegistryV01ServersByServerNameVersionsError,
133-
GetRegistryV01ServersByServerNameVersionsErrors,
134-
GetRegistryV01ServersByServerNameVersionsResponse,
135-
GetRegistryV01ServersByServerNameVersionsResponses,
136-
GetRegistryV01ServersData,
137-
GetRegistryV01ServersError,
138-
GetRegistryV01ServersErrors,
139-
GetRegistryV01ServersResponse,
140-
GetRegistryV01ServersResponses,
14195
GetV1RegistriesByNameData,
14296
GetV1RegistriesByNameEntriesData,
14397
GetV1RegistriesByNameEntriesError,
14498
GetV1RegistriesByNameEntriesErrors,
99+
GetV1RegistriesByNameEntriesResponse,
100+
GetV1RegistriesByNameEntriesResponses,
145101
GetV1RegistriesByNameError,
146102
GetV1RegistriesByNameErrors,
103+
GetV1RegistriesByNameResponse,
104+
GetV1RegistriesByNameResponses,
147105
GetV1RegistriesData,
148106
GetV1RegistriesError,
149107
GetV1RegistriesErrors,
108+
GetV1RegistriesResponse,
109+
GetV1RegistriesResponses,
150110
GetV1SourcesByNameData,
151111
GetV1SourcesByNameEntriesData,
152112
GetV1SourcesByNameEntriesError,
153113
GetV1SourcesByNameEntriesErrors,
114+
GetV1SourcesByNameEntriesResponse,
115+
GetV1SourcesByNameEntriesResponses,
154116
GetV1SourcesByNameError,
155117
GetV1SourcesByNameErrors,
118+
GetV1SourcesByNameResponse,
119+
GetV1SourcesByNameResponses,
156120
GetV1SourcesData,
157121
GetV1SourcesError,
158122
GetV1SourcesErrors,
123+
GetV1SourcesResponse,
124+
GetV1SourcesResponses,
159125
GetVersionData,
160126
GetVersionResponse,
161127
GetVersionResponses,
162-
GithubComStacklokToolhiveRegistryServerInternalConfigApiConfig,
163-
GithubComStacklokToolhiveRegistryServerInternalConfigFileConfig,
164128
GithubComStacklokToolhiveRegistryServerInternalConfigFilterConfig,
165-
GithubComStacklokToolhiveRegistryServerInternalConfigGitAuthConfig,
166-
GithubComStacklokToolhiveRegistryServerInternalConfigGitConfig,
167-
GithubComStacklokToolhiveRegistryServerInternalConfigKubernetesConfig,
168-
GithubComStacklokToolhiveRegistryServerInternalConfigManagedConfig,
169129
GithubComStacklokToolhiveRegistryServerInternalConfigNameFilterConfig,
170130
GithubComStacklokToolhiveRegistryServerInternalConfigSourceType,
171-
GithubComStacklokToolhiveRegistryServerInternalConfigSyncPolicyConfig,
172131
GithubComStacklokToolhiveRegistryServerInternalConfigTagFilterConfig,
173132
GithubComStacklokToolhiveRegistryServerInternalServiceCreationType,
174-
GithubComStacklokToolhiveRegistryServerInternalServiceRegistryCreateRequest,
133+
GithubComStacklokToolhiveRegistryServerInternalServiceEntryVersionInfo,
134+
GithubComStacklokToolhiveRegistryServerInternalServiceRegistryEntriesResponse,
135+
GithubComStacklokToolhiveRegistryServerInternalServiceRegistryEntryInfo,
175136
GithubComStacklokToolhiveRegistryServerInternalServiceRegistryInfo,
176-
GithubComStacklokToolhiveRegistryServerInternalServiceRegistryListResponse,
177-
GithubComStacklokToolhiveRegistryServerInternalServiceRegistrySyncStatus,
137+
GithubComStacklokToolhiveRegistryServerInternalServiceSkill,
138+
GithubComStacklokToolhiveRegistryServerInternalServiceSkillIcon,
139+
GithubComStacklokToolhiveRegistryServerInternalServiceSkillPackage,
140+
GithubComStacklokToolhiveRegistryServerInternalServiceSkillRepository,
141+
GithubComStacklokToolhiveRegistryServerInternalServiceSourceEntriesResponse,
142+
GithubComStacklokToolhiveRegistryServerInternalServiceSourceEntryInfo,
143+
GithubComStacklokToolhiveRegistryServerInternalServiceSourceInfo,
144+
GithubComStacklokToolhiveRegistryServerInternalServiceSourceListResponse,
145+
GithubComStacklokToolhiveRegistryServerInternalServiceSourceSyncStatus,
178146
InternalApiHealthResponse,
179147
InternalApiReadinessResponse,
148+
InternalApiV1PublishEntryRequest,
149+
InternalApiV1RegistryListResponse,
180150
InternalApiVersionResponse,
181151
InternalApiXSkillsSkillListMetadata,
182152
InternalApiXSkillsSkillListResponse,
@@ -190,36 +160,24 @@ export type {
190160
ModelRepository,
191161
ModelStatus,
192162
ModelTransport,
193-
PostByRegistryNameV01PublishData,
194-
PostByRegistryNameV01PublishError,
195-
PostByRegistryNameV01PublishErrors,
196-
PostByRegistryNameV01PublishResponse,
197-
PostByRegistryNameV01PublishResponses,
198-
PostRegistryByRegistryNameV01xDevToolhiveSkillsData,
199-
PostRegistryByRegistryNameV01xDevToolhiveSkillsError,
200-
PostRegistryByRegistryNameV01xDevToolhiveSkillsErrors,
201-
PostRegistryByRegistryNameV01xDevToolhiveSkillsResponse,
202-
PostRegistryByRegistryNameV01xDevToolhiveSkillsResponses,
203-
PostRegistryV01PublishData,
204-
PostRegistryV01PublishError,
205-
PostRegistryV01PublishErrors,
206163
PostV1EntriesData,
207164
PostV1EntriesError,
208165
PostV1EntriesErrors,
209-
PutExtensionV0RegistriesByRegistryNameData,
210-
PutExtensionV0RegistriesByRegistryNameError,
211-
PutExtensionV0RegistriesByRegistryNameErrors,
212-
PutExtensionV0RegistriesByRegistryNameResponse,
213-
PutExtensionV0RegistriesByRegistryNameResponses,
166+
PostV1EntriesResponse,
167+
PostV1EntriesResponses,
214168
PutV1EntriesByTypeByNameClaimsData,
215169
PutV1EntriesByTypeByNameClaimsError,
216170
PutV1EntriesByTypeByNameClaimsErrors,
217171
PutV1RegistriesByNameData,
218172
PutV1RegistriesByNameError,
219173
PutV1RegistriesByNameErrors,
174+
PutV1RegistriesByNameResponse,
175+
PutV1RegistriesByNameResponses,
220176
PutV1SourcesByNameData,
221177
PutV1SourcesByNameError,
222178
PutV1SourcesByNameErrors,
179+
PutV1SourcesByNameResponse,
180+
PutV1SourcesByNameResponses,
223181
RegistrySkill,
224182
RegistrySkillIcon,
225183
RegistrySkillPackage,

0 commit comments

Comments
 (0)