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.

已驗證STDIO僅桌面資料庫開發者工具

概覽

AI 產生的概覽

一個唯讀 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 設定。
安裝前請注意
DATABASE_URL 含有資料庫憑證,經由 IDE 設定傳入,請勿提交到版本庫,建議改用密鑰管理工具。結構中繼資料本身也可能敏感,例如欄位名稱 ssn 就會透露資訊。請使用專用的最小權限帳號,正式環境設定 ALLOWED_TABLES 並啟用正式模式,遠端連線啟用 TLS 驗證。此伺服器不提供資料列查詢或寫入工具。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Secure Schema MCP,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

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

ExposedNot exposed
Table and view namesRow values or query results
Column names and SQL typesRow counts or samples
Primary and unique keysDatabase credentials
Foreign-key relationshipsWrite or query tools

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:

json
{  "mcpServers": {    "secure-schema": {      "command": "uvx",      "args": ["mcp-secure-schema"],      "env": {        "DATABASE_URL": "postgresql+psycopg2://schema_reader:password@localhost:5432/appdb",        "DATABASE_SCHEMA": "public",        "ALLOWED_TABLES": "users,orders,products",        "SECURE_SCHEMA_ENV": "production",        "FASTMCP_CHECK_FOR_UPDATES": "off",        "FASTMCP_SHOW_SERVER_BANNER": "false"      }    }  }}

Restart or reload Cursor after changing its MCP configuration.

Codex

Add this to ~/.codex/config.toml or a trusted project's .codex/config.toml:

toml
[mcp_servers.secure-schema]command = "uvx"args = ["mcp-secure-schema"]enabled_tools = ["schema_overview", "list_tables", "inspect_table"]startup_timeout_sec = 30tool_timeout_sec = 30
[mcp_servers.secure-schema.env]DATABASE_URL = "postgresql+psycopg2://schema_reader:password@localhost:5432/appdb"DATABASE_SCHEMA = "public"ALLOWED_TABLES = "users,orders,products"SECURE_SCHEMA_ENV = "production"FASTMCP_CHECK_FOR_UPDATES = "off"FASTMCP_SHOW_SERVER_BANNER = "false"

Install once instead

If you prefer a persistent installation:

bash
pipx install mcp-secure-schema

Then use "command": "mcp-secure-schema" with an empty args list in the IDE configuration.

Database URLs

Secure Schema MCP accepts SQLAlchemy connection URLs:

text
# SQLite (absolute path)sqlite:////Users/me/project/app.db
# PostgreSQLpostgresql+psycopg2://user:password@localhost:5432/appdb
# Remote PostgreSQL with certificate verificationpostgresql+psycopg2://user:[email protected]:5432/appdb?sslmode=verify-full&sslrootcert=/path/to/ca.pem
# MySQLmysql+pymysql://user:password@localhost:3306/appdb

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

VariableRequiredDescription
DATABASE_URLYesSQLAlchemy connection URL. Treated as a secret by the registry manifest.
DATABASE_SCHEMANoDefault schema or catalog namespace. Recommended for PostgreSQL. Locked against tool overrides in production.
ALLOWED_TABLESProductionComma-separated, case-sensitive table and view allowlist. Production mode refuses to start without it.
SECURE_SCHEMA_ENVNoSet to production or prod for strict startup validation. Defaults to development.
FASTMCP_CHECK_FOR_UPDATESNoSet to off for predictable stdio startup.
FASTMCP_SHOW_SERVER_BANNERNoSet to false to suppress the startup banner.

Multiple schemas

DATABASE_SCHEMA selects the default namespace. Resolution works as follows:

  • In production, a configured DATABASE_SCHEMA is a security boundary and tool arguments cannot override it.
  • Outside production, an explicit tool schema argument overrides DATABASE_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 relationships
  • list_tables: permitted table and view inventory
  • inspect_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:

text
tables:orders,users | pk:orders(order_id);users(user_id) | fk:orders.user_id->users.user_id

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_URL from an OS keychain or secret manager.
  • Use a dedicated least-privilege database account and TLS certificate verification for remote connections.

Example PostgreSQL role:

sql
CREATE ROLE schema_reader LOGIN PASSWORD 'use-a-secret-manager';GRANT CONNECT ON DATABASE appdb TO schema_reader;GRANT USAGE ON SCHEMA public TO schema_reader;

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:

bash
git clone https://github.com/Siddharth-coder13/secure_schema_mcp.gitcd secure_schema_mcpuv sync --extra devuv run python tests/demo_database.pyDATABASE_URL="sqlite:///$PWD/test_schema.db" uv run mcp-secure-schema

Run the test suite:

bash
uv run pytest

Run the opt-in PostgreSQL integration test against a disposable database. The test creates and removes a randomly named schema:

bash
POSTGRES_TEST_DATABASE_URL='postgresql+psycopg2://user@localhost:5432/testdb' \  uv run pytest tests/test_postgres_smoke.py -v

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
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.0.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分