loading…
Search for a command to run...
loading…
A secure, tunnel-native database bridge for AI agents. Connects localhost & on-premise databases (MSSQL, etc.) to LLMs with AST-based query safety and PII maski
A secure, tunnel-native database bridge for AI agents. Connects localhost & on-premise databases (MSSQL, etc.) to LLMs with AST-based query safety and PII masking.
Model Context Protocol (MCP) server for database operations
CoreMCP by CoreBaseHQ provides a secure, extensible bridge between AI assistants (like Claude Desktop) and your databases through the Model Context Protocol.
⚠️ Safety First: CoreMCP defaults to Read-Only mode — omitting readonly in your config is safe. We strongly recommend creating a specific database user with SELECT permissions only.
READ UNCOMMITTED isolation (MSSQL WITH (NOLOCK) equivalent) for zero-locking reads on busy OLTP databasesgit clone https://github.com/corebasehq/coremcp.git
cd coremcp
go build -o coremcp ./cmd/coremcp
Download the latest release from the Releases page.
Create a coremcp.yaml file in your working directory:
server:
name: "coremcp-agent"
version: "0.1.0"
transport: "stdio"
port: 8080
logging:
level: "info"
format: "json"
sources:
- name: "my_database"
type: "mssql"
dsn: "sqlserver://username:password@localhost:1433?database=mydb&encrypt=disable"
readonly: true
no_lock: true # Optional: READ UNCOMMITTED isolation (WITH (NOLOCK) equivalent)
normalize_turkish: true # Optional: Turkish character normalization for legacy ERP databases
See coremcp.example.yaml for more examples.
Microsoft SQL Server:
sqlserver://username:password@host:port?database=dbname&encrypt=disable
Dummy (for testing):
dummy://test
CoreMCP includes enterprise-grade security features:
security:
# Maximum rows to return (prevents DB overload)
max_row_limit: 1000
# Enable PII masking
enable_pii_masking: true
# PII patterns to mask
pii_patterns:
- name: "credit_card"
pattern: '\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b'
replacement: "****-****-****-****"
enabled: true
- name: "email"
pattern: '\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
replacement: "***@***.***"
enabled: true
- name: "turkish_id"
pattern: '\b[1-9]\d{10}\b'
replacement: "***********"
enabled: true
Security Features:
| Option | Type | Default | Description |
|---|---|---|---|
name |
string | — | Unique source identifier |
type |
string | — | Adapter type: mssql, dummy |
dsn |
string | — | Connection string |
readonly |
bool | true |
Restrict to SELECT-only at the config level. Set false explicitly to allow execute_procedure. |
no_lock |
bool | false |
(MSSQL only) Run all SELECT queries under READ UNCOMMITTED transaction isolation level. Equivalent to adding WITH (NOLOCK) to every table reference. Eliminates shared lock acquisition, improving read throughput on busy OLTP databases. Trade-off: may return dirty (uncommitted) rows. |
normalize_turkish |
bool | false |
(MSSQL only) Enable Turkish character normalization middleware. Outgoing: Turkish chars inside SQL string literals are converted to ASCII uppercase before the query is sent ('Hüseyin' → 'HUSEYIN', 'Şeker' → 'SEKER'). Incoming: Windows-1254 / Windows-1252 mojibake in result strings is auto-corrected. Use this for legacy Turkish ERP databases with Turkish_CI_AS collation. |
sources:
- name: "oltp_db"
type: "mssql"
dsn: "sqlserver://user:pass@localhost:1433?database=production&encrypt=disable"
readonly: true
no_lock: true
sources:
- name: "erp_db"
type: "mssql"
dsn: "sqlserver://user:pass@localhost:1433?database=LOGO&encrypt=disable"
readonly: true
no_lock: true # Avoid locking on busy OLTP
normalize_turkish: true # AI can now search 'Hüseyin' and it matches 'HUSEYIN'
How Turkish normalization works:
| AI sends | Normalized query (sent to DB) | Why |
|---|---|---|
WHERE ADI = 'Hüseyin' |
WHERE ADI = 'HUSEYIN' |
ERP stores names as uppercase ASCII |
WHERE SEHIR LIKE '%şeker%' |
WHERE SEHIR LIKE '%SEKER%' |
Ş → S |
WHERE SEHIR = 'İstanbul' |
WHERE SEHIR = 'ISTANBUL' |
İ → I |
Mojibake correction (incoming results):
| DB returns (garbled) | Fixed output | Cause |
|---|---|---|
GÐKHAN |
GĞKHAN |
Win-1254 byte 0xD0 read as Win-1252 |
ÝSTANBUL |
İSTANBUL |
Win-1254 byte 0xDD read as Win-1252 |
ÞEHİR |
ŞEHİR |
Win-1254 byte 0xDE read as Win-1252 |
CoreMCP has two operation modes:
Start the MCP Server locally:
coremcp serve --config coremcp.yaml
Or use stdio transport (default):
coremcp serve -t stdio
Add to your Claude Desktop config (claude_desktop_config.json):
{
"mcpServers": {
"coremcp": {
"command": "/path/to/coremcp",
"args": ["serve", "-c", "/path/to/coremcp.yaml"],
"env": {}
}
}
}
Connect to CoreBase Cloud Platform for remote management:
coremcp connect --server="wss://api.corebase.com/ws/agent" --token="sk_fabrika_123"
Perfect for:
Flags:
-s, --server string CoreBase Cloud WebSocket URL (required)
-t, --token string Authentication token (required)
-a, --agent-id string Agent ID (optional, auto-generated if not provided)
-r, --max-reconnect int Maximum reconnection attempts (default: 10, 0 for infinite)
-d, --reconnect-delay duration Delay between reconnection attempts (default: 5s)
# Factory IT admin runs this command
./coremcp connect \
--server="wss://api.corebasehq.com/ws/agent" \
--token="sk_fabrika_xyz" \
--agent-id="factory-istanbul-001" \
--max-reconnect=0 # Infinite reconnection
How it works:
Remote Commands Supported:
run_sql: Execute SQL queries remotelyget_schema: Retrieve database schemalist_sources: List connected databaseshealth_check: Check agent statusconfig_sync: Update database configurations remotelyNo Port Forwarding Required! 🎉
coremcp/
├── cmd/coremcp/ # CLI application entry point
│ ├── main.go # Main entry
│ ├── root.go # Root command
│ ├── serve.go # Serve command (stdio mode for Claude Desktop)
│ └── connect.go # Connect command (WebSocket mode for Cloud)
├── pkg/
│ ├── adapter/ # Database adapters
│ │ ├── factory.go # Adapter factory pattern
│ │ ├── dummy/ # Dummy adapter (for testing)
│ │ └── mssql/ # MSSQL adapter
│ ├── config/ # Configuration management
│ ├── core/ # Core type definitions
│ ├── security/ # Security features (PII masking, query validation)
│ └── server/ # MCP server implementation
└── coremcp.yaml # Configuration file
query_databaseExecutes arbitrary SQL queries on configured database sources.
Parameters:
source_name (required): Name of the database source from configquery (required): SQL query to executeExample:
SELECT * FROM users WHERE id = 1
list_tablesLists all tables in a database with summary information.
Parameters:
source_name (required): Name of the database sourceReturns: List of tables with column counts, primary keys, and foreign key counts.
describe_tableShows detailed schema information for a specific table.
Parameters:
source_name (required): Name of the database sourcetable_name (required): Name of the table to describeReturns: Complete table schema including:
list_viewsLists all views in a database with their column definitions.
Parameters:
source_name (required): Name of the database sourceReturns: Each view with its column names, types, and nullability.
list_proceduresLists all stored procedures in a database with parameter details.
Parameters:
source_name (required): Name of the database sourceReturns: Each procedure with parameter names, types, modes (IN/OUT/INOUT) and a ready-to-copy example call.
execute_procedureExecutes a stored procedure by name with optional named parameters.
⚠️ Only available on sources where
readonly: false.
Parameters:
source_name (required): Name of the database sourceprocedure_name (required): Stored procedure name (e.g. sp_CiroHesapla)params (optional): JSON string of parameter name/value pairsSecurity:
^[a-zA-Z_][a-zA-Z0-9_#@.]*$sql.Named) — no string interpolationreadonly: trueExample:
{
"source_name": "erp_db",
"procedure_name": "sp_CiroHesapla",
"params": "{\"StartDate\":\"2024-01-01\",\"EndDate\":\"2024-12-31\"}"
}
You can define reusable SQL queries as custom MCP tools in your coremcp.yaml:
custom_tools:
- name: "get_daily_sales"
description: "Retrieves daily sales summary for a specific 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: "Lists 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"
Benefits:
database_schema PromptAutomatically provides complete database schema context to the AI, including:
When CoreMCP starts, it automatically:
MS_Description in MSSQL)This allows Claude to understand your database structure and write accurate queries without you having to explain the schema manually.
Example:
When you ask Claude "Show me all sales", Claude can see that you have a TBLSATIS table with specific columns and automatically write the correct query.
pkg/adapter/yourdb/core.Source interfacepkg/adapter/factory.goSee pkg/adapter/dummy/dummy.go for a simple example.
Contributions are welcome! Please read CONTRIBUTING.md for details.
For security concerns, please see SECURITY.md.
Apache License 2.0 - see LICENSE for details.
list_views, list_procedures, execute_procedure tools; auto-included in schema contextMade with ❤️ by CoreBaseHQ
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"corebasehq-coremcp": {
"command": "npx",
"args": []
}
}
}