@legacy-lens/db-introspect
v0.1.1
Published
Read-only SQL database introspection for PostgreSQL, MySQL, SQLite, and SQL Server
Readme
@legacy-lens/db-introspect
Read-only SQL database introspection for Node.js: list schemas and tables, describe columns and primary keys, list foreign keys, and sample rows. Supports PostgreSQL, MySQL / MariaDB, SQLite, and Microsoft SQL Server.
This package powers @legacy-lens/mcp-server (MCP / Cursor). Install the MCP package if you want AI-assisted discovery; install this package if you are building your own tools on top of the same introspection API.
Requirements
- Node.js 20+
- SQLite uses
better-sqlite3(native addon); you may need a node-gyp toolchain if install fails.
Install
npm install @legacy-lens/db-introspectUsage
Resolve configuration (URL or env-shaped config), then create an introspector:
import { createIntrospector, parseDatabaseUrl } from "@legacy-lens/db-introspect";
const config = parseDatabaseUrl(process.env.DATABASE_URL);
const introspector = await createIntrospector(config);
await introspector.ping();
const schemas = await introspector.listSchemas();
// listTables, describeTable, listForeignKeys, sampleRows, ...Exported helpers include createIntrospector, parseDatabaseUrl, createPostgresPool / poolFromPostgresUrl, types from ./types, and dialect-specific classes such as PostgresIntrospector where you need them.
Security
Use a least-privilege database user (typically read-only / SELECT only). Treat connection strings and credentials as secrets.
Oracle is not supported.
