{"id":18530,"library":"mcp-database-server","title":"Database MCP Server","description":"Node.js-based Model Context Protocol server (v0.1.6) that provides AI systems with runtime database connections. Supports PostgreSQL and MySQL via connection pooling, schema introspection, parameterized query execution, and dynamic connection management. Acts as a bridge between MCP-enabled AI assistants (e.g., Claude) and relational databases. Key differentiators: on-the-fly configuration switching, health monitoring, config file imports/exports, and CLI interface. Requires Node >=18.0.0. Early stage with weekly releases, no breaking changes so far.","status":"active","version":"0.1.6","language":"javascript","source_language":"en","source_url":"https://github.com/mradovic95/database-mcp-server","tags":["javascript","mcp","database","postgresql","mysql","sql","model-context-protocol"],"install":[{"cmd":"npm install mcp-database-server","lang":"bash","label":"npm"},{"cmd":"yarn add mcp-database-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add mcp-database-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"PostgreSQL client driver","package":"pg","optional":false},{"reason":"MySQL client driver","package":"mysql2","optional":false},{"reason":"MCP protocol implementation","package":"@modelcontextprotocol/sdk","optional":false}],"imports":[{"note":"Package is ESM-only. No CommonJS export. Use dynamic import if needed.","wrong":"const DatabaseServer = require('mcp-database-server')","symbol":"DatabaseServer","correct":"import { DatabaseServer } from 'mcp-database-server'"},{"note":"Default export available for convenience; preferred in TypeScript.","wrong":"const server = require('mcp-database-server')","symbol":"default","correct":"import DatabaseServer from 'mcp-database-server'"},{"note":"Config is a type-only export. Use TypeScript 'import type' to avoid runtime errors.","wrong":"import { Config } from 'mcp-database-server'","symbol":"Config","correct":"import type { Config } from 'mcp-database-server'"}],"quickstart":{"code":"import DatabaseServer from 'mcp-database-server';\n\nconst server = new DatabaseServer({\n  connections: {\n    mydb: {\n      type: 'postgresql',\n      host: process.env.DB_HOST ?? 'localhost',\n      port: parseInt(process.env.DB_PORT ?? '5432'),\n      database: process.env.DB_NAME ?? 'mydb',\n      user: process.env.DB_USER ?? 'admin',\n      password: process.env.DB_PASSWORD ?? '',\n      poolSize: 5,\n      timeout: 10000\n    }\n  }\n});\n\n// Start the MCP server (stdio transport)\nserver.start();\n\n// Add connection at runtime\nawait server.addConnection('analytics', {\n  type: 'mysql',\n  host: 'analytics.example.com',\n  port: 3306,\n  database: 'analytics_db',\n  user: 'reader',\n  password: process.env.ANALYTICS_PASSWORD ?? ''\n});\n\n// Execute a query\nconst result = await server.executeQuery('mydb', {\n  sql: 'SELECT id, name FROM users WHERE active = $1',\n  params: [true]\n});\nconsole.log(result.rows);","lang":"typescript","description":"Shows full setup: instantiate server with PostgreSQL config, start MCP server, dynamically add MySQL connection, then run parameterized query."},"warnings":[{"fix":"Use import syntax or dynamic import() in CommonJS files.","message":"Package is ESM-only. Using require() or CommonJS import will fail with ERR_REQUIRE_ESM.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Upgrade Node to >=18.0.0.","message":"Node.js version 18 or higher required. Older versions cause syntax errors.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Rename 'max' to 'poolSize' in connection configuration.","message":"The 'poolSize' parameter in connection config changed from 'max' (v0.1.0-v0.1.3) to 'poolSize' in v0.1.4.","severity":"breaking","affected_versions":">=0.1.4"},{"fix":"Replace server.getTables(conn) with server.getSchema(conn).","message":"The 'getTables' method is deprecated since v0.1.5; use 'getSchema' instead.","severity":"deprecated","affected_versions":">=0.1.5"},{"fix":"Use process.env.VAR for sensitive values; never commit .env files.","message":"Password via environment variable is strongly recommended; hardcoding passwords in config file may expose credentials in AI logs.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Call server.closeAllConnections() in process.on('exit', ...) or SIGTERM handler.","message":"Database connections are not closed automatically on server shutdown; resources may leak.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Pin exact version and review changelog before upgrades.","message":"Package is very early (v0.x); API may change with minor versions despite claiming 'no breaking changes' in changelog.","severity":"gotcha","affected_versions":"<1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use import syntax (ESM) or dynamic import('mcp-database-server') in CommonJS files.","cause":"Using require() on an ESM-only package in a CommonJS context.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/mcp-database-server/index.js from /path/to/your-file.js not supported."},{"fix":"Verify connection names are identical; check getConnections() for existing names.","cause":"Connection name in executeQuery() does not match any configured connection.","error":"TypeError: Cannot read properties of undefined (reading 'host')"},{"fix":"Check network connectivity and hostname spelling; use IP address if needed.","cause":"Database hostname is unreachable or DNS resolution fails.","error":"Error: getaddrinfo ENOTFOUND db.example.com"},{"fix":"Set poolSize to integer >= 1 (e.g., 5).","cause":"poolSize in connection config is not a number or is 0/negative.","error":"Error: poolSize must be a positive integer"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}