MCP Student Assistant
by Nishchitha98
README.md
# š MCP Student Assistant
An AI-powered **Student Assistant** built with the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/). It exposes a set of student-focused tools ā attendance lookup, marks calculator, notes search, college rules, and a math calculator ā through an MCP server, with a companion CLI client powered by **Groq's Llama 3.3 70B** for natural-language interaction.
---
## ⨠Features
| Tool | Description |
|---|---|
| **Calculator** | Evaluate arbitrary math expressions (e.g. `45*12+5`) |
| **Attendance** | Look up a student's attendance record from `attendance.csv` |
| **Marks** | Compute a student's average across Math, Physics, Chemistry, Java & Python |
| **Notes Search** | Search for keywords inside `notes.pdf` |
| **College Rules** | Display all college rules from `rules.txt` |
For questions that don't match any tool, the client falls back to **Groq's Llama 3.3 70B** model for general-purpose answers.
---
## š Project Structure
```
MCP/
āāā server.py # MCP server ā registers all tools
āāā client.py # CLI client ā keyword routing + Groq fallback
āāā attendance.py # Attendance lookup (pandas + CSV)
āāā marks.py # Average marks calculator (pandas + CSV)
āāā notes.py # Keyword search across PDF notes
āāā pdf_reader.py # PDF text extraction (pypdf)
āāā calculator.py # Simple eval-based calculator
āāā rules.py # Reads college rules from a text file
āāā requirements.txt # Python dependencies
āāā .env # Environment variables (GROQ_API_KEY)
āāā data/
āāā attendance.csv # Student attendance records
āāā marks.csv # Student marks (5 subjects)
āāā notes.pdf # Course notes (PDF)
āāā notes.txt # Course notes (plain text)
āāā rules.txt # College rules
āāā students.csv # Student roster
```
---
## š Getting Started
### Prerequisites
- **Python 3.10+**
- A [Groq API key](https://console.groq.com/) (free tier available)
### 1. Clone the repository
```bash
git clone <repo-url>
cd MCP
```
### 2. Create a virtual environment (recommended)
```bash
python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
source venv/bin/activate
```
### 3. Install dependencies
```bash
pip install -r requirements.txt
```
### 4. Configure environment variables
Create a `.env` file in the project root (one is already included):
```env
GROQ_API_KEY=your_groq_api_key_here
```
### 5. Run the application
**Option A ā MCP Server** (exposes tools over the MCP protocol):
```bash
python server.py
```
**Option B ā CLI Client** (interactive chat with keyword routing + Groq fallback):
```bash
python client.py
```
---
## š¬ Usage Examples
```
Ask : What is Rahul's attendance?
ā {'Name': 'Rahul', 'Days_Present': 42, 'Total_Days': 50, ...}
Ask : Show me Priya's average marks
ā Average = 82.4
Ask : What are the college rules?
ā (displays all rules from rules.txt)
Ask : Search notes for machine learning
Keyword : machine learning
ā (matching lines from notes.pdf)
Ask : Calculate 25+50*2
ā 125
Ask : What is the capital of France?
ā (answered by Groq Llama 3.3 70B)
Ask : exit
ā (exits the program)
```
---
## š ļø Tech Stack
- **[MCP (Model Context Protocol)](https://modelcontextprotocol.io/)** ā tool registration & server
- **[Groq](https://groq.com/)** ā LLM inference (Llama 3.3 70B)
- **[pandas](https://pandas.pydata.org/)** ā CSV data processing
- **[pypdf](https://pypdf.readthedocs.io/)** ā PDF text extraction
- **[python-dotenv](https://pypi.org/project/python-dotenv/)** ā environment variable management
---
## š License
This project is for educational purposes.
This server cannot be deployed
Maintenance
ActivitySlowing
ResponsivenessNo issues