YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Notion MCP Specialized Local Model System
This directory contains the training pipeline, dataset generator, quantization scripts, and Ollama Modelfile for building and deploying notion-agent β an ultra-compact (~980MB RAM), fast local AI planner and router specialized for the Notion Model Context Protocol (MCP).
π― Architecture & Objective
The goal of notion-agent is to run locally on resource-constrained laptops (e.g. 16GB RAM / Intel CPU) to:
- Directly Execute Notion MCP Tools: Handle routine tasks like
API-post-page(task/note creation) andAPI-query-data-source(status checks) with 0 cloud latency and 0 Gemini API quota usage. - Deterministic Routing: Act as a primary router. Escalate complex multi-document synthesis or creative queries to Google Gemini Cloud (
gemini-3.7-flash).
flowchart TD
User["π€ User Prompt"] --> NotionAgent["π€ notion-agent (Local Qwen 2.5 1.5B / 0.5B)"]
NotionAgent --> Decision{"Deterministic Routing Decision"}
Decision -->|"Action: CALL_NOTION_TOOL\n(Tasks / Notes CRUD)"| MCP["π¦ Notion MCP Server (Local)"]
Decision -->|"Action: ESCALATE_TO_GEMINI\n(Deep Cross-Doc Synthesis)"| Gemini["β¨ Google Gemini 3.7 Flash"]
Decision -->|"Action: DIRECT_ANSWER\n(Simple greeting)"| Direct["π¬ Instant Local Response"]
MCP --> Output["π Response with Execution Trace"]
Gemini --> Output
Direct --> Output
π Quick Start (Local Build in 30 Seconds)
Prerequisites:
- Install Ollama for Windows.
Build and Register notion-agent:
Run the one-click build script from this directory:
model\scripts\build_model.bat
Or run via Ollama CLI:
cd model
ollama pull qwen2.5:1.5b
ollama create notion-agent -f Modelfile
Test it in terminal:
ollama run notion-agent "Add task 'Review Q3 metrics' with High priority"
π Directory Layout
model/
βββ Modelfile <- Ollama custom model definition with Notion MCP rules
βββ README.md <- This documentation guide
βββ data/
β βββ notion_mcp_dataset.json <- Synthetic training & fine-tuning dataset
βββ scripts/
β βββ build_model.bat <- One-click Windows builder script
βββ src/
βββ dataset_generator.py <- Generates thousands of synthetic Notion prompt/tool pairs
βββ train_lora.py <- PEFT/LoRA fine-tuning script for Qwen 2.5
βββ export_gguf.py <- GGUF conversion & 4-bit quantization (llama.cpp)
βββ upload_to_hf.py <- Uploads quantized GGUF directly to Hugging Face Hub
π§ Training & Fine-Tuning Pipeline
1. Generate Synthetic Notion MCP Dataset
To generate fresh prompt-to-tool training pairs:
python model/src/dataset_generator.py
2. Fine-Tune with LoRA (Unsloth / TRL)
python model/src/train_lora.py
3. Quantize to GGUF (Q4_K_M)
Merge LoRA weights and quantize using llama.cpp:
python model/src/export_gguf.py
π€ Publishing & Hosting on Hugging Face
Because Git repositories have a 100MB file limit, we host quantized GGUF weights on Hugging Face Hub (100% free and unlimited):
- Create a free account at huggingface.co.
- Go to Settings -> Access Tokens and generate a new token with
writepermissions. - Upload your quantized model using the included upload script:
python model/src/upload_to_hf.py ./notion-qwen-1.5b.Q4_K_M.gguf <your-username>/notion-mcp-qwen-1.5b-gguf <your-hf-token> - Any user can now pull and run your model directly:
ollama run hf.co/<your-username>/notion-mcp-qwen-1.5b-gguf