Module 11 – Integrating Analytics & Department-Wide Dashboards Using MCP
This module focuses on adding analytics and dashboards inside the Attendance Tracking System using Model Context Protocol (MCP). We will add department-level statistics, staff performance summaries, student attendance insights, and semester‑wise overview screens.
✔ Step 1 – Define Analytics Endpoints
Create a new MCP tool file analytics.py:
from mcp import register_tool
from database import db
@register_tool
async def department_attendance_summary(dept_id: int):
result = db.fetch("""
SELECT semester, AVG(attendance) AS avg_attendance
FROM attendance_summary
WHERE dept_id = ?
GROUP BY semester;
""", (dept_id,))
return result
@register_tool
async def staff_teaching_load(staff_id: int):
result = db.fetch("""
SELECT subject_name, total_hours
FROM staff_load
WHERE staff_id = ?;
""", (staff_id,))
return result
✔ Step 2 – Add Dashboard UI Template
Department Dashboard
✔ Step 3 – Connect MCP Tools to the UI
async function loadDashboard() {
const semSummary = await mcp.call("department_attendance_summary", { dept_id: 3 });
const staff = await mcp.call("staff_teaching_load", { staff_id: 12 });
document.getElementById("sem-summary").innerHTML = JSON.stringify(semSummary, null, 2);
document.getElementById("staff-load").innerHTML = JSON.stringify(staff, null, 2);
}
loadDashboard();
✔ Step 4 – Add Charts for Visualization
const ctx = document.getElementById('attendanceChart').getContext('2d');
new Chart(ctx, {
type: 'bar',
data: {
labels: semesters,
datasets: [{ label: 'Attendance %', data: values }]
}
});
✔ Step 5 – Real-Life Example
Assume:
- 2 Courses
- 12 Semesters total
- 14 Staff
- 6 Subjects/Semester
- 60 Students/Semester
MCP analytics allow department head to check:
- Semester‑wise attendance of each course
- Staff workload distribution
- Students with attendance shortage
- Weekly subject hour utilization (40 hours/week)
No comments:
Post a Comment