Skip to content

Commit 6d0ec50

Browse files
author
Vincent Molinié
committed
refactor: rename to mountAiMcpServer
1 parent 57b8351 commit 6d0ec50

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

packages/agent/src/agent.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ export default class Agent<S extends TSchema = TSchema> extends FrameworkMounter
200200
* This allows AI assistants to interact with your Forest Admin data.
201201
*
202202
* @example
203-
* agent.mountMcpServer();
203+
* agent.mountAiMcpServer();
204204
*/
205-
mountMcpServer(): this {
205+
mountAiMcpServer(): this {
206206
this.mcpEnabled = true;
207207

208208
return this;
@@ -225,7 +225,7 @@ export default class Agent<S extends TSchema = TSchema> extends FrameworkMounter
225225

226226
await Promise.all(routes.map(route => route.bootstrap()));
227227

228-
// Initialize MCP server if enabled via mountMcpServer()
228+
// Initialize MCP server if enabled via mountAiMcpServer()
229229
let mcpHttpCallback: HttpCallback | undefined;
230230

231231
if (this.mcpEnabled) {
@@ -253,7 +253,7 @@ export default class Agent<S extends TSchema = TSchema> extends FrameworkMounter
253253
*/
254254
private async initializeMcpServer(): Promise<HttpCallback> {
255255
try {
256-
// Dynamic import to defer loading until mountMcpServer() is actually used
256+
// Dynamic import to defer loading until mountAiMcpServer() is actually used
257257
// This avoids loading the transitive dependency @forestadmin-experimental/agent-nodejs-testing
258258
// at startup for users who don't use MCP
259259
const { ForestMCPServer } = await import('@forestadmin/mcp-server');
@@ -265,7 +265,6 @@ export default class Agent<S extends TSchema = TSchema> extends FrameworkMounter
265265
logger: this.options.logger,
266266
});
267267

268-
// baseUrl will be automatically fetched from Forest Admin API (environmentApiEndpoint)
269268
const httpCallback = await mcpServer.getHttpCallback();
270269

271270
this.options.logger('Info', 'MCP server initialized successfully');

packages/agent/test/agent.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ describe('Agent', () => {
336336
mockMcpGetHttpCallback.mockResolvedValue(jest.fn());
337337
});
338338

339-
test('should not initialize MCP server when mountMcpServer() is not called', async () => {
339+
test('should not initialize MCP server when mountAiMcpServer() is not called', async () => {
340340
const options = factories.forestAdminHttpDriverOptions.build();
341341
const agent = new Agent(options);
342342

@@ -349,21 +349,21 @@ describe('Agent', () => {
349349
expect(mockMcpGetHttpCallback).not.toHaveBeenCalled();
350350
});
351351

352-
test('mountMcpServer() should return this for chaining', () => {
352+
test('mountAiMcpServer() should return this for chaining', () => {
353353
const options = factories.forestAdminHttpDriverOptions.build();
354354
const agent = new Agent(options);
355355

356-
const result = agent.mountMcpServer();
356+
const result = agent.mountAiMcpServer();
357357

358358
expect(result).toBe(agent);
359359
});
360360

361-
test('should initialize MCP server when mountMcpServer() is called', async () => {
361+
test('should initialize MCP server when mountAiMcpServer() is called', async () => {
362362
const mockLogger = jest.fn();
363363
const options = factories.forestAdminHttpDriverOptions.build({ logger: mockLogger });
364364
const agent = new Agent(options);
365365

366-
agent.mountMcpServer();
366+
agent.mountAiMcpServer();
367367
await agent.start();
368368

369369
expect(mockMcpGetHttpCallback).toHaveBeenCalled();
@@ -377,7 +377,7 @@ describe('Agent', () => {
377377

378378
mockMcpGetHttpCallback.mockRejectedValue(new Error('MCP init failed'));
379379

380-
agent.mountMcpServer();
380+
agent.mountAiMcpServer();
381381

382382
await expect(agent.start()).rejects.toThrow('MCP init failed');
383383

packages/mcp-server/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ This MCP server provides HTTP REST API access to Forest Admin operations, enabli
1010

1111
### With Forest Admin Agent
1212

13-
The MCP server is included with the Forest Admin agent. Simply call `mountMcpServer()`:
13+
The MCP server is included with the Forest Admin agent. Simply call `mountAiMcpServer()`:
1414

1515
```typescript
1616
import { createAgent } from '@forestadmin/agent';
1717

1818
const agent = createAgent(options)
1919
.addDataSource(myDataSource)
20-
.mountMcpServer();
20+
.mountAiMcpServer();
2121

2222
agent.mountOnExpress(app);
2323
agent.start();

0 commit comments

Comments
 (0)