
Secure Schema MCP
io.github.Siddharth-coder13由 GitHub 账号 Siddharth-coder13 发布v1.0.1更新于 Oct 24, 2026
Read-only MCP server for exposing database schema metadata without row data.
概览
一个只读 MCP 服务器,让 AI 助手获取数据库结构(表、列、键和关系),而不暴露行数据。
- 可以做什么
- 以紧凑或 markdown 格式获取允许访问的表、视图、主键和外键关系的概览。列出助手可见的表和视图清单。查看单个表或视图的列、SQL 类型、可空性、主键、唯一约束和外键。
- 适用场景
- 适合 AI 编程工具需要了解现有 SQLite、PostgreSQL 或 MySQL 数据库结构,以便编写查询、迁移或应用代码,同时不希望交出数据行或查询权限的场景。
- 运行要求
- 作为本地进程通过 stdio 运行,由 Cursor、Codex 等 MCP 客户端启动。需要可访问的 SQLite、PostgreSQL 或 MySQL 数据库,以及必填的 DATABASE_URL 连接字符串;不使用 uvx 安装时需要 Python 3.12 或更高版本。可选配置包括 DATABASE_SCHEMA、ALLOWED_TABLES 和 SECURE_SCHEMA_ENV。远程数据库需要网络访问和有效的 TLS 设置。
安装
在 SourceWeft 中
- 打开 控制台中的 Secure Schema MCP,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Secure Schema MCP
A read-only MCP server that gives AI coding tools database structure without exposing row data. It returns table and view names, columns, types, keys, and relationships in a compact format designed to reduce LLM token usage.
What it exposes
Schema metadata can still be sensitive. A column name such as ssn reveals information even without values, so production deployments should always use the table allowlist and a dedicated database account.
Requirements
- An MCP-compatible client such as Cursor or Codex
- A reachable SQLite, PostgreSQL, or MySQL database
- Python 3.12 or newer when installing without
uvx
SQLite support uses Python's built-in driver. PostgreSQL and MySQL drivers are included. Other SQLAlchemy dialects are not tested or bundled in v1.
Configure your IDE
The recommended setup uses uvx to download and run the published Python package in an isolated environment. You do not need to clone this repository or start the server separately. Your IDE launches it over stdio when needed.
Cursor
Add this server to your Cursor MCP configuration:
Restart or reload Cursor after changing its MCP configuration.
Codex
Add this to ~/.codex/config.toml or a trusted project's .codex/config.toml:
Install once instead
If you prefer a persistent installation:
Then use "command": "mcp-secure-schema" with an empty args list in the IDE configuration.
Database URLs
Secure Schema MCP accepts SQLAlchemy connection URLs:
Percent-encode special characters in URL usernames and passwords. For example, @ in a password becomes %40.
Local and remote databases use the same MCP configuration. For remote databases, the machine running the IDE must also have working DNS, network access, firewall permission, and valid TLS settings.
Configuration
Multiple schemas
DATABASE_SCHEMA selects the default namespace. Resolution works as follows:
- In production, a configured
DATABASE_SCHEMAis a security boundary and tool arguments cannot override it. - Outside production, an explicit tool
schemaargument overridesDATABASE_SCHEMA. - Without either value, the database driver's default schema is used.
For strict production access to multiple schemas, run one MCP server entry per schema with its own DATABASE_SCHEMA and ALLOWED_TABLES values. The table allowlist contains unqualified names, not schema.table values.
Tools
schema_overview: compact map of permitted tables, views, primary keys, and foreign-key relationshipslist_tables: permitted table and view inventoryinspect_table: columns, SQL types, nullability, primary keys, unique constraints, and foreign keys for one entity
Every tool defaults to format="compact" for lower token usage:
Pass format="markdown" when a human-readable table is more useful.
Security notes
- The server exposes only SQLAlchemy inspection operations; it provides no row-query or write tool.
- Missing and disallowed table names return the same message when an allowlist is active, avoiding an existence leak.
- Client-facing errors are sanitized. Operational details are written to server stderr.
- The IDE launches the MCP process and supplies its environment, so treat the IDE and its configuration as trusted.
- Do not commit configurations containing credentials. For stronger isolation, launch through a wrapper that obtains
DATABASE_URLfrom an OS keychain or secret manager. - Use a dedicated least-privilege database account and TLS certificate verification for remote connections.
Example PostgreSQL role:
Metadata visibility varies by PostgreSQL provider and database policy. Grant only the additional catalog or object privileges required for inspection; avoid granting row SELECT unless your environment requires it.
Troubleshooting
The server exits immediately
Check the IDE's MCP logs. DATABASE_URL is mandatory, and production mode also requires a non-empty ALLOWED_TABLES value.
No tables or views are discovered
Confirm DATABASE_SCHEMA, exact table-name casing, database permissions, and whether the allowlist contains the expected names.
The connection URL fails with a valid password
Percent-encode reserved URL characters or use a secret-injection wrapper. Do not paste real credentials into issues or logs.
uvx is not found
Install uv using its official instructions, or install the package with pipx and use mcp-secure-schema as the command.
Starting the command appears to hang
That is normal for a stdio MCP server. It waits for an MCP client on standard input and is normally started by the IDE.
Development
Clone the repository only when developing or testing the server:
Run the test suite:
Run the opt-in PostgreSQL integration test against a disposable database. The test creates and removes a randomly named schema:
The tests verify row-data isolation, allowlist behavior, sanitized errors, compact output, relationships, schema selection, and the locked production namespace.
Release checklist
Maintainers should update the matching versions in pyproject.toml and server.json, run the complete SQLite and PostgreSQL suites, build with uv build --no-sources, verify installation from the wheel, publish to PyPI, and only then publish server.json to the MCP Registry.
License
Licensed under the Apache License 2.0. See LICENSE and NOTICE.
来源:README.md,提交 fb661d1
工具
0版本历史
1- v1.0.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分