
DB2TOON MCP
io.github.kamil5b由 GitHub 账号 kamil5b 发布v1.4.4更新于 Oct 27, 2026
Read-only SQL database and plain-text SQL dump schema extraction to compact TOON for MCP clients.
概览
本地 MCP 服务器,读取 SQL 数据库或 SQL 转储文件,并以紧凑的 TOON 文本返回数据库结构,便于文档与设计使用。
- 可以做什么
- 从在线数据库或纯文本 SQL 转储中提取完整结构,并以紧凑的 TOON 文本返回
- 涵盖表、列、类型、主外键、索引、注释、枚举、序列、视图、例程与触发器
- 离线解析转储文件而不执行其中语句,并可将 DBML 文件转换为同一格式
- 通过选择 schema、排除表与字段、设置超时和输出大小上限来限制提取范围
- 适用场景
- 适合让助手了解现有数据库结构、编写结构文档,或在写查询与迁移前梳理表与关系。适用于对 PostgreSQL、SQLite、DuckDB、MySQL/MariaDB、CockroachDB、SQL Server 或 Oracle 结构的只读查看。
- 运行要求
- 以本地 stdio 进程运行,需用 Go 1.26.0 或更高版本从源码构建,或使用容器镜像安装。需要数据库连接字符串或本地数据库路径,或纯文本 SQL 转储文件。DuckDB 还需运行时提供兼容的 libduckdb 共享库;Oracle 使用纯 Go 驱动。
安装
在 SourceWeft 中
- 打开 控制台中的 DB2TOON MCP,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
db2toon
A CLI tool that converts database schemas into the Toon schema definition format.
Overview
db2toon connects to a database and extracts schema information (tables, columns, types, constraints, indexes, routines, triggers, and examples), then converts it into the human-readable Toon format for database design documentation and visualization. PostgreSQL, SQLite, DuckDB, MySQL/MariaDB, CockroachDB, Microsoft SQL Server, and Oracle are supported. pg2toon remains a PostgreSQL compatibility command.
Features
- Schema Extraction: Automatically extracts tables, columns, and metadata from PostgreSQL, SQLite, DuckDB, MySQL/MariaDB, CockroachDB, Microsoft SQL Server, and Oracle
- Type Normalization: Simplifies PostgreSQL types (e.g.,
character varying→varchar) - Relationship Mapping: Converts foreign key constraints to inline references or multi-column references
- Comment Preservation: Includes comments where the database exposes them; SQLite does not have catalog comments
- Index Documentation: Extracts and documents database indexes
- Database Objects: Preserves supported enums, types, sequences, synonyms, triggers, routines, extensions, materialized views, packages, and other vendor-specific objects in explicit TOON sections
- Cross-Platform: Builds without CGO for Linux, macOS, and Windows (amd64 and arm64)
- DBML Adapter: Converts DBML files (or standard input) into the same TOON format
- Local MCP: Read-only SQL database and plain-text SQL dump schema extraction to compact TOON for MCP clients.
Installation
From Source
From Releases
Download pre-built binaries from the releases page for your platform.
Go package
The module also exposes a public Go API for callers that want the canonical schema model instead of invoking a command:
Set exactly one of Request.DB or Request.Dump. Dump contents are parsed
offline and never executed. The public API returns *schema.Database, so
callers may inspect or transform the model before encoding it.
Usage
LLM tool integration
Build and run the MCP-compatible stdio server:
The server exposes db2toon.extract_schema. Its required argument is
dialect (postgres, sqlite, duckdb, mysql, mariadb, cockroachdb, mssql, sqlserver, or oracle).
Provide exactly one of db or dump; optional extraction settings are
supplied in an options object. Dump files are parsed offline and never
executed. The tool is read-only, uses a 30-second default timeout, and limits
responses to 4 MiB. Set options.timeout and options.max_output_bytes to
lower limits when needed. Connection strings are never included in tool errors
or results.
Basic Usage
Save to File
Include up to two sample rows per PostgreSQL table in the TOON output, using a stable ordering and a reproducible sample seed:
The default -example-sample=0 omits @example sections.
SQLite and DuckDB also support -example-sample, but currently use a simple
LIMIT query. -example-sample-ordered and -seed are currently effective
only for PostgreSQL.
Select multiple schemas, include partitioned tables, and change the default 30-second operation timeout with:
Flags
-db string: Database connection URL or local database path; mutually exclusive with-dump-dump string: Plain-text SQL dump path; mutually exclusive with-dbdialect:postgres,sqlite,duckdb,mysql,mariadb,cockroachdb,mssql,sqlserver, ororaclefordb2toon;pg2toonalways uses PostgreSQL-out string: Output file path (optional, defaults to stdout)-schema string: A single schema to extract (defaults topublicfor PostgreSQL,mainfor SQLite/DuckDB,dbofor SQL Server, and the sessionCURRENT_SCHEMAfor Oracle)-schemas string: Comma-separated schemas to extract; cannot be combined with-schema-include-partitioned: Include PostgreSQL partitioned tables-include-views: Include supported views-exclude-tables string: Comma-separated tables to exclude entirely; acceptstableorschema.table-exclude-example-tables string: Comma-separated tables to exclude from@examplesampling-exclude-example-fields string: Comma-separated qualified fields to exclude from examples, such aspublic.users.password_hash-example-sample int: Number of sample rows to include per table (defaults to0)-example-sample-ordered: Select sample rows using deterministic ordering for PostgreSQL (defaults tofalse)-seed int: Seed for reproducible PostgreSQL sample selection (defaults to0; currently ignored by SQLite/DuckDB)-timeout duration: Connection and extraction timeout (defaults to30s)
Dump mode supports plain-text SQL exports for PostgreSQL, SQLite, DuckDB,
MySQL/MariaDB, CockroachDB, SQL Server, and Oracle. Common tables, columns, constraints,
indexes, comments, and bounded INSERT examples are parsed without executing
the dump. PostgreSQL retains native enums, sequences, views, functions,
procedures, and triggers, including dollar-quoted routine bodies. MySQL/MariaDB
supports DELIMITER-based routine and trigger declarations. SQL Server and
Oracle retain supported views, functions, procedures, triggers, sequences,
types, synonyms, and selected vendor objects. Complex vendor-specific PL/SQL/
T-SQL bodies are preserved as available statement text; unsupported declarations
are ignored rather than executed.
Output Format
The Toon format provides a clean, human-readable schema definition:
Format Elements
@database name {dialect=dialect}: Source database metadata. Live connections derive the name from the connection string; dump mode uses the dump filename without its extension.[TableName]: Table definition# comment: Table or column commentsname type {tags}: Column definition with optional tags{pk}: Primary key{req}: Required (NOT NULL)- Multiple tags:
{pk,req}
-> table(column): Foreign key reference (inline for single columns)@indices: Section for database indexes@enum: Enumerated type values@type: User-defined type metadata@sequence: Sequence configuration@synonym: Alternate object name@routine: Function or procedure metadata and definition where available@triggers: Table trigger metadata@objects: Vendor-specific schema objects, including Oracle materialized views, packages, partitioned tables, scheduler jobs, and database links@example[n]{columns}:: Up tonsampled rows from the table// comment: Inline column comment
Oracle coverage
Oracle extraction uses user-visible ALL_* catalog views, so the output is
limited to objects the connected account can inspect. It supports tables,
views, columns and comments, primary/unique/foreign-key/check constraints,
independent indexes, triggers, standalone functions and procedures, user
sequences, object types, synonyms, materialized views, packages/package bodies,
partitioned-table markers, scheduler jobs, and database links. Oracle-generated
identity sequences and system-generated NOT NULL checks are omitted because
their information is already represented by the column model.
Package/type source bodies, materialized-view refresh settings, detailed partition definitions, grants/roles, VPD policies, tablespace/storage details, specialized spatial/domain index options, and Oracle SQL dump parsing are not yet represented in the canonical model.
Microsoft SQL Server coverage
Microsoft SQL Server extraction uses sys.* catalog views and defaults to the
dbo schema unless -schema or -schemas is supplied. It supports tables and
views, columns and MS_Description comments, defaults, identity/computed
columns, primary/unique/foreign-key/check constraints, independent indexes,
triggers, functions/procedures, alias/table types, sequences, synonyms, and
sample rows. View definitions and vendor-specific schema objects are emitted in
the TOON object sections where applicable.
SQL Server dump parsing is not supported. The current model also does not yet represent partition functions/schemes, filegroups, temporal or memory-optimized table settings, graph tables, full-text/spatial/XML index internals, permissions, extended properties other than descriptions, Agent jobs, or server-level objects.
Requirements
- Go 1.26.0 or later
- PostgreSQL 9.4+ (for JSON aggregation functions), SQLite, DuckDB, MySQL/MariaDB, CockroachDB, Microsoft SQL Server 2022+, or Oracle Database
- A valid database connection string or local database path
- DuckDB also requires a compatible
libduckdbshared library at runtime - Oracle uses the pure-Go
go-oradriver and does not require Oracle Instant Client or CGO
License
MIT
来源:README.md,提交 a9b79f0
工具
0版本历史
1- v1.4.4最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分