Labsco
corebasehq logo

CoreMCP

β˜… 10

from corebasehq

Connect Legacy Databases to AI Agents via Model Context Protocol. Open-source bridge for LLM data analysis.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeQuick setup

CoreMCP

A Model Context Protocol (MCP) server, written in Go, that exposes SQL databases as MCP tools and prompts. It runs as a single static binary, embeds its drivers, and talks either stdio (for local MCP clients like Claude Desktop) or an outbound WebSocket (for remote operation behind NAT).

Currently ships with MSSQL (SQL Server 2000+, Turkish_CI_AS collation aware) and PostgreSQL adapters. Firebird is in progress; MySQL is on the roadmap.

Status

  • Stable: MSSQL adapter, PostgreSQL adapter, stdio transport, schema discovery, custom tools, NOLOCK / Turkish normalization middleware, WebSocket connect mode.
  • In progress: Firebird adapter (factory currently returns a placeholder error).
  • Roadmap: MySQL, HTTP transport, audit log, query result cache.

Defaults

CoreMCP is read-only by default. Omitting readonly in a source config leaves SELECT-only mode active; you have to set readonly: false to enable execute_procedure. Even so, the recommended posture is a dedicated DB user with SELECT (and EXECUTE only on the procedures you intend to expose) β€” defense in depth rather than relying solely on the server-side guard.

Architecture

coremcp/
β”œβ”€β”€ cmd/coremcp/       # CLI entry point
β”‚   β”œβ”€β”€ main.go
β”‚   β”œβ”€β”€ root.go
β”‚   β”œβ”€β”€ serve.go       # stdio mode
β”‚   └── connect.go     # WebSocket mode
β”œβ”€β”€ pkg/
β”‚   β”œβ”€β”€ adapter/       # Database adapters
β”‚   β”‚   β”œβ”€β”€ factory.go
β”‚   β”‚   β”œβ”€β”€ dummy/
β”‚   β”‚   └── mssql/
β”‚   β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ core/          # Shared types, Source interface
β”‚   β”œβ”€β”€ security/      # Query validation, PII masking
β”‚   └── server/        # MCP server
└── coremcp.yaml

Tools and prompts

Built-in tools

query_database

Arbitrary SQL against a configured source.

  • source_name (required)
  • query (required)

list_tables

Tables with column counts, primary keys, foreign key counts.

  • source_name (required)

describe_table

Full schema for one table: columns, types, nullability, PKs, FKs, column comments.

  • source_name (required)
  • table_name (required)

list_views

All views with column definitions.

  • source_name (required)

list_procedures

Stored procedures with parameter names, types, modes (IN/OUT/INOUT), and a ready-to-copy example call.

  • source_name (required)

execute_procedure

Calls a stored procedure with named parameters. Only enabled when readonly: false.

  • source_name (required)
  • procedure_name (required)
  • params (optional) β€” JSON object of name/value pairs

Hardening:

  • Procedure name validated against ^[a-zA-Z_][a-zA-Z0-9_#@.]*$
  • Parameter names validated (alphanumeric + underscore)
  • Values bound via sql.Named β€” no string interpolation
  • Rejected outright when source is readonly: true

Example:

{
  "source_name": "erp_db",
  "procedure_name": "sp_CiroHesapla",
  "params": "{\"StartDate\":\"2024-01-01\",\"EndDate\":\"2024-12-31\"}"
}

Custom tools

Define reusable parameterized queries as first-class MCP tools:

custom_tools:
  - name: "get_daily_sales"
    description: "Daily sales summary for a given date"
    source: "production_db"
    query: "SELECT * FROM orders WHERE DATE(created_at) = '{{date}}'"
    parameters:
      - name: "date"
        description: "Date in YYYY-MM-DD format"
        required: true

  - name: "get_top_customers"
    description: "Top N customers by order count"
    source: "production_db"
    query: "SELECT user_id, COUNT(*) AS order_count FROM orders GROUP BY user_id ORDER BY order_count DESC LIMIT {{limit}}"
    parameters:
      - name: "limit"
        description: "Number of customers to return"
        required: true
        default: "10"

These get exposed to the model with their declared parameter schema, so the model can call them directly rather than re-deriving the SQL each turn.

database_schema prompt

On startup CoreMCP connects to every configured source, scans tables / columns / keys / relationships, and extracts column comments (e.g. MS_Description on MSSQL). The result is exposed as a single MCP prompt that primes the model with schema context β€” including the comments β€” so it can write correct queries without manual schema dumps in every conversation.

Adding adapters

  1. Create pkg/adapter/yourdb/.
  2. Implement core.Source.
  3. Register in pkg/adapter/factory.go.

pkg/adapter/dummy/dummy.go is the minimum reference implementation.

Roadmap

  • Schema discovery on startup
  • Column comments / descriptions
  • Built-in list_tables / describe_table
  • Custom parameterized tools
  • T-SQL aware lexer for query sanitization (fail-closed, multi-statement reject, no third-party parser)
  • PII masking
  • Forced row cap
  • WebSocket connect mode
  • Auto-reconnect
  • Remote config sync
  • NOLOCK / READ UNCOMMITTED per source (MSSQL)
  • Turkish character + mojibake middleware (MSSQL)
  • View and procedure discovery (list_views, list_procedures, execute_procedure)
  • PostgreSQL adapter
  • Firebird adapter (in progress)
  • MySQL adapter
  • HTTP transport
  • Query result cache
  • Write operations (with explicit safety guards)
  • Audit logging
  • Multi-agent management
  • Real-time monitoring

Support


About

CoreMCP is the on-prem agent component of CoreBase β€” memory infrastructure for the AI agents your customers use. CoreBase gives those agents structured access to operational systems (SQL Server 2000+, REST, GraphQL, Slack, Microsoft 365) and layers Corporate Memory on top: the schema relationships, terminology, and proven query patterns that turn raw access into accurate answers.