Purpose
CoreMCP is a Model Context Protocol (MCP) server written in Go, used to expose SQL databases as MCP tools and prompts to LLMs and AI agents, enabling large-model-based data analysis. It runs as a single static binary with embedded database drivers, can communicate with local MCP clients (such as Claude Desktop) via stdio, and can also run remotely behind NAT via outbound WebSocket.
Main capabilities
- Database adapters: currently provides MSSQL (SQL Server 2000+, aware of Turkish_CI_AS collation) and PostgreSQL adapters. The Firebird adapter is under development (the factory currently returns a placeholder error); MySQL is on the roadmap.
- Transport modes: stdio (default) and outbound WebSocket connection mode (connect), the latter used for networks that do not allow inbound port 443 (factory floors, enterprise VPCs, hospital networks, etc.).
- Schema discovery: on startup, connects to each configured data source, scans tables, columns, keys, relationships, and extracts column comments (such as MSSQL's MS_Description); the results are exposed as a single MCP prompt, providing schema context for the model.
- Built-in tools: list_tables (tables with column counts, primary keys, foreign key counts), describe_table (full schema of a single table: columns, types, nullability, primary keys, foreign keys, column comments), list_views (all views and column definitions), list_procedures (stored procedures with parameter names, types, modes IN/OUT/INOUT, and sample calls), execute_procedure (enabled only when readonly: false).
- Custom tools: reusable parameterized queries can be defined as first-class MCP tools, which the model can call directly without re-deriving SQL each turn.
- Security mechanisms: T-SQL-aware lexer (fail-closed custom tokenizer that strips comments and string literals before classifying statements; only SELECT and WITH pass; DROP, ALTER, UPDATE, DELETE, TRUNCATE, EXEC, OPENROWSET, SELECT…INTO, etc. are rejected before reaching the database; multi-statement payloads are fatal, blocking stacked query attacks); enforced row limits (append or wrap LIMIT for each SELECT); regex-based PII masking (result strings are post-processed before reaching the client).
- Middleware: NOLOCK / READ UNCOMMITTED (per data source, MSSQL); Turkish character and mojibake correction middleware (MSSQL).
- Remote configuration sync: the relay protocol supports wire commands such as run_sql, get_schema, list_sources, health_check, config_sync.
Usage
Download the binary for your platform from the Releases page (linux/amd64, linux/arm64, darwin/{amd64,arm64}, windows/amd64), or use the Linux/macOS one-line installer, or use the multi-architecture images (linux/amd64, linux/arm64). Building from source requires Go 1.23+.
Local mode (serve): stdio is the default transport, used for local MCP clients (such as Claude Desktop), configured in claude_desktop_config.json.
Remote mode (connect): connect opens an outbound WebSocket to a relay (usually CoreBase Cloud) and serves MCP traffic over it; the agent never accepts inbound connections.
Configuration: place coremcp.yaml in the working directory; refer to coremcp.example.yaml for a more complete example. For testing, the dummy adapter can be used (no real database required).
Adding an adapter: create pkg/adapter/yourdb/, implement core.Source, and register it in pkg/adapter/factory.go; pkg/adapter/dummy/dummy.go is the minimal reference implementation.
Applicable scenarios
Suitable for scenarios that require LLMs or AI agents to access local or on-premises databases (including legacy systems) for data analysis, especially in network environments behind firewalls that do not allow inbound connections. CoreMCP is part of the open-source local gateway suite of CoreBase (an AI agent platform for enterprise data)items, running on its own server, with database credentials kept locally, using only outbound port 443 and zero-trust connections.
Limitations
- Read-only by default: when readonly is omitted, it stays in SELECT-only mode; execute_procedure can only be enabled by setting readonly: false. It is recommended to use a dedicated database user with only SELECT privileges (and EXECUTE only on the procedures you intend to expose) as defense in depth.
- Security validation serves only as one layer of protection and should not be the only protection; it must be combined with least-privilege database roles.
- The Firebird adapter is still under development; MySQL, HTTP transport, audit logging, query result caching, write operations (with explicit security protections), multi-agent management, and real-time monitoring are on the roadmap.
- License: Apache License 2.0. For security reports, see SECURITY.md; for contributions, see CONTRIBUTING.md. Contact email: support@corebasehq.com.