# SchemaGate

> Selects database schema for text-to-SQL using the caller’s access.

- **URL**: https://followmcp.com/en/servers/schemagate
- **Category**: Database
- **Origin**: Community
- **Stars**: 129
- **FMRS Score**: 58/100 (Grade C)
- **Source**: https://github.com/ashishsinha1602/schemagate
- **Transports**: stdio (local process)
- **Runtimes**: Python
- **Auth**: No credential needed

## Overview
SchemaGate is a database schema selection MCP server for text-to-SQL. It selects relevant tables for a question and can exclude tables and columns the caller is not allowed to read, using caller identity, roles, or database grants. It supports multiple database types and communicates with MCP clients over stdio.

## Best for
- Building text-to-SQL applications that need schema visibility scoped by identity or role.
- Database agent workflows that benefit from sending less schema information to a model.
- Teams connecting the listed database types through MCP.

## Not for
- Users who do not need SQL databases or text-to-SQL.
- Workflows that require database writes or modifications; the described query execution is read-only.
- Deployments that cannot supply valid database connection details and do not use the built-in demo database.

## Required permissions
- Connecting to a real database requires its connection details; the project recommends a read-only database user.
- For database-grant-based filtering, the client must send caller identity and the server must set `SCHEMAGATE_RESTRICT_FROM_GRANTS=1`.
- Database passwords and full connection URLs can be supplied through configuration fields marked secret.

## Risks
- Access filtering depends on correct caller identity, roles, and policy configuration. Calls without identity are treated as anonymous and see only objects granted to everyone.
- Grant-based filtering applies to the database types and grant mechanisms described in the source; misconfiguration or missing identity may produce an unexpected visibility scope.
- Query tools can read data available to the configured database credentials; use a read-only account and protect credentials.
- The source says `run_query` checks read-only SELECT statements, but that alone does not establish that every deployment or database configuration is risk-free.

## Client config (JSON)
```json
{
  "command": "uvx",
  "args": [
    "schemagate-mcp"
  ],
  "env": {
    "SCHEMAGATE_DB_TYPE": "demo"
  }
}
```

## Tools (14)
- `select_schema`: Select relevant schema objects for a question, scoped to the caller’s access.
- `list_objects`: List database objects visible to the caller.
- `describe_object`: Show structure information for a visible database object.
- `run_query`: Run a read-only query after SQL safety checks.
- `explain_query`: Explain a query.
- `compare_queries`: Compare queries.
- `optimize_query`: Optimize a query.
- `semantic_query`: Run a semantic query.
- `answer`: Answer a question; available when a server-side model is configured.
- `deep_answer`: Produce a deeper answer to a question; available when a server-side model is configured.
- `refresh_catalog`: Refresh the database catalog.
- `health`: Check server health.
- `list_connections`: List recognized saved connections; available in local stdio installs.
- `connect_database`: Switch to a saved database connection; available in local stdio installs.
