Build-a-Model-Context-Protocol-MCP-Server-for-a-University-Course-Catalog
University Course Catalog – MCP Server
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Badge for your README
Markdown
[](/listings/prabhasupriya--build-a-model-context-protocol-mcp-server-for-a-university-course-catalog)HTML
<a href="/listings/prabhasupriya--build-a-model-context-protocol-mcp-server-for-a-university-course-catalog"><img src="/api/listings/prabhasupriya--build-a-model-context-protocol-mcp-server-for-a-university-course-catalog/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
git clone https://github.com/prabhasupriya/Build-a-Model-Context-Protocol-MCP-Server-for-a-University-Course-Catalog.git cd mcp-course-catalog cp .env.example .env # optional – defaults work without it docker-compose up --build
The service becomes healthy within seconds. Then:
| What | URL | |-----------------|------------------------------------| | MCP endpoint | `http://localhost:8080/mcp` | | Health check | `http://localhost:8080/health` |
(`docker compose up` works equally well on newer Docker installs.)
Run without Docker
python -m venv .venv && source .venv/bin/activate pip install -r requirements.txt python -m src.server
Test it
With the server running:
python tests/smoke_test.py # automated end-to-end check of every requirement
npx @modelcontextprotocol/inspector # interactive: connect with transport "Streamable HTTP"
# and URL http://localhost:8080/mcpWhat was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
README.md · README · 151 lines
- # University Course Catalog – MCP Server
- A [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that exposes a university
- course catalog to LLM assistants. Built with the official Python `mcp` SDK (FastMCP), **Pydantic**
- for strict data contracts, **SQLite** for storage, **networkx** for prerequisite graphs, and
- **Docker Compose** for one-command startup.
- ## Features
- - 4 tools: `search_courses`, `get_prerequisites`, `lookup_instructor`, `get_prerequisite_graph`
- - 2 resources: `course_descriptions`, `department_directory`
- - 1 prompt template: `course_comparison_template`
- - Pydantic-validated inputs/outputs and a consistent `{"error": "..."}` error envelope
- - Auto-seeding of the SQLite database on first start
- - `/health` endpoint + Docker health check
- ## Quick start
- ```bash
- git clone https://github.com/prabhasupriya/Build-a-Model-Context-Protocol-MCP-Server-for-a-University-Course-Catalog.git
- cd mcp-course-catalog
- cp .env.example .env # optional – defaults work without it
- docker-compose up --build
- ```
- The service becomes healthy within seconds. Then:
- | What | URL |
- |-----------------|------------------------------------|
- | MCP endpoint | `http://localhost:8080/mcp` |
- | Health check | `http://localhost:8080/health` |
- (`docker compose up` works equally well on newer Docker installs.)
- ### Run without Docker
- ```bash
- python -m venv .venv && source .venv/bin/activate
- pip install -r requirements.txt
- python -m src.server
- ```
- ### Test it
- With the server running:
- ```bash
- python tests/smoke_test.py # automated end-to-end check of every requirement
- npx @modelcontextprotocol/inspector # interactive: connect with transport "Streamable HTTP"
- # and URL http://localhost:8080/mcp
- ```
- ## Configuration
- All variables are documented in [`.env.example`](.env.example).
- | Variable | Default | Purpose |
- |----------------|--------------------------------|-------------------------------------------|
- | `DATABASE_URL` | `sqlite:///./data/catalog.db` | SQLite file location |
- | `HOST` | `0.0.0.0` | Bind address |
- | `PORT` | `8080` | Listening port |
- | `LOG_LEVEL` | `INFO` | Logging verbosity |
- ## Database
- `data/catalog.db` is committed and pre-seeded; `data/seed.py` recreates it
- (`python -m data.seed --force`) and is also run automatically at start-up when the DB is empty.
- `./data` is mounted into the container at `/app/data`, so data persists.
- | Table | Columns |
- |-----------------|--------------------------------------------------------------------------------------|
- | `departments` | `id`, `name`, `code` (unique) |
- | `instructors` | `id`, `name`, `email`, `office`, `department_id` |
- | `courses` | `id`, `course_code` (unique), `title`, `description`, `credits`, `instructor_id`, `department_id` |
- | `prerequisites` | `course_id`, `prerequisite_id` |
- Seed data: 3 departments (CS, MATH, PHYS), 5 instructors, 12 courses, 10 prerequisite links.
- Example multi-level chain: `CS401 ← CS350 ← CS201 ← CS101` (and `CS350 ← MATH201 ← MATH101`).
- ## MCP interface
- ### Tools
- | Tool | Input | Output |
- |------|-------|--------|
- | `search_courses` | `query` (str), `department_code` (str, optional) | `[{"course_code", "title", "credits"}]` – `[]` if no match |
- | `get_prerequisites` | `course_code` (str) | `{"course_code", "prerequisites": [{"course_code", "title"}]}` – direct prerequisites only |
- | `lookup_instructor` | `instructor_name` (str, full or partial) | `{"name", "email", "department_name"}` |
- | `get_prerequisite_graph` | `course_code` (str) | `{"nodes": [{"id"}], "edges": [{"source", "target"}]}` – `source` is a prerequisite of `target` |
- Every tool returns `{"error": "<message>"}` on failure, e.g. `{"error": "Course not found"}` or
- `{"error": "Instructor not found"}`. Tool results are JSON text.
- ### Resources
- | Name | URI | Content |
- |------|-----|---------|
- | `course_descriptions` | `catalog://course_descriptions` | One line per course: `[CS101] Introduction to Programming: …` |
- | `department_directory` | `catalog://department_directory` | One line per department: `Computer Science (CS)` |
- ### Prompt
- `course_comparison_template` – contains the placeholders `{{course_code_1}}` and
- `{{course_code_2}}`. Called without arguments it returns the raw template; with
- `course_code_1` / `course_code_2` arguments it returns the filled-in prompt.
- ## Example natural-language queries
- An LLM connected to this server could handle:
- - "What introductory courses are available?" → `search_courses`
- - "Show me Computer Science courses about databases." → `search_courses` with `department_code="CS"`
- - "What do I need to finish before taking CS301?" → `get_prerequisites`
- - "Give me the complete roadmap of courses leading to Advanced AI." → `get_prerequisite_graph("CS401")`
- - "Who is Dr. Raman and how can I contact her?" → `lookup_instructor`
- - "Compare CS201 and CS301 for me." → `course_comparison_template`
- - "List every department and its code." → `department_directory` resource
- ## Project structure
- ```
- ├── Dockerfile
- ├── docker-compose.yml
- ├── .env.example
- ├── requirements.txt
- ├── data/
- │ ├── catalog.db # seeded SQLite database
- │ └── seed.py # schema + seed data + seeding logic
- ├── src/
- │ ├── server.py # MCP tools, resources, prompt, /health
- │ ├── services.py # catalog queries (parameterised SQL, networkx)
- │ ├── schemas.py # Pydantic models
- │ ├── database.py # connection helper
- │ └── config.py # environment configuration
- └── tests/
- └── smoke_test.py # end-to-end MCP client test
- ```
- ## Design notes
- - **Validation:** inputs are validated with Pydantic (`SearchCoursesInput`, `CourseCodeInput`,
- `LookupInstructorInput`) and outputs are built from Pydantic models before serialisation.
- - **Safety:** all SQL is parameterised – no string interpolation of user input.
- - **Graph logic:** `networkx.ancestors()` returns the entire prerequisite chain; the subgraph is
- emitted as nodes/edges.
- - **Transport:** streamable HTTP, the current MCP standard for remote servers.
- ## youtude video
- [watch here](https://youtu.be/QainaWqNWOc?si=P3UUBb25nQ-naLgY)
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.