File size: 10,576 Bytes
c855501
 
 
8cdbc9a
086f0a3
c855501
 
 
a8072e2
086f0a3
 
 
 
 
 
 
 
 
 
c855501
a8072e2
0491e54
 
a8072e2
0491e54
 
 
 
a8072e2
 
 
c498876
a8072e2
086f0a3
 
 
0491e54
 
 
a8072e2
 
 
 
 
 
 
0491e54
 
 
a8072e2
 
0491e54
 
 
 
 
a8072e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0491e54
a8072e2
 
 
 
 
 
 
 
 
 
 
 
0491e54
 
a8072e2
0491e54
a8072e2
0491e54
a8072e2
 
0491e54
a8072e2
0491e54
 
 
 
 
 
 
 
 
a8072e2
0491e54
 
 
a8072e2
0491e54
a8072e2
 
 
 
 
0491e54
a8072e2
0491e54
a8072e2
0491e54
a8072e2
 
 
 
 
0491e54
a8072e2
0491e54
a8072e2
0491e54
a8072e2
0491e54
a8072e2
0491e54
a8072e2
 
 
 
 
0491e54
 
 
 
 
a8072e2
0491e54
 
 
1c346a7
 
a8072e2
1c346a7
 
 
 
 
 
 
 
 
 
 
 
 
a8072e2
0491e54
a8072e2
0491e54
a8072e2
 
 
 
 
 
 
 
0491e54
a8072e2
0491e54
a8072e2
 
 
0491e54
a8072e2
0491e54
a8072e2
0491e54
a8072e2
 
 
 
 
 
0491e54
 
a8072e2
 
 
 
 
 
 
 
0491e54
 
a8072e2
0491e54
a8072e2
0491e54
a8072e2
 
 
0491e54
a8072e2
0491e54
a8072e2
 
 
0491e54
a8072e2
 
 
0491e54
a8072e2
0491e54
a8072e2
0491e54
a8072e2
0491e54
a8072e2
 
0491e54
a8072e2
0491e54
a8072e2
 
 
0491e54
a8072e2
0491e54
a8072e2
0491e54
a8072e2
0491e54
 
a8072e2
0491e54
a8072e2
 
 
 
0491e54
a8072e2
 
0491e54
 
a8072e2
 
 
 
0491e54
a8072e2
 
0491e54
 
 
 
a8072e2
 
 
 
0491e54
 
 
a8072e2
0491e54
 
 
 
 
 
 
 
c216959
a8072e2
c855501
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
---
license: mit
title: FocusFlow AI
sdk: docker
emoji: πŸ‘€
colorFrom: indigo
colorTo: blue
short_description: FocusFlow is AI productivity helper + task tracker MCP
tags:
- mcp-in-action-track-consumer
- mcp-in-action-track-creative
- building-mcp-track-consumer
- building-mcp-track-creative
- anthropic
- gemini
- openai
- elevenlabs
thumbnail: >-
  https://cdn-uploads.huggingface.co/production/uploads/64e5b6b857d6d38e126ca802/6MD7sz2ThFOglZ2D6ZEve.png
---

# πŸ¦‰ FocusFlow - AI Productivity Accountability Agent

**Your Duolingo-style AI buddy that keeps you focused while coding.**

