mysql-context-mcp
Enables agents to pull compact MySQL row diffs into their context, supporting before/after changes via triggers or watermark-based updates, with tools to fetch and acknowledge changes.
README
mysql-context-mcp
Light stdio MCP server. Agents pull compact MySQL row diffs into context. No UI, no replica, no Kafka.
License: MIT. Do not commit DSNs. See SECURITY.md.
Modes
| Mode | What you get | Deploy cost |
|---|---|---|
| outbox (default) | Real before/after from table triggers | One extra table + 3 triggers per watched table |
| watermark | Rows newer than updated_at (no before-image, deletes missed) |
Config only |
Setup
git clone https://github.com/velinussage/mysql-context-mcp.git
cd mysql-context-mcp
npm install
cp config.example.yaml mysql-context.yaml
export MYSQL_CONTEXT_DSN='mysql://user@127.0.0.1:3306/app'
Put the password in the environment DSN, not in the YAML. Edit tables: to the few tables agents should see.
Install triggers once, from a privileged shell — not from the agent:
npx tsx src/install.ts
After that, run the MCP with a user that can only SELECT watched tables and SELECT/UPDATE the outbox table.
Tools
| Tool | Use |
|---|---|
recent_changes |
Default pull. Unacked diffs, capped, JSON. |
get_diff |
One change (change_id, or table+pk in watermark mode). |
ack_changes |
Mark seen so they leave the next pull. |
There is no execute_sql and no install tool on the MCP server.
Attach to a harness
Claude Code / Grok / Cursor (project .mcp.json):
{
"mcpServers": {
"mysql-context": {
"command": "npx",
"args": ["tsx", "src/server.ts"],
"cwd": ".",
"env": {
"MYSQL_CONTEXT_CONFIG": "./mysql-context.yaml",
"MYSQL_CONTEXT_DSN": "${MYSQL_CONTEXT_DSN}"
}
}
}
}
Set cwd to the clone. Keep MYSQL_CONTEXT_DSN in the process environment, not in a committed file.
Claude Agent SDK:
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const message of query({
prompt: "What changed in MySQL since last look? Use recent_changes.",
options: {
mcpServers: {
"mysql-context": {
command: "npx",
args: ["tsx", "src/server.ts"],
env: {
MYSQL_CONTEXT_CONFIG: "./mysql-context.yaml",
MYSQL_CONTEXT_DSN: process.env.MYSQL_CONTEXT_DSN!,
},
},
},
allowedTools: [
"mcp__mysql-context__recent_changes",
"mcp__mysql-context__get_diff",
"mcp__mysql-context__ack_changes",
],
},
})) {
// ...
}
Skill
Copy skill/mysql-context/SKILL.md into the project .claude/skills/ or .grok/skills/ so the agent calls recent_changes before reasoning about live rows.
When this is the wrong tool
- You need a full history of every row forever — use a binlog indexer
- You need a live analytics replica — use a CDC replica
- You need the agent to run arbitrary SQL — do not add that here
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
E2B
Using MCP to run code via e2b.