Skip to content

Commit 5f8cd7c

Browse files
alban bertoliniclaude
andcommitted
feat(forestadmin-client): add MCP server configuration service
Add service to fetch MCP server configurations from Forest Admin API. - New McpServerConfigService for fetching MCP server configs - Add getMcpServerConfigs endpoint to ForestHttpApi - Integrate service into ForestAdminClient 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f6214ae commit 5f8cd7c

16 files changed

Lines changed: 121 additions & 0 deletions

File tree

packages/agent/test/__factories__/forest-admin-client.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ const forestAdminClientFactory = ForestAdminClientFactory.define(() => ({
4343
modelCustomizationService: {
4444
getConfiguration: jest.fn(),
4545
},
46+
mcpServerConfigService: {
47+
getConfiguration: jest.fn(),
48+
},
4649
subscribeToServerEvents: jest.fn(),
4750
close: jest.fn(),
4851
onRefreshCustomizations: jest.fn(),

packages/forestadmin-client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"test": "jest"
3232
},
3333
"devDependencies": {
34+
"@forestadmin/ai-proxy": "0.1.0",
3435
"@forestadmin/datasource-toolkit": "1.50.0",
3536
"@types/json-api-serializer": "^2.6.3",
3637
"@types/jsonwebtoken": "^9.0.1",

packages/forestadmin-client/src/build-application-services.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import EventsSubscriptionService from './events-subscription';
33
import NativeRefreshEventsHandlerService from './events-subscription/native-refresh-events-handler-service';
44
import { RefreshEventsHandlerService } from './events-subscription/types';
55
import IpWhiteListService from './ip-whitelist';
6+
import McpServerConfigFromApiService, { McpServerConfigService } from './mcp-server-config';
67
import ModelCustomizationFromApiService from './model-customizations/model-customization-from-api';
78
import { ModelCustomizationService } from './model-customizations/types';
89
import ActionPermissionService from './permissions/action-permission';
@@ -32,6 +33,7 @@ export default function buildApplicationServices(
3233
chartHandler: ChartHandler;
3334
auth: ForestAdminAuthServiceInterface;
3435
modelCustomizationService: ModelCustomizationService;
36+
mcpServerConfigService: McpServerConfigService;
3537
eventsSubscription: EventsSubscriptionService;
3638
eventsHandler: RefreshEventsHandlerService;
3739
} {
@@ -87,5 +89,9 @@ export default function buildApplicationServices(
8789
forestAdminServerInterface,
8890
optionsWithDefaults,
8991
),
92+
mcpServerConfigService: new McpServerConfigFromApiService(
93+
forestAdminServerInterface,
94+
optionsWithDefaults,
95+
),
9096
};
9197
}

packages/forestadmin-client/src/forest-admin-client-with-cache.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from './events-subscription/types';
66
import IpWhiteListService from './ip-whitelist';
77
import { IpWhitelistConfiguration } from './ip-whitelist/types';
8+
import { McpServerConfigService } from './mcp-server-config';
89
import { ModelCustomizationService } from './model-customizations/types';
910
import RenderingPermissionService from './permissions/rendering-permission';
1011
import { RawTree } from './permissions/types';
@@ -30,6 +31,7 @@ export default class ForestAdminClientWithCache implements ForestAdminClient {
3031
protected readonly schemaService: SchemaService,
3132
public readonly authService: ForestAdminAuthServiceInterface,
3233
public readonly modelCustomizationService: ModelCustomizationService,
34+
public readonly mcpServerConfigService: McpServerConfigService,
3335
protected readonly eventsSubscription: BaseEventsSubscriptionService,
3436
protected readonly eventsHandler: RefreshEventsHandlerService,
3537
) {}

packages/forestadmin-client/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default function createForestAdminClient(
4343
schema,
4444
auth,
4545
modelCustomizationService,
46+
mcpServerConfigService,
4647
eventsSubscription,
4748
eventsHandler,
4849
} = buildApplicationServices(new ForestHttpApi(), options);
@@ -57,6 +58,7 @@ export default function createForestAdminClient(
5758
schema,
5859
auth,
5960
modelCustomizationService,
61+
mcpServerConfigService,
6062
eventsSubscription,
6163
eventsHandler,
6264
);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { McpConfiguration } from '@forestadmin/ai-proxy';
2+
3+
import { McpServerConfigService } from './types';
4+
import { ForestAdminClientOptionsWithDefaults, ForestAdminServerInterface } from '../types';
5+
6+
export default class McpServerConfigFromApiService implements McpServerConfigService {
7+
constructor(
8+
private readonly forestadminServerInterface: ForestAdminServerInterface,
9+
private readonly options: ForestAdminClientOptionsWithDefaults,
10+
) {}
11+
12+
async getConfiguration(): Promise<McpConfiguration> {
13+
return this.forestadminServerInterface.getMcpServerConfigs(this.options);
14+
}
15+
}
16+
17+
export { McpServerConfigService } from './types';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { McpConfiguration } from '@forestadmin/ai-proxy';
2+
3+
export interface McpServerConfigService {
4+
getConfiguration(): Promise<McpConfiguration>;
5+
}

packages/forestadmin-client/src/permissions/forest-http-api.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { McpConfiguration } from '@forestadmin/ai-proxy';
2+
13
import { EnvironmentPermissionsV4, RenderingPermissionV4, UserPermissionV4 } from './types';
24
import AuthService from '../auth';
35
import { ModelCustomization } from '../model-customizations/types';
@@ -34,6 +36,14 @@ export default class ForestHttpApi implements ForestAdminServerInterface {
3436
return ServerUtils.query<ModelCustomization[]>(options, 'get', '/liana/model-customizations');
3537
}
3638

39+
async getMcpServerConfigs(options: HttpOptions): Promise<McpConfiguration> {
40+
return ServerUtils.query<McpConfiguration>(
41+
options,
42+
'get',
43+
'/liana/mcp-server-configs-with-details',
44+
);
45+
}
46+
3747
makeAuthService(options: Required<ForestAdminClientOptions>): ForestAdminAuthServiceInterface {
3848
return new AuthService(options);
3949
}

packages/forestadmin-client/src/schema/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export type ForestSchema = {
66
liana: string;
77
liana_version: string;
88
liana_features: Record<string, string> | null;
9+
ai_llms?: Array<{ provider: string }> | null;
910
stack: {
1011
engine: string;
1112
engine_version: string;

packages/forestadmin-client/src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import type { ChartRequest } from './charts/chart-handler';
22
import type { Chart, QueryChart } from './charts/types';
3+
import type { McpConfiguration } from '@forestadmin/ai-proxy';
34

45
import { ParsedUrlQuery } from 'querystring';
56

67
import { Tokens, UserInfo } from './auth/types';
78
import { IpWhitelistConfiguration } from './ip-whitelist/types';
9+
import { McpServerConfigService } from './mcp-server-config/types';
810
import { ModelCustomization, ModelCustomizationService } from './model-customizations/types';
911
import { HttpOptions } from './permissions/forest-http-api';
1012
import {
@@ -49,6 +51,7 @@ export interface ForestAdminClient {
4951
readonly contextVariablesInstantiator: ContextVariablesInstantiatorInterface;
5052
readonly chartHandler: ChartHandlerInterface;
5153
readonly modelCustomizationService: ModelCustomizationService;
54+
readonly mcpServerConfigService: McpServerConfigService;
5255
readonly authService: ForestAdminAuthServiceInterface;
5356

5457
verifySignedActionParameters<TSignedParameters>(signedParameters: string): TSignedParameters;
@@ -161,5 +164,6 @@ export interface ForestAdminServerInterface {
161164
getUsers: (...args) => Promise<UserPermissionV4[]>;
162165
getRenderingPermissions: (renderingId: number, ...args) => Promise<RenderingPermissionV4>;
163166
getModelCustomizations: (options: HttpOptions) => Promise<ModelCustomization[]>;
167+
getMcpServerConfigs: (options: HttpOptions) => Promise<McpConfiguration>;
164168
makeAuthService(options: ForestAdminClientOptionsWithDefaults): ForestAdminAuthServiceInterface;
165169
}

0 commit comments

Comments
 (0)