diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c71452a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: CI + +on: + push: + pull_request: + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.11", "3.12"] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: pip + - run: pip install -r requirements-dev.txt + - run: pytest -q + - run: python -m compileall -q mcp_server.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..887bd7d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.venv/ +__pycache__/ +*.py[cod] +.pytest_cache/ diff --git a/INTEGRATIONS.md b/INTEGRATIONS.md index 6a531c5..c39e326 100644 --- a/INTEGRATIONS.md +++ b/INTEGRATIONS.md @@ -225,7 +225,7 @@ Create `/path/to/mcp_server.py`: #!/usr/bin/env python3 """ Machine Learning Systems โ€” MCP Server -Exposes the complete textbook (44 chapters, 111 definitions, 820 artifacts) +Exposes the reference corpus (44 chapter files, 111 definitions, 816 indexed artifacts) as MCP tools, resources, and prompts. """ @@ -265,7 +265,7 @@ def glossary() -> str: @mcp.resource("ml-systems://patterns") def patterns() -> str: - """All 820 artifacts across 8 categories.""" + """All 816 indexed artifacts across 8 categories.""" return (CHAPTERS_DIR / "patterns.md").read_text() @mcp.resource("ml-systems://cheatsheet") @@ -472,7 +472,7 @@ fastmcp install claude-desktop mcp_server.py |----------|-----|---------| | Chapter Index | `ml-systems://index` | All 44 chapters metadata | | Glossary | `ml-systems://glossary` | 111 definitions | -| Patterns | `ml-systems://patterns` | 820 artifacts | +| Patterns | `ml-systems://patterns` | 816 indexed artifacts | | Cheatsheet | `ml-systems://cheatsheet` | Formulas, rules | | Prompt | Use Case | @@ -507,4 +507,4 @@ fastmcp install claude-desktop mcp_server.py ## ๐Ÿ“š Source Attribution -All content sourced from **"Machine Learning Systems"** by **Professor Vijay Janapa Reddi** (Harvard SEAS), course **CS 249r**, open-source at **[mlsysbook.ai](https://mlsysbook.ai/)** (CC BY-NC-SA 4.0). Plugin extraction and MCP server are MIT-licensed. \ No newline at end of file +The reference content is adapted from **"Machine Learning Systems"** by **Professor Vijay Janapa Reddi** (Harvard SEAS), course **CS 249r**, at **[mlsysbook.ai](https://mlsysbook.ai/)**. This redistributed/adapted package, including its plugin and MCP integration, is licensed under CC BY-NC-SA 4.0; third-party dependencies retain their own licenses. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f72ec30 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International + +This repository is a derivative of "Machine Learning Systems" by Vijay +Janapa Reddi, available at https://mlsysbook.ai/ and licensed under +CC BY-NC-SA 4.0. + +Repository-specific organization, indexes, MCP server, metadata, and tests: +Copyright (c) 2026 Collins Nyagaka. + +SPDX-License-Identifier: CC-BY-NC-SA-4.0 + +License summary: https://creativecommons.org/licenses/by-nc-sa/4.0/ +Legal code: https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode diff --git a/README.md b/README.md index f8330f2..91c8e86 100644 --- a/README.md +++ b/README.md @@ -1,261 +1,67 @@ -# Machine Learning Systems Plugin +# Machine Learning Systems Reference Plugin -[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -[![Plugin Version](https://img.shields.io/badge/version-1.1.0-blue.svg)]() -[![Chapters](https://img.shields.io/badge/chapters-44-brightgreen.svg)]() -[![Artifacts](https://img.shields.io/badge/named_artifacts-820-orange.svg)]() +[![License: CC BY-NC-SA 4.0](https://img.shields.io/badge/License-CC_BY--NC--SA_4.0-lightgrey.svg)](LICENSE) +[![CI](https://github.com/CollinsNyatundo/machine-learning-systems-plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/CollinsNyatundo/machine-learning-systems-plugin/actions/workflows/ci.yml) -A comprehensive study and reference plugin for **"Machine Learning Systems"** โ€” the open-source textbook by **Professor Vijay Janapa Reddi** ([Harvard SEAS](https://vijay.seas.harvard.edu/)), covering the principles and practices of engineering artificially intelligent systems. +A searchable study and reference package derived from Vijay Janapa Reddi's open textbook, [Machine Learning Systems](https://mlsysbook.ai/). It exposes the material as Markdown and through a small FastMCP server. -Based on the [CS 249r course](https://github.com/harvard-edge/cs249r_book) and the official textbook at **[mlsysbook.ai](https://mlsysbook.ai/)**. +This repository is an independently organized derivative reference. It is not the original textbook, an official Harvard project, or an operational MLOps platform. ---- +## Contents -## ๐Ÿ“š About the Source Material +- 44 chapter and appendix files across two volumes +- 111 glossary entries +- 816 indexed learning artifacts +- A formulas-and-concepts cheatsheet +- FastMCP resources and tools for search and retrieval -| Volume | Title | Focus | Chapters | -|--------|-------|-------|----------| -| **Vol 1** | Introduction to Machine Learning Systems | Foundations, single-machine ML, data engineering, training, serving | 16 + 5 appendices | -| **Vol 2** | Machine Learning Systems at Scale | Distributed training, fleet orchestration, inference at scale, governance | 18 + 6 appendices | +## Run locally -**Author**: Professor Vijay Janapa Reddi, Harvard John A. Paulson School of Engineering and Applied Sciences -**Course**: CS 249r โ€” Machine Learning Systems -**License**: The textbook is open-source (CC BY-NC-SA 4.0). This plugin is MIT-licensed for the extracted reference format. - ---- - -## ๐Ÿ“ฆ What's Included - -### 44 Chapter Files (Complete Textbook Content) -``` -Vol 1 โ€” Foundations (21 files) -โ”œโ”€โ”€ ch01.md โ€” Introduction to ML Systems -โ”œโ”€โ”€ ch02.md โ€” Compute Infrastructure -โ”œโ”€โ”€ ch03.md โ€” Neural Computation -โ”œโ”€โ”€ ch04.md โ€” Data Engineering & Pipeline Architecture -โ”œโ”€โ”€ ch05.md โ€” Network Architectures -โ”œโ”€โ”€ ch06.md โ€” ML Frameworks -โ”œโ”€โ”€ ch07.md โ€” Model Training -โ”œโ”€โ”€ ch08.md โ€” Data Selection & Efficient Training -โ”œโ”€โ”€ ch09.md โ€” Model Compression -โ”œโ”€โ”€ ch10.md โ€” Benchmarking & Profiling -โ”œโ”€โ”€ ch11.md โ€” Hardware Acceleration -โ”œโ”€โ”€ ch12.md โ€” ML Operations -โ”œโ”€โ”€ ch13.md โ€” Model Serving -โ”œโ”€โ”€ ch14.md โ€” Responsible Engineering -โ”œโ”€โ”€ ch15.md โ€” Sustainable AI -โ”œโ”€โ”€ ch16.md โ€” Conclusion -โ”œโ”€โ”€ appA.md โ€” DยทAยทM Taxonomy -โ”œโ”€โ”€ appB.md โ€” Data Foundations -โ”œโ”€โ”€ appC.md โ€” Algorithm Foundations -โ”œโ”€โ”€ appD.md โ€” Machine Foundations -โ””โ”€โ”€ appE.md โ€” System Assumptions - -Vol 2 โ€” Distribution, Serving & Governance (23 files) -โ”œโ”€โ”€ v2_ch01.md โ€” Introduction to ML Systems (Fleet Scale) -โ”œโ”€โ”€ v2_ch02.md โ€” Compute Infrastructure (Fleet Scale) -โ”œโ”€โ”€ v2_ch03.md โ€” Network Fabrics -โ”œโ”€โ”€ v2_ch05.md โ€” Data Storage โ€” The Fuel Line -โ”œโ”€โ”€ v2_ch06.md โ€” Distributed Training Systems -โ”œโ”€โ”€ v2_ch07.md โ€” Collective Communication -โ”œโ”€โ”€ v2_ch08.md โ€” Fault Tolerance and Reliability -โ”œโ”€โ”€ v2_ch09.md โ€” Fleet Orchestration -โ”œโ”€โ”€ v2_ch10.md โ€” Performance Engineering -โ”œโ”€โ”€ v2_ch11.md โ€” Inference at Scale -โ”œโ”€โ”€ v2_ch12.md โ€” Edge Intelligence -โ”œโ”€โ”€ v2_ch13.md โ€” ML Operations at Scale -โ”œโ”€โ”€ v2_ch14.md โ€” Security & Privacy -โ”œโ”€โ”€ v2_ch15.md โ€” Robust AI -โ”œโ”€โ”€ v2_ch16.md โ€” Sustainable AI -โ”œโ”€โ”€ v2_ch17.md โ€” Responsible Engineering -โ”œโ”€โ”€ v2_ch18.md โ€” Conclusion -โ”œโ”€โ”€ v2_appA.md โ€” Single-Machine Foundations -โ”œโ”€โ”€ v2_appB.md โ€” Fleet Foundations -โ”œโ”€โ”€ v2_appC.md โ€” Communication Foundations -โ”œโ”€โ”€ v2_appD.md โ€” Reliability Foundations -โ”œโ”€โ”€ v2_appE.md โ€” The Cยณ Taxonomy -โ””โ”€โ”€ v2_appF.md โ€” System Assumptions -``` - -> **Note**: The source textbook Vol 2 has no chapter 3 content (skips from ch03 to ch04). This plugin combines both ch03 and ch04 into 1 (ch03). - -### 4 Top-Level Reference Files -| File | Description | -|------|-------------| -| `SKILL.md` | Plugin manifest with chapter index, artifact counts, installation guide | -| `glossary.md` | **111 definitions** โ€” alphabetical, disambiguated Vol 1/Vol 2 | -| `patterns.md` | **820 named artifacts** across 8 categories (see below) | -| `cheatsheet.md` | Key formulas, quantitative rules of thumb, hardware constants | - -### 820 Named Artifacts (Extracted & Categorized) -| Category | Count | Description | -|----------|-------|-------------| -| ๐Ÿงฎ Napkin Math | 192 | Worked quantitative examples | -| โœ… Checkpoints | 130 | Self-check questions | -| ๐Ÿ”ญ Systems Perspectives | 114 | Architectural insights | -| โš–๏ธ Principles | 50 | Invariants & laws | -| ๐Ÿ’ฅ War Stories | 41 | Production failures | -| ๐Ÿฎ Lighthouses | 60 | Reference workloads | -| ๐Ÿ“‹ Examples | 87 | Applied cases | -| ๐Ÿ“– Definitions | 142 | Formal definitions | -| **Total** | **820** | | - ---- - -## ๐Ÿš€ Installation - -### Gemini CLI (Primary Target) ```bash -# Clone or download this repo git clone https://github.com/CollinsNyatundo/machine-learning-systems-plugin.git - -# Install to Gemini CLI plugins directory -cp -r machine-learning-systems-plugin/skills/machine-learning-systems \ - ~/.gemini/config/plugins/ - -# Verify -ls ~/.gemini/config/plugins/machine-learning-systems/skills/machine-learning-systems/chapters/ -``` - -### Cursor / Windsurf -```bash -cp -r machine-learning-systems-plugin/skills/machine-learning-systems \ - .cursor/plugins/ -``` - -### MCP Server (Programmatic Access) - -The repository includes a ready-to-use Model Context Protocol (MCP) server (`mcp_server.py`) at the root, allowing programmatic integration with tools like Cursor, Windsurf, Claude Code, and Claude Desktop. - -To run the server directly: -```bash +cd machine-learning-systems-plugin +python -m venv .venv +source .venv/bin/activate +pip install -r requirements.txt python mcp_server.py ``` -To install it directly via the `fastmcp` CLI: +FastMCP can also install the server into supported clients: + ```bash -# Install to Claude Desktop fastmcp install claude-desktop mcp_server.py - -# Install to Cursor fastmcp install cursor mcp_server.py - -# Install to Claude Code fastmcp install claude-code mcp_server.py ``` -### Manual / Any Editor -```bash -# Just copy the chapters folder anywhere -cp -r machine-learning-systems-plugin/skills/machine-learning-systems/chapters \ - ~/my-ml-reference/ -``` - ---- - -## ๐Ÿ” Usage - -### In Gemini CLI -``` -# List available skills -/skills - -# The plugin provides these skills automatically: -# - machine-learning-systems (full textbook reference) -# - Individual chapter skills via chapter-naming -``` - -### As Reference Documentation -- **Search**: Use `Ctrl+F` in any `.md` file -- **Cross-references**: Patterns/glossary link back to source chapters -- **Formulas**: Cheatsheet has LaTeX-rendered equations -- **Definitions**: Glossary is alphabetical with Vol 1/Vol 2 disambiguation - -### Key Formulas Available (Cheatsheet) -- **Iron Law**: `T = D_vol/BW + O/(R_peakยทฮท_hw) + L_lat` -- **Arithmetic Intensity**: `AI = FLOPs / Bytes` -- **MFU**: `Achieved FLOP/s / Peak FLOP/s` -- **Ridge Point**: `R = R_peak / BW` -- **Young-Daly**: `ฯ„_opt = โˆš(2ยทT_writeยทMTBF)` -- **KL Divergence**: `D_KL(PโˆฅQ) = ฮฃ P(i) log(P(i)/Q(i))` - ---- - -## ๐Ÿ›  How This Was Built +Client support and syntax change over time; consult the client's current documentation. See [INTEGRATIONS.md](INTEGRATIONS.md) for configuration examples. Its HTTP examples require authentication, transport security, and network hardening before exposure outside a trusted machine. -1. **Source Extraction**: Docling PDF โ†’ markdown slices (via Antigravity / docling-serve) -2. **Deterministic Merge**: Python script `merge_vol1_chapters.py` โ€” no LLM in the loop - - Preserves every named artifact (Definition, Napkin Math, Checkpoint, etc.) - - Maintains all tables, equations, code blocks, H2/H3 hierarchy - - Prepends original summary section ("Section-by-Section Preserve-and-Extend") -3. **Parity Audit**: `audit_vol1_rebuild.py` verifies 100% artifact coverage -4. **Top-Level Regeneration**: Patterns, glossary, cheatsheet extracted from final chapters -5. **Math Placeholder & LaTeX Resolution**: Resolved 354 mathematical comment placeholders (``) and raw dollar-sign math wrappers using a background validation pipeline. Enforced strict math delimiters (`\(` and `\)` for inline, `\[` and `\]` for display) and normalized Greek/Unicode characters across all 44 chapters. -6. **Quality**: 113% average byte ratio (plugin โ‰ฅ slice), 0 missing artifacts +## MCP surface -**Artifacts preserved**: `/tmp/merge_vol1_chapters.py`, `/tmp/audit_vol1_rebuild.py`, `/tmp/backup_vol1/` +| Type | Name | Purpose | +|---|---|---| +| Resource | `ml-systems://index` | Chapter metadata | +| Resource | `ml-systems://chapter/{id}` | Chapter text | +| Resource | `ml-systems://glossary` | Glossary | +| Resource | `ml-systems://patterns` | Indexed artifacts | +| Resource | `ml-systems://cheatsheet` | Quick reference | +| Tool | `search` | Search the reference corpus | +| Tool | `get_chapter` | Retrieve one chapter safely | +| Tool | `list_chapters` | List chapter metadata | +| Tool | `list_patterns` | Filter indexed artifacts | ---- +## Verify -## ๐Ÿ“– Attribution & License - -| Component | License | Attribution | -|-----------|---------|-------------| -| **Source Textbook** | CC BY-NC-SA 4.0 | "Machine Learning Systems" by Vijay Janapa Reddi, Harvard SEAS โ€” [mlsysbook.ai](https://mlsysbook.ai/) | -| **Course Material** | Educational | CS 249r: Machine Learning Systems, Harvard | -| **This Plugin** | CC BY-NC-SA 4.0 | Plugin format, extraction scripts, top-level indices โ€” free to use, modify, distribute | -| **Docling** | Apache 2.0 | PDF โ†’ markdown conversion โ€” [ds4sd/docling](https://github.com/docling-project/docling) | - -### Proper Citation -``` -@book{reddi2024mlsystems, - title = {Machine Learning Systems}, - author = {Reddi, Vijay Janapa}, - institution = {Harvard John A. Paulson School of Engineering and Applied Sciences}, - course = {CS 249r}, - year = {2024}, - url = {https://mlsysbook.ai/}, - note = {Open-source textbook, CC BY-NC-SA 4.0} -} - -@software{mls_plugin_2025, - title = {Machine Learning Systems Plugin for Gemini CLI / Cursor / MCP}, - author = {Nyatundo, Collins}, - url = {https://github.com/CollinsNyatundo/machine-learning-systems-plugin}, - license = {MIT}, - note = {Deterministic extraction from docling slices, 820 artifacts, 44 chapters} -} +```bash +pip install -r requirements-dev.txt +pytest -q +python -m compileall -q mcp_server.py ``` ---- - -## ๐Ÿค Contributing - -1. **Source corrections**: Report to upstream textbook at [harvard-edge/cs249r_book](https://github.com/harvard-edge/cs249r_book) -2. **Plugin improvements**: PRs welcome for: - - Additional top-level indices (timeline, concept map, etc.) - - Enhancement of MCP prompts and resources - - Better cross-references between Vol 1 โ†” Vol 2 - - Search/index tooling - ---- - -## ๐Ÿ™ Acknowledgments - -- **Prof. Vijay Janapa Reddi** โ€” for writing and open-sourcing this exceptional textbook -- **Harvard EDGE / CS 249r team** โ€” for the course and materials -- **Docling Project** โ€” for best-in-class PDF understanding -- **Antigravity** โ€” for the deterministic rebuild pipeline -- **Nous Research / Hermes** โ€” for the agent framework used to build this - ---- - -## ๐Ÿ“ž Support +## Provenance -- **Plugin issues**: [GitHub Issues](https://github.com/CollinsNyatundo/machine-learning-systems-plugin/issues) -- **Textbook questions**: [mlsysbook.ai](https://mlsysbook.ai/) or [CS 249r discussions](https://github.com/harvard-edge/cs249r_book/discussions) -- **Author**: Collins Nyatundo ([@CollinsNyatundo](https://github.com/CollinsNyatundo)) +The chapter Markdown was extracted and reorganized from the CC BY-NC-SA 4.0 source material. Repository-specific changes include the directory layout, indexes, search server, metadata, and tests. Corrections to the textbook itself should be reported to the [upstream project](https://github.com/harvard-edge/cs249r_book). ---- +## License -*Generated from the complete "Machine Learning Systems" textbook via deterministic docling extraction. Every definition, formula, worked example, and architectural insight preserved from source.* +The source and this derivative are licensed under [CC BY-NC-SA 4.0](LICENSE). You must provide attribution, restrict use to non-commercial purposes, and distribute adaptations under the same license. diff --git a/mcp_server.py b/mcp_server.py index 4823bb1..dec1167 100644 --- a/mcp_server.py +++ b/mcp_server.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ Machine Learning Systems โ€” MCP Server -Exposes the complete textbook (44 chapters, 111 definitions, 820 artifacts) +Exposes the reference collection (44 chapters, 111 definitions, 816 artifacts) as MCP tools, resources, and prompts. Usage: @@ -14,10 +14,11 @@ """ from __future__ import annotations -from pathlib import Path import json import re from functools import lru_cache +from pathlib import Path + from fastmcp import FastMCP # โ”€โ”€ Configuration โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ @@ -58,7 +59,6 @@ def _load_chapter_index() -> list[dict]: "title": title, "volume": vol, "size_kb": md.stat().st_size // 1024, - "path": str(md) }) return chapters @@ -68,9 +68,12 @@ def _load_glossary_entries() -> list[dict]: text = (CHAPTERS_DIR / "glossary.md").read_text(encoding="utf-8") entries = [] parts = text.split("\n---\n") - for part in parts[1:]: # skip header + for part in parts: + heading = part.find("\n### ") + if heading >= 0: + part = part[heading + 1 :] lines = part.strip().split("\n") - if not lines: + if not lines or not lines[0].startswith("### "): continue term = lines[0].replace("### ", "").strip() heading = None @@ -80,7 +83,11 @@ def _load_glossary_entries() -> list[dict]: if line.startswith("**Full heading:**"): heading = line.replace("**Full heading:**", "").strip() elif line.startswith("**Source:**"): - source = line.replace("**Source:**", "").strip().replace("`", "") + source_line = line.replace("**Source:**", "").strip() + source_part, separator, chapter_part = source_line.partition(" โ€ข **Chapter:**") + source = source_part.replace("`", "").strip() + if separator: + chapter = chapter_part.strip() elif line and not line.startswith("**") and not heading: content += line + " " entries.append({ @@ -97,9 +104,12 @@ def _load_patterns_index() -> list[dict]: text = (CHAPTERS_DIR / "patterns.md").read_text(encoding="utf-8") artifacts = [] parts = text.split("\n---\n") - for part in parts[1:]: # skip header + for part in parts: + heading = part.find("\n### ") + if heading >= 0: + part = part[heading + 1 :] lines = part.strip().split("\n") - if not lines: + if not lines or not lines[0].startswith("### "): continue name = lines[0].replace("### ", "").strip() source = None @@ -108,7 +118,11 @@ def _load_patterns_index() -> list[dict]: content = "" for line in lines[1:]: if line.startswith("**Source:**"): - source = line.replace("**Source:**", "").strip().replace("`", "") + source_line = line.replace("**Source:**", "").strip() + source_part, separator, chapter_part = source_line.partition(" โ€ข **Chapter:**") + source = source_part.replace("`", "").strip() + if separator: + chapter = chapter_part.strip() elif line.startswith("**Full heading:**"): version = line.replace("**Full heading:**", "").strip() elif line.startswith("**Chapter:**"): @@ -147,7 +161,7 @@ def glossary() -> str: @mcp.resource("ml-systems://patterns") def patterns() -> str: - """All 820 named artifacts across 8 categories.""" + """All 816 indexed artifacts across 8 categories.""" return (CHAPTERS_DIR / "patterns.md").read_text(encoding="utf-8") @mcp.resource("ml-systems://cheatsheet") @@ -295,8 +309,13 @@ def get_chapter(file: str) -> str: Returns: Full chapter markdown or error. """ - path = CHAPTERS_DIR / file - if not path.exists(): + requested = Path(file) + if requested.name != file or requested.suffix.lower() != ".md": + return json.dumps({"error": f"Invalid chapter filename: {file}"}) + + root = CHAPTERS_DIR.resolve() + path = (root / requested).resolve() + if not path.is_relative_to(root) or not path.is_file(): # List available files available = [c["file"] for c in _load_chapter_index()] return json.dumps({ @@ -554,4 +573,4 @@ def exam_prep(chapters: str = "all") -> str: # โ”€โ”€ Run โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ if __name__ == "__main__": - mcp.run() \ No newline at end of file + mcp.run() diff --git a/plugin.json b/plugin.json index 67056f1..855fcff 100644 --- a/plugin.json +++ b/plugin.json @@ -4,7 +4,7 @@ "description": "Study and reference guide for Machine Learning Systems design, patterns, architectures, and quantitative invariants. Includes MCP server for universal AI assistant integration.", "version": "1.1.0", "author": { - "name": "Collins Nyatundo", + "name": "Collins Nyagaka", "email": "cnyagakan@gmail.com" }, "source": { @@ -15,7 +15,7 @@ "url": "https://mlsysbook.ai/", "license": "CC BY-NC-SA 4.0" }, - "license": "MIT", + "license": "CC-BY-NC-SA-4.0", "keywords": [ "machine-learning", "systems-engineering", @@ -67,4 +67,4 @@ "continue": "Add to ~/.continue/config.json", "manual": "Copy chapters/ folder or use MCP server" } -} \ No newline at end of file +} diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..44dca33 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,2 @@ +-r requirements.txt +pytest==8.4.2 diff --git a/requirements.txt b/requirements.txt index 9074148..932de22 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -fastmcp>=2.0.0 \ No newline at end of file +fastmcp==2.14.7 diff --git a/skills/machine-learning-systems/SKILL.md b/skills/machine-learning-systems/SKILL.md index 572a14f..1ad5b9d 100644 --- a/skills/machine-learning-systems/SKILL.md +++ b/skills/machine-learning-systems/SKILL.md @@ -194,10 +194,10 @@ cp -r skills/machine-learning-systems/chapters ~/my-ml-reference/ |-----------|---------|-------------| | **Source Textbook** | CC BY-NC-SA 4.0 | "Machine Learning Systems" by Vijay Janapa Reddi, Harvard SEAS โ€” [mlsysbook.ai](https://mlsysbook.ai/) | | **Course Material** | Educational | CS 249r: Machine Learning Systems, Harvard | -| **Plugin & MCP Server** | MIT | Free to use, modify, distribute | +| **Plugin & MCP Server** | CC BY-NC-SA 4.0 | Attribution required; noncommercial use; adaptations use the same license | | **Docling** | Apache 2.0 | PDF โ†’ markdown conversion โ€” [ds4sd/docling](https://github.com/docling-project/docling) | | **FastMCP** | MIT | MCP server framework โ€” [gofastmcp.com](https://gofastmcp.com) | --- -*Generated from the complete "Machine Learning Systems" textbook via deterministic docling extraction. Every definition, formula, worked example, and architectural insight preserved from source.* \ No newline at end of file +*Derived from "Machine Learning Systems" through document extraction and repository-specific indexing. Consult the upstream textbook when exact source fidelity matters.* diff --git a/skills/machine-learning-systems/chapters/cheatsheet.md b/skills/machine-learning-systems/chapters/cheatsheet.md index 89897fc..e59b49f 100644 --- a/skills/machine-learning-systems/chapters/cheatsheet.md +++ b/skills/machine-learning-systems/chapters/cheatsheet.md @@ -56,9 +56,9 @@ - **Vol 1 (21 files):** `chapters/ch01.md` โ€“ `ch16.md`, `appA.md`โ€“`appE.md` - **Vol 2 (23 files):** `chapters/v2_ch01.md` โ€“ `v2_ch18.md`, `v2_appA.md`โ€“`v2_appF.md` - **Full Glossary:** `glossary.md` (112 definitions) -- **All Patterns:** `patterns.md` (820 artifacts) -- **Total Artifacts:** 820+ +- **All Patterns:** `patterns.md` (816 indexed artifacts) +- **Total Indexed Artifacts:** 816 --- -*Generated from 44 chapter files via deterministic extraction.* \ No newline at end of file +*Generated from 44 chapter files via deterministic extraction.* diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..0d04def --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,5 @@ +import sys +from pathlib import Path + + +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) diff --git a/tests/test_mcp_server.py b/tests/test_mcp_server.py new file mode 100644 index 0000000..73cd597 --- /dev/null +++ b/tests/test_mcp_server.py @@ -0,0 +1,35 @@ +import json + +import mcp_server + + +def test_get_chapter_rejects_parent_directory_escape(): + result = json.loads(mcp_server.get_chapter.fn("../README")) + assert result["error"].startswith("Invalid chapter filename") + + +def test_get_chapter_rejects_symlink_escape(tmp_path, monkeypatch): + chapters = tmp_path / "chapters" + chapters.mkdir() + outside = tmp_path / "private.md" + outside.write_text("private", encoding="utf-8") + (chapters / "escape.md").symlink_to(outside) + monkeypatch.setattr(mcp_server, "CHAPTERS_DIR", chapters) + + result = json.loads(mcp_server.get_chapter.fn("escape.md")) + assert result["error"].startswith("Chapter not found") + + +def test_chapter_index_does_not_disclose_absolute_paths(): + mcp_server._load_chapter_index.cache_clear() + payload = json.loads(mcp_server.chapter_index.fn()) + chapters = payload["vol1"] + payload["vol2"] + assert payload["total_chapters"] == 44 + assert all("path" not in chapter for chapter in chapters) + + +def test_patterns_parser_indexes_every_artifact_record(): + mcp_server._load_patterns_index.cache_clear() + patterns = mcp_server._load_patterns_index() + assert len(patterns) == 816 + assert all(item["name"] and item["source"] and item["chapter"] for item in patterns)