Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

Fetch MCP servers and gateway installations in parallel. (#616)

Srajan Asthana3c1d544907d5
diff --git a/.changeset/sour-suns-greet.md b/.changeset/sour-suns-greet.md
new file mode 100644
index 000000000..a070e7517
--- /dev/null
+++ b/.changeset/sour-suns-greet.md
@@ -0,0 +1,5 @@
+---
+"@truefoundry/trueforge": patch
+---
+
+Fetch MCP servers and gateway installations in parallel.
diff --git a/packages/trueforge/src/truefoundry/TrueFoundryMcpServerStore.ts b/packages/trueforge/src/truefoundry/TrueFoundryMcpServerStore.ts
index b1404d089..6b4e1afd3 100644
--- a/packages/trueforge/src/truefoundry/TrueFoundryMcpServerStore.ts
+++ b/packages/trueforge/src/truefoundry/TrueFoundryMcpServerStore.ts
@@ -128,13 +128,15 @@ export class TrueFoundryMcpServerStore<TTransaction = never> implements IMcpServ
return paginateOffsetRows([], input.limit, offset);
}
- const rows = await this.#client.listMcpServers({
- accessToken: this.#accessToken,
- limit: input.limit + 1,
- offset,
- ...(input.names !== undefined ? { names: input.names } : {}),
- });
- const gatewayUrl = await this.#resolveGatewayUrl();
+ const [rows, gatewayUrl] = await Promise.all([
+ this.#client.listMcpServers({
+ accessToken: this.#accessToken,
+ limit: input.limit + 1,
+ offset,
+ ...(input.names !== undefined ? { names: input.names } : {}),
+ }),
+ this.#resolveGatewayUrl(),
+ ]);
const records = mapSfyMcpServers({ rows }).map(server =>
toRecord({ tenant_id: input.tenant_id, server, gatewayUrl }),
);
@@ -143,12 +145,14 @@ export class TrueFoundryMcpServerStore<TTransaction = never> implements IMcpServ
async getServer(input: GetMcpServerInput, transaction?: TTransaction): Promise<McpServerRecord | undefined> {
void transaction;
- const row = await this.#client.getMcpServerByName({ accessToken: this.#accessToken, name: input.name });
+ const [row, gatewayUrl] = await Promise.all([
+ this.#client.getMcpServerByName({ accessToken: this.#accessToken, name: input.name }),
+ this.#resolveGatewayUrl(),
+ ]);
if (row === undefined) {
return undefined;
}
const server = parseSfyMcpServerSummary(row);
- const gatewayUrl = await this.#resolveGatewayUrl();
return toRecord({ tenant_id: input.tenant_id, server, gatewayUrl });
}
diff --git a/packages/trueforge/tests/unit/truefoundry/TrueFoundryMcpServerStore.test.ts b/packages/trueforge/tests/unit/truefoundry/TrueFoundryMcpServerStore.test.ts
index 1cd74887a..e6555ceb9 100644
--- a/packages/trueforge/tests/unit/truefoundry/TrueFoundryMcpServerStore.test.ts
+++ b/packages/trueforge/tests/unit/truefoundry/TrueFoundryMcpServerStore.test.ts
@@ -140,13 +140,8 @@ describe('TrueFoundryMcpServerStore', () => {
});
it('throws McpServerNotFoundError when the server is missing', async () => {
- const client = createMockClient();
+ const { store, client } = createStore();
client.getMcpServerByName.mockResolvedValue(undefined);
- const store = new TrueFoundryMcpServerStore({
- client,
- accessToken: ACCESS_TOKEN,
- subject: { id: 'user-1', type: 'user', display_name: 'user-1' },
- });
await expect(store.authorize({ tenant_id: TENANT, name: 'missing', userRef: 'user-1' })).rejects.toBeInstanceOf(
McpServerNotFoundError,
);