MCP Demo — GitHub Copilot + Your Database

MCP Demo — GitHub Copilot + Your Database

An MCP server that enables AI assistants to query and interact with SQLite databases through natural language. It includes built-in security guardrails such as PII redaction, SQL injection blocking, and query rate limiting.

Category
访问服务器

README

MCP Demo — GitHub Copilot + Your Database

What if you could ask Copilot a question and it queried your database to answer it? That's what this demo shows. Clone it, run two commands, and watch it work.


What is MCP?

Model Context Protocol (MCP) is an open standard that lets AI assistants like GitHub Copilot connect directly to your tools and data — in real time, with guardrails you control.

Instead of copy-pasting data into chat, Copilot just asks your server:

You type in Copilot Chat What happens
What tables are in the database? Copilot calls get_schema, returns your full schema
Show me all products under $200 Copilot writes and runs the SQL query live
Which users have the admin role? Instant answer — emails auto-redacted

MCP isn't AI-only. The same server can be called by scripts, pipelines, or any client. The LLM is just the first killer app.


See It In Action

Real responses from this running server:

"Show me all products under $200"

Product Price Stock
Wireless Mouse $49.99 120
USB-C Hub $79.99 60
External SSD (1TB) $129.99 35
Mechanical Keyboard $149.99 45
Webcam (4K) $199.99 12

Guardrail in action — PII is auto-redacted:

{
  "rows": [{"id": 1, "name": "Alice Johnson", "email": "[REDACTED]", "role": "admin"}],
  "pii_notice": "The following field(s) were redacted to protect PII: email"
}

Dangerous query? Blocked before it touches the database:

{ "success": false, "error": "Query contains a blocked pattern and was rejected for security reasons." }

Get Running in 3 Steps

Prerequisites: Python 3.12+, VS Code, GitHub Copilot extension

# 1. Install
git clone https://github.com/coderkanasu/mcp-demo && cd mcp-demo
pip install -r requirements.txt   # simple install
# or: pip install -e .            # editable install (for development)

# 2. Set up the database
python mcp_server/db/init_db.py

# 3. Verify it works
python mcp_server/tools/sql_query_tool.py

Connect to Copilot: A .vscode/mcp.json is already included — open this repo in VS Code and Copilot Agent mode picks it up automatically. No manual config needed.

{
  "servers": {
    "demo-sql-server": {
      "type": "stdio",
      "command": "python3",
      "args": ["-m", "mcp_server.server"],
      "env": { "PYTHONPATH": "${workspaceFolder}" }
    }
  }
}

Then open Copilot Chat → Agent mode and start asking questions.


Built-in Guardrails

This is a demo — but it ships with real security controls, not placeholders:

Guardrail Detail
PII auto-redaction email, phone, address, password, and 9 other field patterns scrubbed from all results
SQL injection blocking 17 patterns blocked: UNION SELECT, OR 1=1, stacked queries, DROP, -- comments, and more
Allowed operations only SELECT, INSERT, UPDATE only — DROP, DELETE, TRUNCATE rejected
Row cap 100 rows max per query — prevents bulk extraction
Rate limiting 30 calls per 60-second window
Audit logging Every query logged with timestamp and outcome
Sanitised errors Stack traces never returned to the LLM

Not included (needed for production): user authentication, role-based access control, write-operation approval gates. See PRODUCTION_READINESS.md.


What's Inside

mcp_server/
├── server.py               # MCP server — rate limiting, routing, error handling
├── tools/
│   └── sql_query_tool.py   # PII scrubbing, injection blocking, query execution
└── db/
    ├── init_db.py          # Seeds sample e-commerce data
    └── demo.db             # SQLite database (users, products, orders)
.vscode/
└── mcp.json                # Plug-and-play Copilot config
requirements.txt            # pip install -r requirements.txt
pyproject.toml              # package metadata + dev dependencies

How It Works

You (Copilot Chat)
      │  "Show me all products under $200"
      ▼
GitHub Copilot (Agent mode)
      │  calls get_schema, then execute_query
      ▼
MCP Server  ←── validates, rate-limits, scrubs PII
      │
      ▼
SQLite Database  ←── returns rows
      │
      ▼
Copilot formats and presents the answer

Want to extend it?

  • Add a new tool: create a class in mcp_server/tools/, register it in server.py
  • Use a real database: swap SQLite for PostgreSQL/MySQL in sql_query_tool.py
  • Add auth: wrap execute_query with a token check

Requirements

  • Python 3.12+
  • VS Code with GitHub Copilot (Agent mode)
  • macOS / Linux / Windows

License

MIT — free to use, fork, and adapt.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选