Secure Schema MCP
A read-only MCP server that provides AI coding tools with database schema structure (tables, columns, keys, relationships) without exposing row data.
README
Secure Schema MCP
<!-- mcp-name: io.github.Siddharth-coder13/secure-schema -->
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
| Exposed | Not exposed |
|---|---|
| Table and view names | Row values or query results |
| Column names and SQL types | Row counts or samples |
| Primary and unique keys | Database credentials |
| Foreign-key relationships | Write 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:
{
"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:
[mcp_servers.secure-schema]
command = "uvx"
args = ["mcp-secure-schema"]
enabled_tools = ["schema_overview", "list_tables", "inspect_table"]
startup_timeout_sec = 30
tool_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:
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:
# SQLite (absolute path)
sqlite:////Users/me/project/app.db
# PostgreSQL
postgresql+psycopg2://user:password@localhost:5432/appdb
# Remote PostgreSQL with certificate verification
postgresql+psycopg2://user:password@db.example.com:5432/appdb?sslmode=verify-full&sslrootcert=/path/to/ca.pem
# MySQL
mysql+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
| Variable | Required | Description |
|---|---|---|
DATABASE_URL |
Yes | SQLAlchemy connection URL. Treated as a secret by the registry manifest. |
DATABASE_SCHEMA |
No | Default schema or catalog namespace. Recommended for PostgreSQL. Locked against tool overrides in production. |
ALLOWED_TABLES |
Production | Comma-separated, case-sensitive table and view allowlist. Production mode refuses to start without it. |
SECURE_SCHEMA_ENV |
No | Set to production or prod for strict startup validation. Defaults to development. |
FASTMCP_CHECK_FOR_UPDATES |
No | Set to off for predictable stdio startup. |
FASTMCP_SHOW_SERVER_BANNER |
No | Set to false to suppress the startup banner. |
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:
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_URLfrom an OS keychain or secret manager. - Use a dedicated least-privilege database account and TLS certificate verification for remote connections.
Example PostgreSQL role:
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:
git clone https://github.com/Siddharth-coder13/secure_schema_mcp.git
cd secure_schema_mcp
uv sync --extra dev
uv run python tests/demo_database.py
DATABASE_URL="sqlite:///$PWD/test_schema.db" uv run mcp-secure-schema
Run the test suite:
uv run pytest
Run the opt-in PostgreSQL integration test against a disposable database. The test creates and removes a randomly named schema:
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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。