[![Gradio](https://img.shields.io/badge/Built%20with-Gradio-orange)](https://gradio.app)
[![MCP](https://img.shields.io/badge/MCP-Enabled-blue)](https://modelcontextprotocol.io)
[![Python](https://img.shields.io/badge/Python-3.11+-green)](https://python.org)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

[![](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/MCP-1st-Birthday/FocusFlowAI)
[![](https://img.shields.io/badge/github-repo-blue?label=GitHub)](https://github.com/Rebell-Leader/FocusFlow)

Link to demo video: [YouTube](https://youtu.be/wb8vGpcL_as)
Link to LinkedIn post: [LInkedIn](https://www.linkedin.com/posts/airat-v-7a28b7185_focusflowai-activity-7400951579425550338-oS1f)
Link to X: [X](https://x.com/Valiev7Airat/status/1995211325002354925?s=20)

## 🎯 The Problem

**"I'll just check Reddit for 5 minutes while wait for inspiration..." -> 3 hours later.**

Developers and creators often struggle with:
- **Task Paralysis**: Overwhelmed by big projects.
- **Context Switching**: Getting lost in unrelated rabbit holes.
- **Lack of Accountability**: No one to gently nudge you back to work.
- **"Busy" vs. Productive**: Doing work that doesn't actually move the needle.

## ✨ The Solution

**FocusFlow** is an AI-powered productivity partner that monitors your **actual work** (file changes, git commits) and gently nudges you when you drift off track. It's not a micromanager; it's a friendly companion that helps you maintain momentum.

1. **Breaks down projects** into 5-8 micro-tasks (15-30 min each)
2. **Monitors your workspace** in real-time (file changes or text input)
3. **Provides Duolingo-style nudges** when you get distracted or idle
4. **Tracks focus metrics** with streaks, scores, and visualizations
5. **Integrates with LLMs** via MCP (Model Context Protocol) for natural language task management
6. **Integrates with Linear MCP** for project management

## πŸš€ Features

| Feature | Description |
| :--- | :--- |
| πŸ¦‰ **Duolingo-style Nudges** | Friendly, personality-driven reminders to stay on track. |
| πŸ”— **MCP Integration** | Connects with tools like Claude Desktop for natural language task execution and  management. |
| πŸ“‹ **Linear Sync** | Import projects and tasks directly from Linear (via API). |
| πŸ‘οΈ **Focus Monitoring** | Real-time file system monitoring to detect actual work. |
| πŸ›‘οΈ **Privacy First** | Support for local LLMs (Ollama) or private API keys. |
| πŸ… **Pomodoro Timer** | Built-in timer with break reminders and audio alerts. |
| πŸ“Š **Productivity Stats** | Track streaks, focus scores, and daily progress. |
| πŸ—£οΈ **Voice Feedback** | (Optional) ElevenLabs integration for spoken encouragement. |

## πŸ—οΈ Architecture

```ascii
+----------------+      +------------------+      +----------------+
| Claude Desktop | <--> | FocusFlow (MCP)  | <--> | Linear API     |
| (MCP Client)   |      | (Gradio App)     |      | (Task Source)  |
+----------------+      +------------------+      +----------------+
       ^                        |
       |                        v
       |                +------------------+
       |                | Local File Sys   |
       |                | (Watchdog)       |
       |                +------------------+
       |                        |
       |                        v
+----------------+      +------------------+
| User Workspace | <--> | AI Agent Logic   |
| (Code/Docs)    |      | (LLM / Mock)     |
+----------------+      +------------------+
```

```
focusflow/
β”œβ”€β”€ app.py              # Main Gradio application
β”œβ”€β”€ agent.py            # AI focus agent (OpenAI/Anthropic/Mock)
β”œβ”€β”€ storage.py          # Task manager with SQLite
β”œβ”€β”€ monitor.py          # File monitoring with watchdog
β”œβ”€β”€ metrics.py          # Productivity tracking
β”œβ”€β”€ mcp_tools.py        # MCP tools and resources
β”œβ”€β”€ requirements.txt    # Python dependencies
β”œβ”€β”€ .env.example        # Environment template
└── README.md           # This file
```


## ⚑ Quick Start

### 1. Installation

**Option A: Hugging Face Spaces (Try it now!)**
Click the "Try It" button above to run the demo version in your browser.

**Option B: Local Setup (Recommended for full features)**

```bash
# Clone the repository
git clone https://github.com/Rebell-Leader/FocusFlow.git
cd FocusFlow

# Install dependencies
pip install -r requirements.txt

# Run the app
python app.py
```

### 2. Onboarding

1.  Open `http://localhost:5000`.
2.  **Home Tab**: Check your AI provider status.
3.  **Onboarding Tab**: Describe your project (e.g., "Build a React Native weather app") or import from Linear.
4.  **Task Manager**: See your decomposed micro-tasks.
5.  **Monitor**: Start working! FocusFlow will watch your file changes and update your status.

## πŸ›‘οΈ Privacy & AI Providers

FocusFlow gives you full control over your data.

| Mode | Description | Best For |
| :--- | :--- | :--- |
| **Local (Ollama/vLLM)** | Runs 100% on your machine. No data leaves your network. | πŸ”’ Maximum Privacy |
| **Cloud (OpenAI/Anthropic/Gemini)** | Uses external APIs for smarter reasoning. | 🧠 Best Performance |
| **Mock AI** | Uses predefined responses. No API keys needed. | πŸ§ͺ Testing / Demos |

To configure, set `AI_PROVIDER` in your `.env` file (see below).

## πŸ”Œ MCP Server Documentation

FocusFlow implements the **Model Context Protocol (MCP)**, allowing you to control it directly from Claude Desktop or other MCP clients.

### Connection Guide (Claude Desktop)

1.  **Prerequisite**: Ensure FocusFlow is running (`python app.py`).
2.  **Locate Config**:
    *   **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
    *   **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
3.  **Add Server**:

```json
{
  "mcpServers": {
    "focusflow": {
      "url": "http://<YOUR_LOCAL_IP>:5000/gradio_api/mcp"
    }
  }
}
```

*Note: If running on WSL, you may need to use the SSE endpoint URL instead.*
```json
  "mcpServers": {
    "focusflow": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://172.30.9.188:5000/gradio_api/mcp",
        "--allow-http"
      ]
    }
  }
```

*Replace `<YOUR_LOCAL_IP>` with the IP address of your local machine or WSL (e.g., `172.x.x.x`).*

### Exposed Tools

| Tool | Signature | Description |
| :--- | :--- | :--- |
| `add_task` | `(title: str, description: str, duration: int)` | Create a new task. |
| `get_current_task` | `()` | Get the currently active task details. |
| `start_task` | `(task_id: int)` | Mark a task as 'In Progress'. |
| `mark_task_done` | `(task_id: int)` | Complete a task. |
| `get_all_tasks` | `()` | List all tasks and statuses. |
| `get_productivity_stats` | `()` | Get focus scores and streaks. |

### Exposed Resources

- `focusflow://tasks/all`: JSON list of all tasks.
- `focusflow://tasks/active`: JSON details of active task.
- `focusflow://stats`: Current productivity metrics.

### API Response Format

Tools return strings that are formatted for human/LLM reading, but resources return JSON.

**Example `get_current_task` response:**
```text
πŸ“‹ Current Active Task:
- ID: 12
- Title: Implement Auth
- Status: In Progress
```

**Example `focusflow://tasks/active` resource:**
```json
{
  "id": 12,
  "title": "Implement Auth",
  "status": "In Progress",
  "estimated_duration": "30 min"
}
```

### Error Handling

All tools return descriptive error messages starting with `❌` if something goes wrong.

- **Task Not Found**: `❌ Task 99 not found. Use get_all_tasks() to see available tasks.`
- **Invalid Status**: `❌ Failed to start task. Task is already marked as Done.`
- **System Error**: `❌ Error creating task: [Error Details]`

### Example Usage (Claude)

> **User**: "What should I be working on?"
>
> **Claude**: (Calls `get_current_task`) "You are currently working on 'Implement Auth Middleware'. You've been focused for 15 minutes."

> **User**: "Add a task to fix the login bug."
>
> **Claude**: (Calls `add_task`) "Added 'Fix login bug' to your list."

## πŸ“‹ Linear Integration

FocusFlow integrates with Linear via their **GraphQL API** to sync your projects and tasks.

### Setup

1.  Get your **Linear API Key**: [https://linear.app/settings/api](https://linear.app/settings/api)
2.  Add it to your `.env` file: `LINEAR_API_KEY=lin_api_...`

### How it Works

1.  **Import**: In the "Onboarding" tab, FocusFlow fetches your Linear projects using `viewer { projects }`.
2.  **Sync**: It pulls active issues using `project { issues }`.
3.  **Create**: You can create new tasks in FocusFlow, which pushes them to Linear via `issueCreate`.

*(Screenshots of Linear import flow would go here)*

## βš™οΈ Configuration

Copy `.env.example` to `.env` and configure your preferences:

```bash
# .env example

# --- Launch Mode ---
# 'local': Monitors file system changes (Best for personal use)
# 'demo': Text-area simulation (Best for Hugging Face Spaces)
LAUNCH_MODE=local

# --- AI Provider ---
# Options: openai, anthropic, gemini, vllm, mock
AI_PROVIDER=anthropic

# --- API Keys ---
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
LINEAR_API_KEY=lin_api_...

# --- MCP ---
ENABLE_MCP=true
```

## 🀝 Contributing

Contributions are welcome!
1.  Fork the repo.
2.  Create a feature branch.
3.  Submit a Pull Request.

## πŸ“„ License

MIT License. See [LICENSE](LICENSE) for details.

## πŸ™ Acknowledgments

- Built for the [Gradio MCP Hackathon](https://gradio.app) - competing for **Track 1: Building MCP**
- Voice integration powered by [ElevenLabs](https://elevenlabs.io) - competing for **$2,000 Best Use of ElevenLabs** sponsor award
- Inspired by Duolingo's encouraging UX
- Uses [Model Context Protocol](https://modelcontextprotocol.io) for LLM integration

---
**Made with ❀️ for the Gradio MCP Hackathon.**
*Hoot hoot!* πŸ¦‰