Skip to main content
Glama
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.