Skip to main content
Glama
Vanity-1

edu-db-readonly-mcp

by Vanity-1

Edu DB Readonly MCP — Education Administration Read-Only Database Gateway

Python 3.10+ MCP FastMCP

A secure read-only query gateway MCP for education administration business databases. Using the official FastMCP SDK, it exposes the "administration database (students / courses / grades / enrollments)" as a set of MCP tools, allowing LLM Agents to safely query business data while prohibiting all write operations from the protocol layer down to the database layer.

Unlike ChatGPT wrappers, generic MCP Servers, or pure RAG demos, this project focuses on the engineering pipeline of "safely opening business databases to Agents for reading" — a hardcore case of data security + MCP implementation.


Core Selling Points (Interview-Ready)

Security Dimension

Implementation

Write Protection

Static SQL lexical validation: only SELECT/WITH allowed; blocks INSERT/UPDATE/DELETE/DROP/PRAGMA; prohibits semicolon multi-statement injection

Read-Only Fallback

SQLite opened with mode=ro, so even if SQL slips through validation, nothing can be written at the database level

Anti-Dump Protection

Missing LIMIT automatically forces an upper bound (default 100 rows), preventing Agents from dumping entire tables

Injection Prevention

The gateway layer uses parameter binding exclusively; business tools use fixed query whitelist functions, naturally immune to concatenation injection

Timeout Protection

Slow queries exceeding the threshold (default 3s) are automatically terminated, preventing clever Agents from hanging

Authentication

Optional READONLY_GATEWAY_TOKEN; mismatched tokens are rejected outright

Auditing

Every query is written to audit.log (timestamp/tool/SQL/row count/duration), making calls traceable


Related MCP server: sql-safety-executor

Tool List (MCP)

Tool

Description

list_tables

Lists all business tables and row counts

describe_table

Returns fields / types / primary keys for a given table

query

Raw read-only SQL gateway (security validation + LIMIT + timeout)

get_student_profile

Student profile (basic info + average score + enrollment grade details)

get_course_stats

Course enrollment / average score / max-min / pass rate

get_enrollment_summary

Enrollment grade summary report, filterable by year / term

query demonstrates the "raw SQL gateway" capability; the rest are industry-specific secure wrapper functions for administration (fixed parameterized queries, safer and more business-aligned than raw SQL).


Quick Start

# 1. 安装依赖
pip install -r requirements.txt

# 2. 初始化教务演示库
python scripts/init_db.py

# 3. 运行命令行演示(连 stdio MCP,展示 6 个工具 + 写操作被拦截)
python scripts/demo_client.py

# 4. 启动为 MCP Server(供 Claude / Cursor / 任意 MCP 客户端接入)
python -m src.server
# 开启鉴权:
#   READONLY_GATEWAY_TOKEN=your_secret python -m src.server

Example queries: student profile, CS205 course statistics, summary by term...


Testing

pytest tests/            # 22 个用例:写防护/注入/多语句/截断/工具行为/审计

Directory Structure

edu-db-readonly-mcp/
├── README.md
├── pyproject.toml
├── requirements.txt
├── data/edu.db                 # 生成的教务演示库(只读打开)
├── scripts/
│   ├── init_db.py              # 建表 + 造种子数据(10学生/10课/32选课)
│   └── demo_client.py          # 命令行 MCP 演示
├── src/
│   ├── server.py               # FastMCP 入口,注册 6 个工具
│   ├── gateway/
│   │   ├── readonly_gateway.py # 核心:SQL 只读校验 + LIMIT + 超时
│   │   ├── auth.py             # token 鉴权
│   │   └── audit.py            # 审计日志
│   ├── db/connection.py        # mode=ro 连接 + 元数据读取
│   └── tools/
│       ├── query_tool.py       # 原始 SQL 网关
│       ├── schema_tools.py     # list_tables / describe_table
│       └── edu_workflows.py    # 教务业务封装工具
└── tests/
    ├── test_gateway_security.py   # 安全用例
    └── test_tools.py              # 工具行为用例

Design document → docs/DESIGN.md


Resume Description (Copy-Paste Ready)

Education Administration Read-Only Database Gateway MCP (FastMCP) Independently developed a secure read-only MCP Server for education administration databases. Designed a lightweight SQL read-only gateway: static validation that only allows SELECT/WITH to block DML/DDL and semicolon multi-statement injection, automatic row limiting when LIMIT is missing, parameterized queries for injection prevention, thread timeout protection, and SQLite mode=ro read-only fallback; provided table introspection and administration business wrapper tools with Token authentication and audit.log auditing. 22 unit tests cover security scenarios including write protection, injection, multi-statement, and truncation; end-to-end demo verifies write operations are blocked at the protocol layer.

F
license - not found
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    Provides a read-only PostgreSQL SQL surface for LLM agents via MCP, with defense-in-depth security layers for safe database queries.
    3
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables LLMs to safely execute database queries via MCP tools, with security features including query restrictions, truncation, and timeout.
    6
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Provides read-only access to databases for MCP-compatible AI tools, allowing schema exploration and SELECT queries without exposing credentials or risking data changes.
    92
    3
    MIT

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Vanity-1/edu-db-readonly-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server