DEV Community

Cover image for I Built an AI Agent That Forces You to Finish What You Start — Using Notion MCP
bilal meziani
bilal meziani

Posted on

I Built an AI Agent That Forces You to Finish What You Start — Using Notion MCP

Notion MCP Challenge Submission 🧠

OneTask uses Notion's Model Context Protocol to turn one weekly goal into a structured weekly execution plan, with an AI agent that protects your focus all week.


This is a submission for the Notion MCP Challenge


🔴 The Problem Most productivity tools overload you with hundreds of tasks, creating distraction and stress.
💡 The Idea What if an AI forced us to focus on only one task at a time, and guided your week around it?
The Solution OneTask is an AI-powered focus agent that reads your Notion workspace, plans your week in structured daily steps, and enforces focus using intelligent prompts.

OneTask Demo - AI Focus Agent in Action

What I Built

Every Monday I open Notion and see 15 tasks. By Friday, I've touched 8 and finished 0.

The problem isn't motivation. It's too many open loops at once. I start something, get pulled toward something else, and never build real momentum on anything.

So I built OneTask, a Notion MCP-powered AI agent that enforces radical weekly focus.

You pick one task. The agent reads your Notion workspace, plans your entire week inside Notion day by day, and then guards your focus. Want to switch mid-week? The agent reviews your reason and rejects weak excuses.

BEFORE OneTask:

  • □ Learn Python
  • □ Build landing page
  • □ Write business plan
  • □ Fix the API bug
  • □ Update portfolio
  • □ Reply to emails
  • □ ...7 more

AFTER OneTask:

  • Learn Python
    • Wednesday: Read chapters 1-3
    • Thursday: Build first script
    • Friday: Practice with exercises
    • Saturday: Mini project

You choose one focus. OneTask plans the week, writes it to Notion, and guards your focus.


Key Features

📋 AI week planning: Gemini 2.5 Flash breaks your task into specific daily steps

Real Notion checkboxes: Creates to_do blocks written directly into your task page

🔒 Focus Guardian: The AI agent rejects weak reasons for switching mid-week

🔄 Real-time Notion writes: Every action in the app updates Notion immediately

✏️ Adapt your plan: Rewrite the plan for your actual level mid-week

🌙 Dark mode: Auto-detects system preference


Live Demo

💡 Try it yourself: Duplicate the OneTask Notion Template and see the AI in action.


Show Us the Code

GitHub: github.com/bilalmez/onetask

Notion Template: Duplicate the OneTask workspace

Stack:

  • Backend: Python + FastAPI
  • Frontend: Vanilla HTML/CSS/JS (single file, zero build step)
  • AI: Gemini 2.5 Flash (native JSON output mode)
  • Integration: Notion REST API + Notion MCP tooling layer

The Focus Guardian

This is the feature that makes OneTask different. When you try to change your focus on Day 3:

You: "I want to work on something else"

Agent: "You're on Day 3 of 7. You've done 1 out of 5 steps. What's the real reason?"

You: "I feel like working on a different project"

Agent: "That sounds more like avoidance than necessity. I recommend staying with your current focus."

You: "My client moved a deadline to tomorrow morning"

Agent: "External deadline conflict detected. You're clear to switch."

Commitment enforced intelligently, not just suggested.

The agent uses Gemini to review the reason and decide: legitimate external conflict or procrastination? This transforms productivity from suggestion to enforcement.


How I Used Notion MCP

OneTask uses a Notion MCP integration layer alongside the Notion REST API. The MCP layer gives the AI agent tool-based access to the workspace. Instead of raw HTTP calls, the agent interacts with Notion through structured tools it understands natively.

Here's the hybrid engine at the center of the architecture:

def mcp_hybrid_execute(operation, tool_name, tool_args, rest_method, rest_path):
    # 1. Try MCP tool first (native tool-based access)
    result = mcp(tool_name, tool_args)
    if result and not result.get("isError"):
        return result  # MCP success

    # 2. Transparent REST API fallback
    return notion(rest_method, rest_path)
Enter fullscreen mode Exit fullscreen mode

MCP tools used in OneTask:

Tool Purpose
API-retrieve-a-database Read the workspace schema
API-get-block-children Read existing page content
API-patch-block-children Write daily to-do blocks
API-delete-a-block Clean up old plans before rewriting
API-patch-page Update Status, Priority, and Notes

What MCP unlocks: The agent doesn't just call an API. It uses Notion as a set of tools it understands. This changes the mental model from "send HTTP requests" to "use workspace tools." The result is better agent behavior and cleaner integration logic.

Why hybrid? The MCP layer handles structured workspace actions reliably. The REST API handles database property updates where the MCP layer can hit validation edge cases. The hybrid strategy means the agent always works. MCP when possible, REST as fallback, unified result either way.


What Happens in Notion When You Set a Focus

  1. Finds or creates your task in the database
  2. Sets Status → In progress and Priority → Week Focus
  3. Writes a personalized AI motivation note to the Notes field
  4. Removes Week Focus from all other tasks (one focus enforced)
  5. Writes to_do blocks inside the task page (real Notion checkboxes)

When all steps are completed, Status → Done and Priority → Medium update automatically. No manual cleanup needed.


Try OneTask Yourself

1. Duplicate the Notion Template

2. Clone the repo:

git clone https://github.com/bilalmez/onetask.git
cd onetask
pip install -r requirements.txt
cp .env.example .env
Enter fullscreen mode Exit fullscreen mode

3. Add your Notion token & database ID in .env

4. Run:

start.bat
Enter fullscreen mode Exit fullscreen mode

5. Open http://localhost:3001

Focus on one goal, let the AI guide you, and actually finish what you start.


Built for the Notion MCP Challenge, March 2026

Top comments (1)

Collapse
 
kenwalger profile image
Ken W Alger

Great use case. Thanks for putting it together with a nice write-up.