Skip to main content
Glama
IshaanShivalli

college-tools-mcp

College Management AI Assistant (v5)

基于 Google Gemini 和模型上下文协议(Model Context Protocol,MCP)构建的智能高校行政助手。该助手通过结构化的 FastMCP 工具与关系型 SQLite 数据库交互,用来回答有关学生、教师、课程、选课以及学业成绩的问题。


架构概览

+-------------------------------------------------------------+
|                      User / Client                          |
+-------------------------------------------------------------+
                              |
                              v
+-------------------------------------------------------------+
|                   Gemini LLM Assistant                      |
|                         (bot.py)                            |
+-------------------------------------------------------------+
                              |
                     MCP Protocol (stdio)
                              |
                              v
+-------------------------------------------------------------+
|                     FastMCP Server                          |
|                      (tooling.py)                           |
+-------------------------------------------------------------+
                              |
                        SQLite Queries
                              |
                              v
+-------------------------------------------------------------+
|                   College SQLite Database                   |
|                        (college.db)                         |
|   - persons (students, faculty, staff)                      |
|   - courses                                                 |
|   - student_enrollments                                     |
+-------------------------------------------------------------+

Related MCP server: College AI Assistant

功能特性

  • 合成数据生成:使用 Faker 创建真实完整的高校数据,包括学生、教师、课程以及成绩记录。

  • FastMCP 工具:提供健壮、依据 schema 规范的 MCP 工具,用于查询学术记录、课程、院系和选课统计信息。

  • 交互式多轮对话机器人:基于 Google GenAI SDK(google-genai)的聊天气泡,并通过 MCP 自动编排工具调用。

  • 安全配置:基于环境变量的密钥管理,支持 .env 文件。


项目结构

.
├── bot.py                   # Interactive Gemini chatbot integrating MCP tools via stdio
├── tooling.py               # FastMCP Server exposing database querying tools
├── create_data.py           # SQLite database schema initializer & synthetic data generator
├── college.db               # SQLite database file (generated by create_data.py)
├── system_prompt.txt        # System instruction prompt for the AI assistant
├── prompt.txt               # Context and initial project design prompts
├── mcp_config.example.json  # Example configuration for MCP client registration
├── requirements.txt         # Python package dependencies
├── .env                     # Environment variables (GEMINI_API_KEY)
└── .gitignore               # Git ignore file for Python, SQLite, and secrets

数据库结构

SQLite 数据库(college.db)包含以下关系表:

  1. persons:存储学生、教师和职员的用户档案(ID, name, email, phone, DOB, gender, address, role)。

  2. courses:存储课程信息(course ID, code, course name, department, credits, assigned instructor)。

  3. student_enrollments:存储选课记录(enrollment ID, student ID, course ID, date, grade, semester)。


可用的 MCP 工具(tooling.py)

  • get_student_info(student_id_or_name):按 ID、姓名或 email 查找学生档案。

  • get_course_details(course_code_or_name):获取课程详细信息以及授课教师。

  • get_student_enrollments(student_id_or_name):列出某学生的所有课程和成绩。

  • get_students_by_course(course_code_or_name):列出选修某门课程的所有学生。

  • list_courses_by_department(department):列出某个院系的所有全部课程。

  • get_courses_taught_by_faculty(faculty_id_or_name):列出某位教师所教授的所有课程。

  • search_persons(query, role):跨角色(学生、教师、教职工)搜索人员信息。

  • get_course_statistics(course_code_or_name):给出汇总统计(总选课人数、成绩分布)。

  • list_all_courses():提供所有大学课程的完整目录。

  • execute_custom_sql_query(query):供复杂聚合查询的只读 SQL 执行。


设置与安装

1. 前置条件

2. 安装依赖

pip install -r requirements.txt

3. 配置环境变量

在项目的根目录下创建或编辑你的 .env 文件:

GEMINI_API_KEY=your_actual_gemini_api_key_here

4. 生成合成数据

用合成数据初始化数据库:

python create_data.py

使用说明

运行交互式 AI 对话

python bot.py

输入你的学术或行政相关问题(例如,“列出计算机科学系的所有课程” 或 “John Doe 的 ID 是多少?”),输入 exit 或 quit 即可结束会话。

作为 MCP 服务器连接(例如 IDE / Claude Desktop / Antigravity)

可参考 mcp_config.example.json 在 MCP 客户端配置中注册 tooling.py:

{
  "mcpServers": {
    "college-tools-mcp": {
      "command": "python",
      "args": [
        "-Wignore",
        "<FULL_PATH_TO>/tooling.py"
      ]
    }
  }
}

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    C
    maintenance
    Provides MCP tools for searching student profiles, viewing marks/attendance, and finding low-attendance students. Enables AI assistants like Gemini to interact with college student data through natural language.
    -
  • F
    license
    Not graded
    quality
    B
    maintenance
    MCP server exposing a university course catalog with tools for searching courses, looking up prerequisites and instructors, and generating prerequisite graphs, plus resources and a prompt template for AI academic advisors.
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables LLM agents to safely query educational administration databases through read-only MCP tools, enforcing SQL whitelisting, automatic LIMIT caps, parameterized queries, timeouts, token authentication, and audit logging.
    -