How msr327/iitkgp-erp-mcp works
Purpose and Entry Points
This package exposes IIT Kharagpur ERP data and workflows as a local MCP server for AI-agent clients. The primary runtime entry point is src/server.py; installation/setup behavior is defined through pyproject.toml and src/setup.py. MCP communication is local stdio, while ERP interaction targets erp.iitkgp.ac.in.
MCP Tool Boundary
src/server.py is the orchestration boundary between MCP tool calls and ERP-backed operations. It presents tools for grades/GPA analysis, attendance decisions, elective recommendations, timetable/calendar use, notices/placements, and freeform ERP navigation. Tool handlers should remain responsible for input validation, session requirements, and formatting agent-facing results, delegating ERP retrieval to scraper modules.
Authentication and Session Lifecycle
Authentication is isolated under src/auth/login.py and src/auth/credentials.py. Setup stores credentials in the OS keychain; login handles live OTP without persistence. An authenticated ERP session is then consumed by scraper operations, and logout terminates it. This is the main security boundary: credentials and OTP remain local, while only authenticated requests/browser activity reach the ERP.
ERP Retrieval Layer
The scraper package encapsulates ERP page navigation, HTTP extraction, and HTML parsing. Domain-specific modules include src/scrapers/grades.py, src/scrapers/attendance.py, src/scrapers/timetable.py, src/scrapers/electives.py, src/scrapers/placements.py, src/scrapers/notices.py, and src/scrapers/registration.py. These modules form the volatile integration boundary because ERP selector and page-layout changes should be contained here.
Browser and Transport Strategy
src/scrapers/browser.py provides the browser automation path for JavaScript-heavy or interactive ERP pages, using Playwright Chromium. Conventional retrieval uses requests plus BeautifulSoup according to the documented architecture. The server/selectors should choose the least expensive mechanism: direct parsed requests for stable content, browser automation for rendered pages or interactive exploration.
Derived Academic and Scheduling Features
Retrieved grade records feed server-level calculations such as CGPA/SGPA, trends, comparisons, projections, grade distributions, and elective recommendations. Attendance records drive alerts and “can I skip” calculations. Timetable data supports day filtering, professor lookup, and ICS calendar export. These are local transformations over scraper output rather than separate remote services; their public behavior is surfaced through src/server.py and sourced mainly from src/scrapers/grades.py, src/scrapers/attendance.py, and src/scrapers/timetable.py.
Local State and Operations
src/utils/cache.py owns locally cached ERP-derived data, reducing repeated authenticated retrieval and providing the clear-cache capability. Environment-sensitive values are represented by .env.example; credentials are explicitly not committed. Runtime dependencies materially include Python, MCP-compatible clients, OS keychain support, requests/BeautifulSoup, and Playwright Chromium.
Main entry points: server.py MCP tool server · login.py Login & session · grades.py Grades retrieval · attendance.py Attendance retrieval
Components 17
MCP Server
- MCP tool server · Validates tool inputs, manages sessions, and formats agent results.
src/server.py - Install & setup · Defines installation and setup behavior.
pyproject.toml - Academic & schedule analysis · Calculates GPA, attendance decisions, recommendations, and calendar output.
src/server.py
Authentication
Local credential handling and authenticated ERP sessions.
- Credential setup · Stores credentials in the OS keychain.
src/setup.py - Credential store · Keeps ERP credentials local in the OS keychain.
src/auth/credentials.py - Login & session · Handles live OTP and authenticated session lifecycle.
src/auth/login.py
ERP Retrieval
Volatile ERP navigation and parsing boundary.
- Grades retrieval
src/scrapers/grades.py - Attendance retrieval
src/scrapers/attendance.py - Timetable retrieval
src/scrapers/timetable.py - Electives retrieval
src/scrapers/electives.py - Notices & placements
src/scrapers/notices.py - Registration retrieval
src/scrapers/registration.py - Browser automation · Used for rendered or interactive ERP pages.
src/scrapers/browser.py
Local State
- ERP cache · Caches ERP-derived data and supports clearing it.
src/utils/cache.py - Environment template · Documents environment-sensitive values without committed credentials.
.env.example
External Systems
- AI-agent client
- IITKGP ERP · Authenticated ERP site at erp.iitkgp.ac.in.
Connections 26
- AI-agent client → MCP tool server: local stdio MCP
- Install & setup → Credential setup: installs setup flow
- Credential setup → Credential store: stores credentials
- Environment template → MCP tool server: runtime values
- MCP tool server → Login & session: requires session
- Login & session → Credential store: reads credentials
- Login & session → IITKGP ERP: OTP login / logout
- MCP tool server → ERP cache: reads and clears
- MCP tool server → Grades retrieval: grade tools
- MCP tool server → Attendance retrieval: attendance tools
- MCP tool server → Timetable retrieval: timetable & calendar tools
- MCP tool server → Electives retrieval: recommendation data
- MCP tool server → Notices & placements: notices & placements
- MCP tool server → Registration retrieval: ERP navigation
- Grades retrieval → Academic & schedule analysis: grade records
- Attendance retrieval → Academic & schedule analysis: attendance records
- Timetable retrieval → Academic & schedule analysis: schedule records
- Academic & schedule analysis → MCP tool server: agent-facing results
- Grades retrieval → Login & session: uses session
- Attendance retrieval → Login & session: uses session
- Timetable retrieval → Login & session: uses session
- Grades retrieval → IITKGP ERP: parsed requests
- Attendance retrieval → IITKGP ERP: parsed requests
- Timetable retrieval → IITKGP ERP: parsed requests
- Browser automation → IITKGP ERP: interactive pages
- MCP tool server → Browser automation: rendered-page fallback