@@ -4,7 +4,7 @@ import jsonwebtoken from 'jsonwebtoken';
44import request from 'supertest' ;
55
66import MockServer from './test-utils/mock-server' ;
7- import { clearSchemaCache } from './utils/schema-fetcher.js' ;
7+ import { clearSchemaCache } from '../src /utils/schema-fetcher.js' ;
88import ForestMCPServer from '../src/server' ;
99
1010function shutDownHttpServer ( server : http . Server | undefined ) : Promise < void > {
@@ -2154,11 +2154,11 @@ describe('ForestMCPServer Instance', () => {
21542154 } ) ;
21552155
21562156 /**
2157- * Integration tests for the getHasMany tool
2158- * Tests that the getHasMany tool is properly registered and accessible
2157+ * Integration tests for the listRelated tool
2158+ * Tests that the listRelated tool is properly registered and accessible
21592159 */
2160- describe ( 'GetHasMany tool integration' , ( ) => {
2161- let hasManyServer : ForestAdminMCPServer ;
2160+ describe ( 'listRelated tool integration' , ( ) => {
2161+ let hasManyServer : ForestMCPServer ;
21622162 let hasManyHttpServer : http . Server ;
21632163 let hasManyMockServer : MockServer ;
21642164
@@ -2213,7 +2213,7 @@ describe('ForestMCPServer Instance', () => {
22132213
22142214 global . fetch = hasManyMockServer . fetch ;
22152215
2216- hasManyServer = new ForestAdminMCPServer ( ) ;
2216+ hasManyServer = new ForestMCPServer ( ) ;
22172217 hasManyServer . run ( ) ;
22182218
22192219 await new Promise ( resolve => {
@@ -2233,7 +2233,7 @@ describe('ForestMCPServer Instance', () => {
22332233 } ) ;
22342234 } ) ;
22352235
2236- it ( 'should have getHasMany tool registered in the MCP server' , async ( ) => {
2236+ it ( 'should have listRelated tool registered in the MCP server' , async ( ) => {
22372237 const authSecret = process . env . FOREST_AUTH_SECRET || 'test-auth-secret' ;
22382238 const validToken = jsonwebtoken . sign (
22392239 {
@@ -2290,24 +2290,24 @@ describe('ForestMCPServer Instance', () => {
22902290 expect ( responseData . result . tools ) . toBeDefined ( ) ;
22912291 expect ( Array . isArray ( responseData . result . tools ) ) . toBe ( true ) ;
22922292
2293- // Verify the 'getHasMany ' tool is registered
2294- const getHasManyTool = responseData . result . tools . find (
2295- ( tool : { name : string } ) => tool . name === 'getHasMany ' ,
2293+ // Verify the 'listRelated ' tool is registered
2294+ const listRelatedTool = responseData . result . tools . find (
2295+ ( tool : { name : string } ) => tool . name === 'listRelated ' ,
22962296 ) ;
2297- expect ( getHasManyTool ) . toBeDefined ( ) ;
2298- expect ( getHasManyTool . description ) . toBe (
2299- 'Retrieve a list of records from the specified hasMany relationship .' ,
2297+ expect ( listRelatedTool ) . toBeDefined ( ) ;
2298+ expect ( listRelatedTool . description ) . toBe (
2299+ 'Retrieve a list of records from the specified relation (hasMany) .' ,
23002300 ) ;
2301- expect ( getHasManyTool . inputSchema ) . toBeDefined ( ) ;
2302- expect ( getHasManyTool . inputSchema . properties ) . toHaveProperty ( 'collectionName' ) ;
2303- expect ( getHasManyTool . inputSchema . properties ) . toHaveProperty ( 'relationName' ) ;
2304- expect ( getHasManyTool . inputSchema . properties ) . toHaveProperty ( 'parentRecordId' ) ;
2305- expect ( getHasManyTool . inputSchema . properties ) . toHaveProperty ( 'search' ) ;
2306- expect ( getHasManyTool . inputSchema . properties ) . toHaveProperty ( 'filters' ) ;
2307- expect ( getHasManyTool . inputSchema . properties ) . toHaveProperty ( 'sort' ) ;
2301+ expect ( listRelatedTool . inputSchema ) . toBeDefined ( ) ;
2302+ expect ( listRelatedTool . inputSchema . properties ) . toHaveProperty ( 'collectionName' ) ;
2303+ expect ( listRelatedTool . inputSchema . properties ) . toHaveProperty ( 'relationName' ) ;
2304+ expect ( listRelatedTool . inputSchema . properties ) . toHaveProperty ( 'parentRecordId' ) ;
2305+ expect ( listRelatedTool . inputSchema . properties ) . toHaveProperty ( 'search' ) ;
2306+ expect ( listRelatedTool . inputSchema . properties ) . toHaveProperty ( 'filters' ) ;
2307+ expect ( listRelatedTool . inputSchema . properties ) . toHaveProperty ( 'sort' ) ;
23082308
23092309 // Verify collectionName has enum with the collection names from the mocked schema
2310- const collectionNameSchema = getHasManyTool . inputSchema . properties . collectionName as {
2310+ const collectionNameSchema = listRelatedTool . inputSchema . properties . collectionName as {
23112311 type : string ;
23122312 enum ?: string [ ] ;
23132313 } ;
@@ -2316,7 +2316,7 @@ describe('ForestMCPServer Instance', () => {
23162316 expect ( collectionNameSchema . enum ) . toEqual ( [ 'users' , 'orders' ] ) ;
23172317 } ) ;
23182318
2319- it ( 'should create activity log with forestServerToken and relation label when calling getHasMany tool' , async ( ) => {
2319+ it ( 'should create activity log with forestServerToken and relation label when calling listRelated tool' , async ( ) => {
23202320 const authSecret = process . env . FOREST_AUTH_SECRET || 'test-auth-secret' ;
23212321 const forestServerToken = 'original-forest-server-token-for-has-many' ;
23222322
@@ -2347,7 +2347,7 @@ describe('ForestMCPServer Instance', () => {
23472347 jsonrpc : '2.0' ,
23482348 method : 'tools/call' ,
23492349 params : {
2350- name : 'getHasMany ' ,
2350+ name : 'listRelated ' ,
23512351 arguments : {
23522352 collectionName : 'users' ,
23532353 relationName : 'orders' ,
@@ -2383,7 +2383,7 @@ describe('ForestMCPServer Instance', () => {
23832383 } ) ;
23842384 } ) ;
23852385
2386- it ( 'should accept string parentRecordId when calling getHasMany tool' , async ( ) => {
2386+ it ( 'should accept string parentRecordId when calling listRelated tool' , async ( ) => {
23872387 const authSecret = process . env . FOREST_AUTH_SECRET || 'test-auth-secret' ;
23882388 const forestServerToken = 'forest-token-for-string-id-test' ;
23892389
@@ -2412,7 +2412,7 @@ describe('ForestMCPServer Instance', () => {
24122412 jsonrpc : '2.0' ,
24132413 method : 'tools/call' ,
24142414 params : {
2415- name : 'getHasMany ' ,
2415+ name : 'listRelated ' ,
24162416 arguments : {
24172417 collectionName : 'users' ,
24182418 relationName : 'orders' ,
0 commit comments