Inspiration

We've all been there: Day 1 at a new job. Instead of diving into exciting work, you spend your first week tracking down HR to ask about document statuses, waiting for IT to provision your software accounts, and reading endless static PDF policies. On the flip side, HR professionals are buried in administrative paperwork, answering the exact same questions repeatedly instead of focusing on team culture.

With the recent introduction of the Model Context Protocol (MCP), I realized we finally had the missing piece to solve this. Instead of building a basic Q&A chatbot that just reads text, I was inspired to build a truly autonomous agent, one that could hook directly into a live database and securely execute operational tasks on behalf of HR.

How we built it

Onboardora is a full-stack application built to be blindingly fast and highly scalable:

  • Frontend & Backend Core: Built entirely on Next.js 14, providing a seamless, real-time user interface for both the Employee Chat and the HR Admin Dashboard.
  • The Brains: Powered by Google Gemini 2.5 Flash via the Vercel AI SDK. We chose Flash for its incredibly low latency, which is essential for real-time chat interfaces.
  • The Magic (MCP Integration): Instead of hardcoding REST APIs for every possible user intent, we integrated the official @modelcontextprotocol/sdk. Our Next.js server spawns the MongoDB MCP Server as a background process and bridges its tools (find, aggregate) directly into Gemini. When an employee asks, "Is my CNIC verified yet?", Gemini autonomously translates that intent into a MongoDB query and fetches the live answer.
  • Real-Time Synchronization: To make the platform feel truly alive, we implemented WebSockets backed by Redis Pub/Sub. Whenever the AI agent autonomously updates an employee's status in the database, Redis instantly broadcasts that event via WebSockets to the HR Admin dashboard, updating the UI in real-time without a page refresh. Redis also acts as an ultra-fast caching layer to handle high-frequency LLM requests.
  • Knowledge Base & RAG: We utilized the Gemini Embeddings API to chunk and embed company policy documents. These are stored directly in a MongoDB Atlas Vector Search index, allowing the agent to instantly retrieve semantic answers regarding company policies alongside the operational database checks.

Challenges we ran into

Building on the bleeding edge of AI and the Model Context Protocol required solving complex architectural puzzles:

  1. Asynchronous Tool Orchestration: Orchestrating the real-time stream between Gemini, the Next.js backend, and the MongoDB MCP Server was a complex architectural challenge. We had to engineer a highly optimized conversational state loop, ensuring Gemini could autonomously suspend its text stream, execute a secure database lookup via the MCP, and seamlessly resume streaming the final answer to the client without dropping the connection.
  2. Vector Space Alignment: Bridging the semantic gap between Google's state-of-the-art embedding models and our database required precise mathematical alignment. We carefully configured our MongoDB Atlas Vector Search index to operate on a highly specific 768-dimensional space using cosine similarity, guaranteeing that Gemini's semantic document retrieval was both lightning-fast and perfectly accurate.

What we learned

The most profound learning from this project was experiencing the true power of the Model Context Protocol.

In traditional software development, if I wanted an AI to check an employee's onboarding status, I would have had to write a custom /api/get-status endpoint, write an OpenAPI spec for it, and strictly bind the LLM to that specific route.

By using the MongoDB MCP Server, we wrote zero API routes for data retrieval. We simply handed the entire database schema to Gemini as a tool. Watching the agent autonomously decide whether it needed to perform a standard vector search for a policy question, or execute a live MongoDB aggregate pipeline to check a task status, completely shifted my perspective on how future software will be built.

What's next for Onboardora

We plan to expand Onboardora's MCP integrations. The next step is connecting it to the Slack MCP and Google Workspace MCP, allowing the agent to not just read onboarding data, but actively create the new hire's email address and invite them to the company Slack channels autonomously!

Built With

  • gemini-2.5-flash
  • gemini-embeddings
  • google-gemini
  • model-context-protocol
  • mongodb-atlas
  • mongodb-vector-search
  • next-auth
  • nextjs
  • node.js
  • prisma
  • react
  • redis
  • tailwind-css
  • typescript
  • vercel-ai-sdk
  • websockets
Share this project:

Updates