Skip to content

Commit c059ee7

Browse files
author
Vincent Molinié
committed
fix: review fixes
1 parent 8631315 commit c059ee7

6 files changed

Lines changed: 41 additions & 41 deletions

File tree

packages/mcp-server/src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env node
22

3-
import ForestAdminMCPServer from './server.js';
3+
import ForestMCPServer from './server.js';
44

55
// Start the server when run directly as CLI
6-
const server = new ForestAdminMCPServer();
6+
const server = new ForestMCPServer();
77

88
server.run().catch(error => {
99
console.error('[FATAL] Server crashed:', error);

packages/mcp-server/src/forest-oauth-provider.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Response } from 'express';
44
import createForestAdminClient from '@forestadmin/forestadmin-client';
55
import jsonwebtoken from 'jsonwebtoken';
66

7-
import ForestAdminOAuthProvider from './forest-oauth-provider';
7+
import ForestOAuthProvider from './forest-oauth-provider';
88
import MockServer from './test-utils/mock-server';
99

1010
jest.mock('jsonwebtoken');
@@ -20,14 +20,14 @@ const TEST_ENV_SECRET = 'test-env-secret';
2020
const TEST_AUTH_SECRET = 'test-auth-secret';
2121

2222
function createProvider(forestServerUrl = 'https://api.forestadmin.com') {
23-
return new ForestAdminOAuthProvider({
23+
return new ForestOAuthProvider({
2424
forestServerUrl,
2525
envSecret: TEST_ENV_SECRET,
2626
authSecret: TEST_AUTH_SECRET,
2727
});
2828
}
2929

30-
describe('ForestAdminOAuthProvider', () => {
30+
describe('ForestOAuthProvider', () => {
3131
let originalEnv: NodeJS.ProcessEnv;
3232
let mockServer: MockServer;
3333
const originalFetch = global.fetch;
@@ -61,7 +61,7 @@ describe('ForestAdminOAuthProvider', () => {
6161

6262
describe('initialize', () => {
6363
it('should not throw when envSecret is empty string', async () => {
64-
const customProvider = new ForestAdminOAuthProvider({
64+
const customProvider = new ForestOAuthProvider({
6565
forestServerUrl: 'https://api.forestadmin.com',
6666
envSecret: '',
6767
authSecret: TEST_AUTH_SECRET,
@@ -230,7 +230,7 @@ describe('ForestAdminOAuthProvider', () => {
230230
describe('authorize', () => {
231231
let mockResponse: Partial<Response>;
232232
let mockClient: OAuthClientInformationFull;
233-
let initializedProvider: ForestAdminOAuthProvider;
233+
let initializedProvider: ForestOAuthProvider;
234234

235235
beforeEach(async () => {
236236
mockResponse = {

packages/mcp-server/src/forest-oauth-provider.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
} from '@modelcontextprotocol/sdk/server/auth/errors.js';
2222
import jsonwebtoken from 'jsonwebtoken';
2323

24-
export interface ForestAdminOAuthProviderOptions {
24+
export interface ForestOAuthProviderOptions {
2525
forestServerUrl: string;
2626
envSecret: string;
2727
authSecret: string;
@@ -30,19 +30,19 @@ export interface ForestAdminOAuthProviderOptions {
3030
/**
3131
* OAuth Server Provider that integrates with Forest Admin authentication
3232
*/
33-
export default class ForestAdminOAuthProvider implements OAuthServerProvider {
33+
export default class ForestOAuthProvider implements OAuthServerProvider {
3434
private forestServerUrl: string;
3535
private envSecret: string;
3636
private authSecret: string;
3737
private environmentId?: number;
38-
private forestAdminClient: ForestAdminClient;
38+
private forestClient: ForestAdminClient;
3939
private environmentApiEndpoint: string;
4040

41-
constructor({ forestServerUrl, envSecret, authSecret }: ForestAdminOAuthProviderOptions) {
41+
constructor({ forestServerUrl, envSecret, authSecret }: ForestOAuthProviderOptions) {
4242
this.forestServerUrl = forestServerUrl;
4343
this.envSecret = envSecret;
4444
this.authSecret = authSecret;
45-
this.forestAdminClient = createForestAdminClient({
45+
this.forestClient = createForestAdminClient({
4646
forestServerUrl: this.forestServerUrl,
4747
envSecret: this.envSecret,
4848
});
@@ -156,7 +156,7 @@ export default class ForestAdminOAuthProvider implements OAuthServerProvider {
156156

157157
res.redirect(agentAuthUrl.toString());
158158
} catch (error) {
159-
console.error('[ForestAdminOAuthProvider] Authorization error:', error);
159+
console.error('[ForestOAuthProvider] Authorization error:', error);
160160
const errorMessage = error instanceof Error ? error.message : String(error);
161161

162162
res.redirect(
@@ -282,7 +282,7 @@ export default class ForestAdminOAuthProvider implements OAuthServerProvider {
282282
exp: number;
283283
iat: number;
284284
};
285-
const user = await this.forestAdminClient.authService.getUserInfo(
285+
const user = await this.forestClient.authService.getUserInfo(
286286
renderingId,
287287
forestServerAccessToken,
288288
);

packages/mcp-server/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Library exports only - no side effects
2-
export { default as ForestAdminMCPServer } from './server';
3-
export type { ForestAdminMCPServerOptions } from './server';
2+
export { default as ForestMCPServer } from './server';
3+
export type { ForestMCPServerOptions } from './server';

packages/mcp-server/src/server.test.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type * as http from 'http';
33
import jsonwebtoken from 'jsonwebtoken';
44
import request from 'supertest';
55

6-
import ForestAdminMCPServer from './server';
6+
import ForestMCPServer from './server';
77
import MockServer from './test-utils/mock-server';
88

99
function shutDownHttpServer(server: http.Server | undefined): Promise<void> {
@@ -17,11 +17,11 @@ function shutDownHttpServer(server: http.Server | undefined): Promise<void> {
1717
}
1818

1919
/**
20-
* Integration tests for ForestAdminMCPServer instance
20+
* Integration tests for ForestMCPServer instance
2121
* Tests the actual server class and its behavior
2222
*/
23-
describe('ForestAdminMCPServer Instance', () => {
24-
let server: ForestAdminMCPServer;
23+
describe('ForestMCPServer Instance', () => {
24+
let server: ForestMCPServer;
2525
let originalEnv: NodeJS.ProcessEnv;
2626
let modifiedEnv: NodeJS.ProcessEnv;
2727
let mockServer: MockServer;
@@ -81,37 +81,37 @@ describe('ForestAdminMCPServer Instance', () => {
8181

8282
describe('constructor', () => {
8383
it('should create server instance', () => {
84-
server = new ForestAdminMCPServer();
84+
server = new ForestMCPServer();
8585

8686
expect(server).toBeDefined();
87-
expect(server).toBeInstanceOf(ForestAdminMCPServer);
87+
expect(server).toBeInstanceOf(ForestMCPServer);
8888
});
8989

9090
it('should initialize with FOREST_SERVER_URL', () => {
9191
process.env.FOREST_SERVER_URL = 'https://custom.forestadmin.com';
92-
server = new ForestAdminMCPServer();
92+
server = new ForestMCPServer();
9393

9494
expect(server.forestServerUrl).toBe('https://custom.forestadmin.com');
9595
});
9696

9797
it('should fallback to FOREST_URL', () => {
9898
delete process.env.FOREST_SERVER_URL;
9999
process.env.FOREST_URL = 'https://fallback.forestadmin.com';
100-
server = new ForestAdminMCPServer();
100+
server = new ForestMCPServer();
101101

102102
expect(server.forestServerUrl).toBe('https://fallback.forestadmin.com');
103103
});
104104

105105
it('should use default URL when neither is provided', () => {
106106
delete process.env.FOREST_SERVER_URL;
107107
delete process.env.FOREST_URL;
108-
server = new ForestAdminMCPServer();
108+
server = new ForestMCPServer();
109109

110110
expect(server.forestServerUrl).toBe('https://api.forestadmin.com');
111111
});
112112

113113
it('should create MCP server instance', () => {
114-
server = new ForestAdminMCPServer();
114+
server = new ForestMCPServer();
115115

116116
expect(server.mcpServer).toBeDefined();
117117
});
@@ -120,7 +120,7 @@ describe('ForestAdminMCPServer Instance', () => {
120120
describe('environment validation', () => {
121121
it('should throw error when FOREST_ENV_SECRET is missing', async () => {
122122
delete process.env.FOREST_ENV_SECRET;
123-
server = new ForestAdminMCPServer();
123+
server = new ForestMCPServer();
124124

125125
await expect(server.run()).rejects.toThrow(
126126
'FOREST_ENV_SECRET is not set. Provide it via options.envSecret or FOREST_ENV_SECRET environment variable.',
@@ -129,7 +129,7 @@ describe('ForestAdminMCPServer Instance', () => {
129129

130130
it('should throw error when FOREST_AUTH_SECRET is missing', async () => {
131131
delete process.env.FOREST_AUTH_SECRET;
132-
server = new ForestAdminMCPServer();
132+
server = new ForestMCPServer();
133133

134134
await expect(server.run()).rejects.toThrow(
135135
'FOREST_AUTH_SECRET is not set. Provide it via options.authSecret or FOREST_AUTH_SECRET environment variable.',
@@ -146,7 +146,7 @@ describe('ForestAdminMCPServer Instance', () => {
146146
const testPort = 39310; // Use a different port for testing
147147
process.env.MCP_SERVER_PORT = testPort.toString();
148148

149-
server = new ForestAdminMCPServer();
149+
server = new ForestMCPServer();
150150

151151
// Start the server without awaiting (it runs indefinitely)
152152
server.run();
@@ -172,7 +172,7 @@ describe('ForestAdminMCPServer Instance', () => {
172172
const testPort = 39311;
173173
process.env.MCP_SERVER_PORT = testPort.toString();
174174

175-
server = new ForestAdminMCPServer();
175+
server = new ForestMCPServer();
176176
server.run();
177177

178178
await new Promise(resolve => {
@@ -190,7 +190,7 @@ describe('ForestAdminMCPServer Instance', () => {
190190
const testPort = 39312;
191191
process.env.MCP_SERVER_PORT = testPort.toString();
192192

193-
server = new ForestAdminMCPServer();
193+
server = new ForestMCPServer();
194194
server.run();
195195

196196
await new Promise(resolve => {
@@ -272,7 +272,7 @@ describe('ForestAdminMCPServer Instance', () => {
272272
process.env.FOREST_SERVER_URL = 'https://custom.forestadmin.com';
273273
process.env.MCP_SERVER_PORT = '39314';
274274

275-
server = new ForestAdminMCPServer();
275+
server = new ForestMCPServer();
276276
server.run();
277277

278278
await new Promise(resolve => {
@@ -416,7 +416,7 @@ describe('ForestAdminMCPServer Instance', () => {
416416
* Uses a separate server instance with mock server for Forest Admin API
417417
*/
418418
describe('/oauth/token endpoint', () => {
419-
let mcpServer: ForestAdminMCPServer;
419+
let mcpServer: ForestMCPServer;
420420
let mcpHttpServer: http.Server;
421421
let mcpMockServer: MockServer;
422422

@@ -487,7 +487,7 @@ describe('ForestAdminMCPServer Instance', () => {
487487
mcpMockServer.setupSuperagentMock();
488488

489489
// Create and start server
490-
mcpServer = new ForestAdminMCPServer();
490+
mcpServer = new ForestMCPServer();
491491
mcpServer.run();
492492

493493
await new Promise(resolve => {
@@ -887,7 +887,7 @@ describe('ForestAdminMCPServer Instance', () => {
887887
* Tests that the list tool is properly registered and accessible
888888
*/
889889
describe('List tool integration', () => {
890-
let listServer: ForestAdminMCPServer;
890+
let listServer: ForestMCPServer;
891891
let listHttpServer: http.Server;
892892
let listMockServer: MockServer;
893893

@@ -928,7 +928,7 @@ describe('ForestAdminMCPServer Instance', () => {
928928

929929
global.fetch = listMockServer.fetch;
930930

931-
listServer = new ForestAdminMCPServer();
931+
listServer = new ForestMCPServer();
932932
listServer.run();
933933

934934
await new Promise(resolve => {

packages/mcp-server/src/server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ import cors from 'cors';
1616
import express, { Express } from 'express';
1717
import * as http from 'http';
1818

19-
import ForestAdminOAuthProvider from './forest-oauth-provider';
19+
import ForestOAuthProvider from './forest-oauth-provider';
2020
import declareListTool from './tools/list';
2121
import { fetchForestSchema, getCollectionNames } from './utils/schema-fetcher';
2222

2323
/**
2424
* Options for configuring the Forest Admin MCP Server
2525
*/
26-
export interface ForestAdminMCPServerOptions {
26+
export interface ForestMCPServerOptions {
2727
/** Forest Admin server URL */
2828
forestServerUrl?: string;
2929
/** Forest Admin environment secret */
@@ -45,7 +45,7 @@ export interface ForestAdminMCPServerOptions {
4545
* - MCP_SERVER_PORT: Port for the HTTP server (default: 3931)
4646
*/
4747

48-
export default class ForestAdminMCPServer {
48+
export default class ForestMCPServer {
4949
public mcpServer: McpServer;
5050
public mcpTransport?: StreamableHTTPServerTransport;
5151
public httpServer?: http.Server;
@@ -55,7 +55,7 @@ export default class ForestAdminMCPServer {
5555
private envSecret?: string;
5656
private authSecret?: string;
5757

58-
constructor(options?: ForestAdminMCPServerOptions) {
58+
constructor(options?: ForestMCPServerOptions) {
5959
this.forestServerUrl =
6060
options?.forestServerUrl ||
6161
process.env.FOREST_SERVER_URL ||
@@ -131,7 +131,7 @@ export default class ForestAdminMCPServer {
131131
);
132132

133133
// Initialize OAuth provider
134-
const oauthProvider = new ForestAdminOAuthProvider({
134+
const oauthProvider = new ForestOAuthProvider({
135135
forestServerUrl: this.forestServerUrl,
136136
envSecret,
137137
authSecret,

0 commit comments

Comments
 (0)