SuperAPI AI Directory

mcpolyglot

mcpolyglot is an open-source MCP server that turns existing Postgres, MySQL, SQLite, and MongoDB databases as well as OpenAPI REST APIs into servers supporting the Model Context Protocol, for use by AI agents such as Claude, GPT, and Cursor. Through unified configuration and a CLI, it provides security guardrails such as per-table policies, read-only enforcement, sensitive data masking, and audit logging, with all checks enforced server-side rather than relying on model self-discipline.

Open website

About this tool

mcpolyglot is an MCP (Model Context Protocol) server for AI agents, designed to connect your existing databases and REST APIs to MCP-capable agents such as Claude, GPT, and Cursor using a single configuration and CLI. It supports Postgres, MySQL, SQLite, MongoDB, and OpenAPI, and includes security guardrails enforced by the server rather than merely requested of the model.

Key capabilities:

  • Policy first: every SQL statement is parsed before reaching the database and checked against per-table policies for tables, columns, and functions; rejected calls are returned as tool errors with the reason.
  • Database-level read-only: unless a policy grants write permission, the connection itself is read-only; write operations are executed through a single tool within a transaction and are subject to row limits.
  • Per-agent identity: each agent has its own token (stored as a sha256 hash), its own data sources and scope, and policies can only narrow, not widen; audit logs identify agents by token.
  • Masking and wrapping: emails, JWTs, AWS keys, GitHub tokens, SSNs, and card numbers in results are masked; all results are wrapped in <mcpolyglot-data>, prompting the model to treat them as data rather than instructions.
  • Audit: each call (allowed or denied) records one JSONL line containing the agent, tool, decision, reason, parameter hash, row count, and latency, without recording raw parameters or row data.
  • Transport: supports stdio (Claude Desktop / Cursor / Claude Code) and Streamable HTTP with bearer tokens, per-agent tokens, or OAuth (JWT / JWKS); defaults to loopback addresses only, and provides a /healthz probe and structured JSON logs.
  • Tools: the SQL connector exposes list_tables, describe_table, and query, and adds execute when a policy grants write access to tables; Mongo exposes list_collections, describe_collection, find, and aggregate; OpenAPI exposes list_operations, describe_operation, and call.

Usage:

  • 30-second quick start (SQLite file): npx @mcpolyglot/cli init marks password_hash as a suggested deny column; runs an interactive wizard when no database is present.
  • Point at any database: init introspects the schema and generates a policy, all tables are read-only by default (defaultAccess: 'none'), new tables are hidden by default, and it suggests denyColumns for names like password, token, ssn, api_key, hash; inline passwords are written as ${env:DATABASE_URL}. doctor checks the policy against the live schema and prints what each data source exposes.
  • Docker: the root Dockerfile runs serve --http as a non-root user, with config mounted at /config/mcpolyglot.config.json; examples/docker-compose provides Postgres with an example schema, run docker compose up -d --build then curl localhost:7337/healthz.
  • Code calls: @mcpolyglot/client can communicate with a running HTTP server and is subject to the same policy checks as agents.
  • Connect to Claude Desktop: edit ~/Library/Application Support/Claude/claude_desktop_config.json, restart, then try "list the tables in the database, then sample 5 rows from users".
  • Agent skills: .agents/skills/mcpolyglot is an Agent Skills folder that teaches Claude Code, Codex, Cursor and Gemini CLI to set up and connect to mcpolyglot, and to read policy denial reasons; Claude Code requires copying or symlinking to .claude/skills/. claude.ai chat can connect as a custom connector via serve --http.
  • Examples: examples/ provides end-to-end recipes per connector (Postgres, MySQL, SQLite, MongoDB, OpenAPI, Streamable HTTP, Docker), each example includes a config, seed file and README table, and every row of the table is verified by examples.test.ts.

When to use:

  • You need to let AI agents safely query an existing database while keeping it read-only or with restricted writes.
  • You want to manage multiple databases and REST APIs through a unified interface instead of building a separate server for each data source.
  • You need table/column policies, masking and auditing to meet security compliance requirements.
  • Multi-agent scenarios: different agents use different tokens and narrowed policies (e.g. support bot, finance bot, revoked bot).

Limitations and caveats:

  • Always-denied operations (regardless of policy): DDL, GRANT, SET, multiple statements per call, SQL the parser cannot read, SELECT ... INTO, server-access functions (pg_read_file, LOAD_FILE, dblink, pg_sleep, etc.), system catalogs, and UPDATE/DELETE that specify columns without WHERE; WHERE rules can only catch missing clauses, maxWritesPerCall rolling back runaway statements is the actual safeguard; dryRun: true returns the decision without executing.
  • Prompt injection can still induce a model to perform reads it is allowed to perform; wrapping helps but cannot fully prevent it, so grant agents only the permissions they need.
  • Data an agent can read can be repeated by it, so be mindful of data exfiltration risk.
  • The classifier only sees tables and columns, not the behavior of functions or triggers, so use a database role without relevant privileges.
  • Policies are per table and column; row-level rules must rely on the database's own RLS.
  • Rate limits and idempotency keys exist within a single process, and revoking tokens requires a restart.
  • Business rules (spending limits, balances, approvals) should live in database constraints or the application.
  • The project is in alpha but actively maintained; the four database connectors, the OpenAPI connector and both transports work end to end; CI runs all tests on real Postgres 16, MySQL 8.4 and SQLite, and skipping tests fails.
  • Licensed under MIT.

Not yet provided: specific pricing, costs, platform compatibility details, performance metrics or effectiveness data.