An agentic RAG system designed to de-risk HR operations by ensuring strict compliance with Hong Kong’s Mandatory Provident Fund (MPF) employer obligations.
The MPF Employer RAG is an agentic retrieval-augmented generation system designed to answer questions about Mandatory Provident Fund (MPF) employer obligations in Hong Kong. The system combines a reasoning agent with local vector storage and external API connectivity to provide accurate, context-aware responses.
The system uses a layered architecture with three main components: an Agent Layer for reasoning and tool orchestration, a Retrieval Layer for semantic search via Zvec, and a Data Layer for document storage and management.
External Frontend (OpenWebUI / Jan.ai)
│
▼ (MCP - query tool only)
MCP Server (FastMCP)
│
▼
Deep Agents (with planning, reflection)
│
▼ (tool call)
Zvec (hybrid search)
uv run python rag/index.pyuv run python mcp/zvec_server.pyMCP server runs on http://localhost:8080
export OPENROUTER_API_KEY=your_key
uv run python agents/rag_agent.pyCopy .env.example to .env and fill in:
OPENROUTER_API_KEY=your_api_key
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
OPENROUTER_MODEL=google/gemma-4-31b-it:free
MCP_HOST=0.0.0.0
MCP_PORT=8080
SEARCH_TOP_K=5
See config/settings.py for:
- Zvec path, embedding model
- MCP server host/port
- Search top-k, chunk size
-
Ensure the MCP server is running:
uv run python mcp/zvec_server.py
-
In OpenWebUI, go to Settings → Admin Panel → Connections
-
Under MCP Servers, add a new server:
- Name: MPF Employer RAG
- URL:
http://localhost:8080/mcp - Or use STDIO mode with command:
uv --directory /path/to/mpf-employer-rag run mcp/zvec_server.py
-
The following tools will be available:
query_rag: Query MPF knowledge baseget_stats: Knowledge base statistics
-
Ensure the MCP server is running:
uv run python mcp/zvec_server.py
-
Open Jan.ai and go to Settings → MCP Servers
-
Click + Add MCP Server and configure:
- Name: MPF Employer RAG
- Transport:
HTTP(Streamable HTTP) - URL:
http://localhost:8080/mcp - Env (optional): Add any environment variables if needed
-
Toggle the server on. A green indicator shows when active.
-
Available tools:
query_rag: Query MPF knowledge baseget_stats: Knowledge base statistics
query_rag: Query MPF knowledge baseget_stats: Knowledge base statistics
search_documents: Search knowledge baseget_knowledge_stats: Get stats
mpf-employer-rag/
├── mcp/zvec_server.py # FastMCP server
├── agents/
│ ├── rag_agent.py # Deep Agents
│ └── rag_tools.py # RAG tools
├── rag/
│ ├── index.py # Document indexing
│ ├── zvec_db.py # Zvec wrapper
│ └── doc/ # Source documents
├── config/settings.py # Configuration
└── pyproject.toml

