DEV Community

Pooya Golchian
Pooya Golchian

Posted on

RevOps AI. I Turned Notion into an AI-Powered CRM with Gemini and MCP

Notion MCP Challenge Submission 🧠

A revenue operations platform where Gemini 2.5 Flash autonomously manages pipeline, scores leads, and drafts sales emails through Notion MCP. No CRM vendor lock-in. No proprietary databases. Just Notion.

What I Built

RevOps AI turns Notion into a full revenue operations platform. No Salesforce. No HubSpot. No proprietary database sitting between your team and their data.

Four Notion databases hold every contact, deal, activity, and company record. Google Gemini 2.5 Flash sits on top as an autonomous sales team member. It queries your pipeline, scores leads, drafts emails, generates pre-call briefings, and creates follow-up activities. All through natural language. All written back to Notion in real time.

The critical difference from other MCP integrations? Gemini doesn't follow hardcoded scripts. Through mcpToTool() from Google's GenAI SDK, the model receives all 22 Notion MCP tools and decides at runtime which ones to call. It reasons through multi-step operations the same way a senior sales ops analyst would, chaining searches, queries, and updates in a single response.

The Problem That Started This

Every sales team I've worked with runs into the same wall. Their CRM lives in one system. Their docs, meeting notes, and project management live in Notion. Two systems. Two sources of truth. Data drifts apart within weeks.

Salesforce runs $150/user/month. HubSpot locks you into their ecosystem. Meanwhile, the team already collaborates in Notion every day.

So I asked a simple question. What if Notion was the CRM? And what if an AI agent could operate it autonomously?

Key Features

AI Sales Team Manager. Ask "What's my pipeline health?" in plain English. Gemini queries your Notion databases, calculates win rates, and surfaces the insights that matter. Say "Create a follow-up for the Acme deal" and it creates the activity, linked to the right deal, without you touching a form. Think of it as a senior sales ops analyst available around the clock.

Revenue Dashboard. Total pipeline value, win rate, deal breakdown by stage, top deals, and recent team activity. Every metric pulls from Notion through MCP in real time. No stale data. No manual report building.

Visual Deal Pipeline. Drag-and-drop Kanban board with six stages, from Lead through Closed Won and Closed Lost. Every move syncs to Notion instantly via MCP. What your team sees in the app matches what they see in Notion. Always.

AI Lead Scoring. One click triggers Gemini to evaluate a contact's role seniority, company size, and engagement history, then assign a 0-100 score with written reasoning. That score persists back to the Notion Contacts database so your entire team sees it everywhere Notion surfaces.

Pre-Call Briefing Generator. Before any sales call, the AI pulls deal context, activity history, and contact data from Notion to build a structured brief. Talking points, likely objections, relationship timeline, and recommended next steps. All generated autonomously from your existing data.

Email Ghostwriter. Gemini drafts personalized sales emails based on the deal's stage, contact history, and recent activity. No generic templates. Each email reflects the actual context of the relationship.

Contact Management. Full CRUD with search, filtering by lead source, sortable columns, and inline AI scoring. Add new contacts directly from the UI. Everything writes to Notion through MCP.

Demo

Screenshots

Revenue Dashboard
Dashboard

Deal Pipeline (Kanban)
Pipeline

Deal Detail + AI Email Draft
Deal Detail
AI Email Draft

Leads & AI Scoring
Leads

Companies
Companies

AI Sales Team Manager
AI Assistant

Responsive across desktop, tablet, and mobile
Desktop Tablet Mobile

Show Us the Code

GitHub Repository: https://github.com/pooyagolchian/ai-sales-crm

Application Flow

Application Architecture

The Core Innovation, mcpToTool()

Most MCP integrations manually wire each API endpoint into the AI layer. RevOps AI eliminates that entire step with a single function call.

// src/lib/gemini.ts
import { GoogleGenAI, mcpToTool } from "@google/genai";
import { getMcpClient } from "./mcp-client";

export async function generateWithTools(
  prompt: string,
  systemPrompt?: string
): Promise<string> {
  const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
  const mcpClient = await getMcpClient();

  const response = await ai.models.generateContent({
    model: "gemini-2.5-flash",
    contents: prompt,
    config: {
      tools: [mcpToTool(mcpClient)],         // All 22 Notion tools, auto-mapped
      systemInstruction: getCrmSystemPrompt(), // DB IDs + property names injected
    },
  });

  return response.text ?? "";
}
Enter fullscreen mode Exit fullscreen mode

