Lexiguard HR

Lexiguard HR

Enables Cursor AI to query a local MySQL HR database in natural language using read-only SQL tools.

Category
访问服务器

README

Lexiguard HR — Local MySQL MCP Server for Cursor

A small Model Context Protocol (MCP) demo that lets Cursor query a local MySQL HR database in natural language—without pasting credentials or schema into every chat.

Cursor (AI)  ←── MCP (stdio) ──→  server.py  ←── SQL ──→  MySQL (lexiguard)

What it does

MCP tool Description
get_db_schema Lists tables, columns, types, and keys so the AI knows what exists
query_hr_db Runs read-only SQL (SELECT, SHOW, DESCRIBE, EXPLAIN, WITH) and returns formatted text

Example questions in Cursor chat:

  • “Use get_db_schema to show all tables.”
  • “Who works in Engineering?”
  • “List employees with their department names.”
  • “Average salary by department.”

Tech stack

Prerequisites

Quick start

1. Create database and sample data

In MySQL Workbench or the CLI:

CREATE DATABASE IF NOT EXISTS lexiguard;
USE lexiguard;

CREATE TABLE IF NOT EXISTS departments (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    location VARCHAR(100)
);

CREATE TABLE IF NOT EXISTS employees (
    id INT AUTO_INCREMENT PRIMARY KEY,
    first_name VARCHAR(50) NOT NULL,
    last_name VARCHAR(50) NOT NULL,
    email VARCHAR(100) UNIQUE,
    department_id INT,
    hire_date DATE,
    salary DECIMAL(10, 2),
    FOREIGN KEY (department_id) REFERENCES departments(id)
);

INSERT INTO departments (name, location) VALUES
('Engineering', 'London'),
('HR', 'Manchester'),
('Finance', 'Birmingham');

INSERT INTO employees (first_name, last_name, email, department_id, hire_date, salary) VALUES
('Alice', 'Smith', 'alice.smith@lexiguard.com', 1, '2022-03-15', 65000.00),
('Bob', 'Jones', 'bob.jones@lexiguard.com', 1, '2021-07-01', 72000.00),
('Carol', 'Brown', 'carol.brown@lexiguard.com', 2, '2020-11-20', 48000.00),
('David', 'Taylor', 'david.taylor@lexiguard.com', 3, '2023-01-10', 55000.00);

2. Install Python dependencies

Windows (PowerShell):

cd db-mcp-server
python -m venv .venv
.\.venv\Scripts\pip install -r requirements.txt

macOS / Linux:

cd db-mcp-server
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

3. Configure environment

cp .env.example .env

Edit .env with your MySQL settings (especially MYSQL_PASSWORD if root has a password).

4. Connect Cursor

This repo includes project-level MCP config at .cursor/mcp.json.

  1. Open this folder as a Cursor workspace.
  2. Go to Cursor Settings → Models → MCP.
  3. Enable lexiguard-hr (should show 2 tools).
  4. Restart Cursor if the server does not appear.

macOS / Linux: Update .cursor/mcp.json so command points to your venv Python, for example:

"command": "${workspaceFolder}/.venv/bin/python"

Windows (default in this repo):

"command": "${workspaceFolder}/.venv/Scripts/python.exe"

Credentials are loaded from .env via envFile—do not commit .env (it is in .gitignore).

5. Try it

Open chat (Ctrl+L / Cmd+L), use Agent mode, and allow MCP tool runs when prompted.

Project layout

db-mcp-server/
├── .cursor/
│   └── mcp.json          # Cursor MCP launch config
├── server.py             # MCP server (FastMCP + MySQL)
├── requirements.txt
├── .env.example          # Copy to .env locally
├── .gitignore
├── README.md             # This file (demo / setup)
└── MCP-HOW-IT-WORKS.md   # Short technical notes on MCP

Security notes

  • Read-only queries only in query_hr_db (no INSERT / UPDATE / DELETE).
  • Keep .env local; use .env.example as a template for collaborators.
  • Intended for local development demos, not production exposure of a database.

Troubleshooting

Issue What to check
MCP server red / disconnected MySQL running; .env password correct; re-run pip install
“Connection refused” Start MySQL service; confirm MYSQL_HOST / MYSQL_PORT
Tools not listed Reopen project folder; toggle MCP server; restart Cursor
GitKraken MCP error Unrelated third-party config in global ~/.cursor/mcp.json

Learn more

See MCP-HOW-IT-WORKS.md for a concise technical explanation of MCP and how this repo implements it.

License

Use and adapt freely for learning and demos.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选