{"id":42600,"library":"db-read","title":"db-read","description":"db-read is a read-only MCP server (Model Context Protocol) for coding agents to safely access PostgreSQL, MySQL, and MongoDB databases. Version 0.1.1 is the first stable release, offering unified configuration via .db-read.yml, CLI tools for validation and serving, and strict read-only guards: SQL queries are filtered for multi-statement and non-read commands, MongoDB aggregation blocks $out and $merge, and limits on rows/documents and timeouts are enforced. It supports environments (dev, staging, prod) and local or hosted connections. Compared to other MCP database tools, db-read uniquely supports three database kinds in one server with a focus on read-only safety for AI agents.","status":"active","version":"0.1.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","mcp","database","postgres","mysql","mongodb","read-only"],"install":[{"cmd":"npm install db-read","lang":"bash","label":"npm"},{"cmd":"yarn add db-read","lang":"bash","label":"yarn"},{"cmd":"pnpm add db-read","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core MCP SDK for server implementation","package":"@modelcontextprotocol/sdk","optional":false}],"imports":[{"note":"ESM-only package, requires Node >= 20, no CommonJS export","wrong":"const dbRead = require('db-read')","symbol":"default","correct":"import dbRead from 'db-read'"},{"note":"Named export available, but require() fails because package is ESM-only","wrong":"const validateConfig = require('db-read').validateConfig","symbol":"validateConfig","correct":"import { validateConfig } from 'db-read'"},{"note":"serve is a named export, not default; only default export is the main server class","wrong":"import serve from 'db-read'","symbol":"serve","correct":"import { serve } from 'db-read'"},{"note":"Config is a type-only export; use type import to avoid runtime errors in TypeScript","wrong":"import { Config } from 'db-read'","symbol":"type Config","correct":"import type { Config } from 'db-read'"}],"quickstart":{"code":"// Create .db-read.yml file\n// version: 1\n// defaultEnvironment: dev\n// environments:\n//   dev:\n//     connections:\n//       my_pg:\n//         kind: postgres\n//         uri: postgresql://readonly:${DATABASE_PASSWORD}@localhost:5432/mydb\n\n// Then run CLI:\n// npx db-read validate-config --config .db-read.yml\n// npx db-read serve --env dev --config .db-read.yml\n\n// Example using the SDK programmatically (ESM):\nimport { serve } from 'db-read';\nimport { readFile } from 'fs/promises';\n\nconst config = JSON.parse(await readFile('.db-read.yml', 'utf8'));\n// serve(config, { env: 'dev' });","lang":"typescript","description":"Shows basic setup with .db-read.yml config file, CLI commands for validation and serving, and a programmatic ESM import example."},"warnings":[{"fix":"Use import syntax or set \\\"type\\\": \\\"module\\\" in package.json.","message":"The package is ESM-only. Using require() will throw a MODULE_NOT_FOUND error.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Upgrade Node to v20 or later.","message":"Node.js >= 20 is required. Older versions will fail to start.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Copy .db-read.example.yml to .db-read.yml and fill in credentials.","message":"The db-read.yml file is git-ignored by default. Forgetting to create it from the example will cause a 'Config file not found' error.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Do not rely on ${VARIABLE} syntax; use direct values or a separate env management tool.","message":"Environment variables like ${DATABASE_PASSWORD} in the config URI are not expanded. You must hardcode the URI or use a tool like dotenv.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Remove $out and $merge stages from your aggregations.","message":"MongoDB aggregation pipeline rejects $out and $merge stages. Queries using these will return 'Forbidden aggregation stage' error.","severity":"breaking","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.1.1':29 'access':22 'agent':19,117 'aggreg':66 'ai':116 'block':67 'cli':40 'code':18 'command':64 'compar':90 'configur':37 'connect':89 'context':15 'databas':27,94,102,120 'db':2,5,97 'db-read':1,4,96 'db-read.yml':39 'dev':82 'enforc':78 'environ':81 'filter':55 'first':32 'focus':109 'guard':51 'host':88 'javascript':118 'kind':103 'limit':72 'local':86 'mcp':12,93,119 'merg':70 'model':14 'mongodb':26,65,123 'multi':58 'multi-stat':57 'mysql':24,122 'non':62 'non-read':61 'offer':35 'one':105 'postgr':121 'postgresql':23 'prod':84 'protocol':16 'queri':53 'read':3,6,10,49,63,98,112,125 'read-on':9,48,111,124 'releas':34 'rows/documents':74 'safe':21 'safeti':114 'serv':45 'server':13,106 'sql':52 'stabl':33 'stage':83 'statement':59 'strict':47 'support':80,100 'three':101 'timeout':76 'tool':41,95 'unifi':36 'uniqu':99 'valid':43 'version':28 'via':38","created_at":"2026-06-05T16:55:46.556095+00:00","updated_at":"2026-06-05T16:55:46.556095+00:00","problems":[{"fix":"Change require('db-read') to import 'db-read'.","cause":"Using require() on an ESM-only package.","error":"Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'db-read'"},{"fix":"Add 'defaultEnvironment: dev' (or another env) to the config.","cause":"Missing environment section in .db-read.yml.","error":"ValidationError: 'defaultEnvironment' is required"},{"fix":"Increase timeoutMs in .db-read.yml under defaults or connection config.","cause":"Database query exceeded the default timeout.","error":"MCP error: Timeout after 10000ms"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"db-read","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}