mcpToTool(mcpClient) auto-maps all 22 Notion MCP tools into Gemini function declarations. The system prompt injects actual database IDs and property names so Gemini skips the discovery phase entirely.

The result? Gemini autonomously decides which Notion operations to perform. Ask "What's my pipeline value?" and it calls API-query-data-source on Deals. Say "Log a meeting for Acme" and it calls API-post-page to create an Activity, then API-patch-page to update the deal. Zero hardcoded logic.

MCP Client, Singleton with Auto-Reconnect

// src/lib/mcp-client.ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";

async function createClient(): Promise<Client> {
  const mcpClient = new Client({ name: "revops-ai", version: "1.0.0" });

  const transport = new StreamableHTTPClientTransport(
    new URL(process.env.MCP_SERVER_URL || "http://localhost:3001/mcp"),
    { requestInit: { headers: { Authorization: `Bearer ${authToken}` } } }
  );

  await mcpClient.connect(transport);
  return mcpClient;
}
Enter fullscreen mode Exit fullscreen mode

Tech Stack

Layer Technology
Framework Next.js 15 (App Router), TypeScript (strict)
UI Tailwind CSS v4, shadcn/ui, Lucide icons
AI Google Gemini 2.5 Flash via @google/genai SDK
Data Notion (4 databases) via MCP protocol
MCP @notionhq/notion-mcp-server v2 (HTTP) + @modelcontextprotocol/sdk
DnD @dnd-kit/core + @dnd-kit/sortable
Linting Biome

How I Used Notion MCP

Notion isn't a supporting tool here. It is the entire database layer. No Postgres. No SQLite. No local storage. Every record lives in a Notion database, and every read and write goes through MCP.

Four Notion Databases

Database Purpose Key Properties
Contacts Lead & customer profiles Name, Email, Company, Role, Lead Score, Lead Score Notes, Source
Deals Revenue pipeline items Name, Contact (relation), Stage (6 values), Value, Close Date, Priority, Next Action
Activities Sales touchpoints Type (call/email/meeting/note), Date, Deal (relation), Summary, Raw Notes
Companies Organization profiles Name, Industry, Size, Website

MCP Operations Used

Every data operation routes through MCP.

  • API-query-data-source for querying databases with filters and sorts
  • API-post-page for creating new contacts, deals, and activities
  • API-patch-page for updating deal stages via Kanban drag-and-drop, persisting AI lead scores, and modifying Next Action fields
  • API-search for free-text search across the entire Notion workspace
  • API-retrieve-a-page for fetching full details used in deal briefings and AI assistant context

What Makes This Approach Different

Most MCP integrations hardcode which tools to call. RevOps AI hands the entire toolset to Gemini and lets it choose.

mcpToTool(mcpClient) auto-maps all 22 Notion MCP tools into Gemini function declarations with a single call. No manual schema writing. No tool definitions to maintain.

Autonomous multi-step reasoning means Gemini chains multiple MCP calls in one response. Ask "Brief me on the TechCorp deal" and it searches for the deal, queries related activities, retrieves the contact profile, and synthesizes a briefing. Four operations. One prompt. Zero hardcoded logic.

System prompt injection feeds the AI actual database IDs and exact property names from notion-schema.ts, so the model never wastes tool calls discovering database structure.

Notion stays the single source of truth. The team's data lives where they already collaborate. RevOps AI adds an intelligent layer on top without creating another data silo.

Why Notion MCP Specifically

This solves a real problem that traditional CRM architectures cannot.

Your data stays where your team already works. A marketing director opens Notion and sees every deal, contact, and activity in familiar views. Tables, kanban boards, calendars, galleries. They edit inline, add comments, share with stakeholders. No separate CRM login required.

The AI gets full context through a standard protocol. MCP gives structured access to query, create, update, and search, with proper schemas and typed inputs. This is a designed protocol, not screen scraping or brittle API hacks.

Zero vendor lock-in. Switch from Gemini to Claude or GPT? The MCP layer stays the same. Switch from Notion to another MCP-compatible tool? The AI integration pattern stays the same. MCP decouples the AI from the data source.

The cost is essentially zero. Notion's free plan supports databases. Gemini 2.5 Flash has a generous free tier via Google AI Studio. The MCP server is open source. A startup's first RevOps stack can run at $0.


Built with Notion MCP, Google Gemini 2.5 Flash, and Next.js 15. Because revenue operations shouldn't require a $150/seat CRM when your team already lives in Notion.

Top comments (0)