AFK Mode

AFK Mode

An MCP server that bridges VS Code Copilot to your mobile device, allowing you to monitor task progress and respond to decision prompts while away from your desk. It features real-time push notifications, a web-based dashboard, and interactive tools for remote code review and approval.

Category
访问服务器

README

AFK Mode

Monitor and respond to VS Code Copilot from your phone.

When Copilot's agent mode runs long tasks, it frequently pauses for user input. If you step away, the session stalls. AFK Mode bridges Copilot and your phone through an MCP server — so you can watch progress, get notifications, and respond to prompts without being at your desk.

Quick Start

One-command setup

Run this in your project folder:

npx afk-mode-mcp --setup

This creates .vscode/mcp.json and .github/prompts/afk-workflow.prompt.md — done. Copilot will start AFK Mode automatically when it needs it.

Usage

  1. Ask Copilot: "Show me the AFK app link" → scan the QR code on your phone
  2. Toggle AFK Mode on in the app
  3. Start a task with /afk-workflow — Copilot routes all progress and decisions to your phone

Push notifications work automatically — no extra setup needed.

Manual setup (alternative)

If you prefer to configure manually, add this to .vscode/mcp.json in your workspace:

{
  "servers": {
    "afk-mode-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "afk-mode-mcp"],
      "env": {
        "AFK_PORT": "7842"
      }
    }
  }
}

How It Works

AFK Mode is a single Node.js process that serves two roles simultaneously:

  1. MCP Server (stdio) — Exposes tools that Copilot calls to report progress and request decisions
  2. Web App Server (HTTP + WebSocket) — Serves a React PWA and maintains a real-time connection with your phone
┌──────────────┐     stdio      ┌──────────────────────┐    WebSocket     ┌──────────────┐
│  VS Code     │◄──────────────►│  MCP + Web Server    │◄────────────────►│  Mobile Web  │
│  Copilot     │                │  (single process)    │    HTTP (static) │  App (PWA)   │
│  Agent Mode  │                │                      │◄────────────────►│              │
└──────────────┘                └──────────────────────┘                  └──────────────┘
  1. Copilot starts the MCP server → HTTP/WebSocket server starts automatically on port 7842
  2. Ask Copilot "Show me the AFK app link" → it calls get_current_web_app_url and renders a QR code
  3. Scan the QR code on your phone → the PWA connects via WebSocket
  4. Toggle AFK Mode on in the app → Copilot routes interactions through your phone
  5. Copilot sends progress updates and decision prompts to your phone in real time
  6. Toggle AFK Mode off → Copilot goes back to the normal VS Code chat panel

MCP Tools

The server exposes 4 tools to Copilot:

Tool Purpose
get_current_web_app_url Returns the connection URL + QR code for pairing your phone
get_afk_status Checks if AFK mode is on and a client is connected
notify_session_progress Sends a progress update to the phone (info, warning, error, success, milestone)
get_user_decision Asks the user a question and blocks until they respond (confirm, choice, text, or diff review)

notify_session_progress

Sends real-time progress to the phone. Categories control the icon and urgency:

  • info — general status (ℹ️)
  • success — task completed (✅)
  • error — something failed (❌)
  • milestone — significant achievement (🎯)
  • warning — needs attention (⚠️)

Supports optional progress bars ({ current, total, label }) and file change lists.

get_user_decision

Blocks Copilot until the user responds on their phone. Decision types:

  • confirm — Yes/No
  • choice — Pick from a list of options
  • text — Free-form text input
  • diff — Review a code diff and approve/reject

Includes a configurable timeout (default 5 minutes) with an optional default value.

Web App Features

  • Dashboard — AFK toggle, live progress feed with category icons and progress bars
  • Decision prompts — Modal overlay with countdown timer, vibration alert
  • Diff viewer — Unified diff with syntax coloring for code review decisions
  • History — Searchable/filterable log of all progress entries (persisted in localStorage)
  • Settings — Verbosity, sound, vibration, theme (light/dark/system)
  • PWA — Installable to home screen, works offline via service worker (network-first caching)

Push Notifications

Push notifications alert you on your phone even when the browser tab is in the background (e.g., for errors or pending decisions). They work out of the box — no configuration required.

Push uses the Web Push standard with VAPID (Voluntary Application Server Identification). VAPID is an open W3C standard — no Google account, Firebase setup, or API keys required.

How it works

  1. Server auto-generates a VAPID key pair on each startup
  2. Client fetches the public key from /api/vapid-key and subscribes via the Push API
  3. Browser returns an FCM/Mozilla/Apple push endpoint — stored on the server
  4. Server sends encrypted payloads to the endpoint when needed
  5. Service worker receives the push and shows a system notification

Since VAPID keys are generated per session (and push subscriptions are in-memory), each developer runs an isolated instance — no shared secrets, no cross-talk between team members.

Security

  • Session token — 256-bit random token generated per server instance, required for the initial WebSocket connection
  • Single device — Only one phone can connect at a time (409 Conflict for second connections)
  • Reconnect tickets — Rotating one-time tickets for seamless reconnection after network drops (expires after 5 minutes, invalidated after use)
  • Local network only — The server binds to your machine's local IP; no internet exposure

Environment Variables

Variable Default Description
AFK_PORT 7842 HTTP/WebSocket server port

Development (for contributors)

git clone <repo-url> && cd afk-mode-mcp
pnpm install

# Run server with hot reload
pnpm dev:server

# Run webapp dev server (Vite, port 5173)
pnpm dev:webapp

# Build everything
pnpm build

# Start production server
pnpm start

# Lint and format
pnpm lint             # Check for lint errors
pnpm lint:fix         # Auto-fix lint errors
pnpm format           # Format all source files
pnpm format:check     # Check formatting without writing

Tech Stack

  • Server: Node.js, Express 5, WebSocket (ws), @modelcontextprotocol/sdk
  • Web App: React 19, Vite 7, MUI (Material UI) 7, Emotion
  • Build: tsup (server), Vite (webapp)
  • Lint: ESLint 10 with typescript-eslint + React Hooks plugin
  • Format: Prettier
  • Push: web-push with VAPID
  • QR: qrcode (data-URI PNG)

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选