startMongoServer
Launch a local MongoDB-compatible server that generates realistic data from statistical models, enabling database operations without actual storage requirements.
Instructions
Start a local MongoDB-compatible server that generates data from statistical models
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | Default database name | test |
| port | No | Port to listen on (0 for auto) |
Implementation Reference
- src/mcp/mcp-server.js:928-949 (handler)The core handler function for the 'startMongoServer' tool. Creates and starts a MongoDBServer instance using DataFlood storage, registers it in the servers map, and returns connection details.async startMongoServer(args) { const { port = 0, database = 'test' } = args; const server = new MongoDBServer({ port, storage: this.storage, database, logger: this.logger // Pass the MCP logger }); await server.start(); const actualPort = server.server.address().port; this.servers.set(actualPort, server); return { success: true, port: actualPort, message: `MongoDB server started on port ${actualPort}`, connectionString: `mongodb://localhost:${actualPort}/${database}` }; }
- src/mcp/mcp-server.js:69-79 (schema)Input schema definition for the 'startMongoServer' tool, specifying optional port (integer, default 0) and database (string, default 'test').{ name: 'startMongoServer', description: 'Start a MongoDB-compatible server with DataFlood backing', inputSchema: { type: 'object', properties: { port: { type: 'integer', description: 'Port to listen on (0 for auto)', default: 0 }, database: { type: 'string', description: 'Default database name', default: 'test' } } } },
- src/mcp/mcp-server.js:744-745 (registration)Tool call registration/dispatch in the handleToolCall method's switch statement, invoking the startMongoServer handler.case 'startMongoServer': result = await this.startMongoServer(args);
- src/mcp/index.js:323-343 (handler)Alternative inline handler for 'startMongoServer' in the SDK-based MCP server entry point (index.js), similar logic to start MongoDBServer.case 'startMongoServer': const port = args.port !== undefined ? args.port : (config.server.defaultPort || 0); const database = args.database || config.storage.defaultDatabase || 'test'; const mongoServer = new MongoDBServer({ port: port, host: config.server.host || 'localhost', storage: storage, logger: logger }); await mongoServer.start(); const actualPort = mongoServer.port; // Get the actual port from the server servers.set(actualPort, { server: mongoServer, database, status: 'running', connections: 0 }); return { content: [{ type: 'text', text: `MongoDB server started successfully:\n- Port: ${actualPort}\n- Database: ${database}\n- Connection: mongodb://localhost:${actualPort}/${database}\n\nServer supports DataFlood generation with $seed and $entropy parameters.` }] };
- src/mcp/index.js:139-147 (schema)Input schema for 'startMongoServer' tool in the SDK-based server, matching the enhanced version.name: 'startMongoServer', description: 'Start a local MongoDB-compatible server that generates data from statistical models', inputSchema: { type: 'object', properties: { port: { type: 'integer', description: 'Port to listen on (0 for auto)', default: 0 }, database: { type: 'string', description: 'Default database name', default: 'test' } } }