Skip to content
Back to search

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
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/prabhasupriya--build-a-model-context-protocol-mcp-server-for-a-university-course-catalog/badge.svg)](/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

i

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/mcp

What 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
  1. # University Course Catalog – MCP Server
  2. A [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that exposes a university
  3. course catalog to LLM assistants. Built with the official Python `mcp` SDK (FastMCP), **Pydantic**
  4. for strict data contracts, **SQLite** for storage, **networkx** for prerequisite graphs, and
  5. **Docker Compose** for one-command startup.
  6. ## Features
  7. - 4 tools: `search_courses`, `get_prerequisites`, `lookup_instructor`, `get_prerequisite_graph`
  8. - 2 resources: `course_descriptions`, `department_directory`
  9. - 1 prompt template: `course_comparison_template`
  10. - Pydantic-validated inputs/outputs and a consistent `{"error": "..."}` error envelope
  11. - Auto-seeding of the SQLite database on first start
  12. - `/health` endpoint + Docker health check
  13. ## Quick start
  14. ```bash
  15. git clone https://github.com/prabhasupriya/Build-a-Model-Context-Protocol-MCP-Server-for-a-University-Course-Catalog.git
  16. cd mcp-course-catalog
  17. cp .env.example .env # optional – defaults work without it
  18. docker-compose up --build
  19. ```
  20. The service becomes healthy within seconds. Then:
  21. | What | URL |
  22. |-----------------|------------------------------------|
  23. | MCP endpoint | `http://localhost:8080/mcp` |
  24. | Health check | `http://localhost:8080/health` |
  25. (`docker compose up` works equally well on newer Docker installs.)
  26. ### Run without Docker
  27. ```bash
  28. python -m venv .venv && source .venv/bin/activate
  29. pip install -r requirements.txt
  30. python -m src.server
  31. ```
  32. ### Test it
  33. With the server running:
  34. ```bash
  35. python tests/smoke_test.py # automated end-to-end check of every requirement
  36. npx @modelcontextprotocol/inspector # interactive: connect with transport "Streamable HTTP"
  37. # and URL http://localhost:8080/mcp
  38. ```
  39. ## Configuration
  40. All variables are documented in [`.env.example`](.env.example).
  41. | Variable | Default | Purpose |
  42. |----------------|--------------------------------|-------------------------------------------|
  43. | `DATABASE_URL` | `sqlite:///./data/catalog.db` | SQLite file location |
  44. | `HOST` | `0.0.0.0` | Bind address |
  45. | `PORT` | `8080` | Listening port |
  46. | `LOG_LEVEL` | `INFO` | Logging verbosity |
  47. ## Database
  48. `data/catalog.db` is committed and pre-seeded; `data/seed.py` recreates it
  49. (`python -m data.seed --force`) and is also run automatically at start-up when the DB is empty.
  50. `./data` is mounted into the container at `/app/data`, so data persists.
  51. | Table | Columns |
  52. |-----------------|--------------------------------------------------------------------------------------|
  53. | `departments` | `id`, `name`, `code` (unique) |
  54. | `instructors` | `id`, `name`, `email`, `office`, `department_id` |
  55. | `courses` | `id`, `course_code` (unique), `title`, `description`, `credits`, `instructor_id`, `department_id` |
  56. | `prerequisites` | `course_id`, `prerequisite_id` |
  57. Seed data: 3 departments (CS, MATH, PHYS), 5 instructors, 12 courses, 10 prerequisite links.
  58. Example multi-level chain: `CS401 ← CS350 ← CS201 ← CS101` (and `CS350 ← MATH201 ← MATH101`).
  59. ## MCP interface
  60. ### Tools
  61. | Tool | Input | Output |
  62. |------|-------|--------|
  63. | `search_courses` | `query` (str), `department_code` (str, optional) | `[{"course_code", "title", "credits"}]` – `[]` if no match |
  64. | `get_prerequisites` | `course_code` (str) | `{"course_code", "prerequisites": [{"course_code", "title"}]}` – direct prerequisites only |
  65. | `lookup_instructor` | `instructor_name` (str, full or partial) | `{"name", "email", "department_name"}` |
  66. | `get_prerequisite_graph` | `course_code` (str) | `{"nodes": [{"id"}], "edges": [{"source", "target"}]}` – `source` is a prerequisite of `target` |
  67. Every tool returns `{"error": "<message>"}` on failure, e.g. `{"error": "Course not found"}` or
  68. `{"error": "Instructor not found"}`. Tool results are JSON text.
  69. ### Resources
  70. | Name | URI | Content |
  71. |------|-----|---------|
  72. | `course_descriptions` | `catalog://course_descriptions` | One line per course: `[CS101] Introduction to Programming: …` |
  73. | `department_directory` | `catalog://department_directory` | One line per department: `Computer Science (CS)` |
  74. ### Prompt
  75. `course_comparison_template` – contains the placeholders `{{course_code_1}}` and
  76. `{{course_code_2}}`. Called without arguments it returns the raw template; with
  77. `course_code_1` / `course_code_2` arguments it returns the filled-in prompt.
  78. ## Example natural-language queries
  79. An LLM connected to this server could handle:
  80. - "What introductory courses are available?" → `search_courses`
  81. - "Show me Computer Science courses about databases." → `search_courses` with `department_code="CS"`
  82. - "What do I need to finish before taking CS301?" → `get_prerequisites`
  83. - "Give me the complete roadmap of courses leading to Advanced AI." → `get_prerequisite_graph("CS401")`
  84. - "Who is Dr. Raman and how can I contact her?" → `lookup_instructor`
  85. - "Compare CS201 and CS301 for me." → `course_comparison_template`
  86. - "List every department and its code." → `department_directory` resource
  87. ## Project structure
  88. ```
  89. ├── Dockerfile
  90. ├── docker-compose.yml
  91. ├── .env.example
  92. ├── requirements.txt
  93. ├── data/
  94. │ ├── catalog.db # seeded SQLite database
  95. │ └── seed.py # schema + seed data + seeding logic
  96. ├── src/
  97. │ ├── server.py # MCP tools, resources, prompt, /health
  98. │ ├── services.py # catalog queries (parameterised SQL, networkx)
  99. │ ├── schemas.py # Pydantic models
  100. │ ├── database.py # connection helper
  101. │ └── config.py # environment configuration
  102. └── tests/
  103. └── smoke_test.py # end-to-end MCP client test
  104. ```
  105. ## Design notes
  106. - **Validation:** inputs are validated with Pydantic (`SearchCoursesInput`, `CourseCodeInput`,
  107. `LookupInstructorInput`) and outputs are built from Pydantic models before serialisation.
  108. - **Safety:** all SQL is parameterised – no string interpolation of user input.
  109. - **Graph logic:** `networkx.ancestors()` returns the entire prerequisite chain; the subgraph is
  110. emitted as nodes/edges.
  111. - **Transport:** streamable HTTP, the current MCP standard for remote servers.
  112. ## youtude video
  113. [watch here](https://youtu.be/QainaWqNWOc?si=P3UUBb25nQ-naLgY)

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.