MCP Task Queue — EC2 + SSE

MCP Task Queue — EC2 + SSE

Enables Cursor on your laptop to connect to an MCP server on EC2 via SSE/HTTPS to manage a task queue stored in Postgres, supporting task listing, status updates, and work prompt generation.

Category
访问服务器

README

MCP Task Queue — EC2 + SSE

Pure Python MCP setup so Cursor on your laptop works on tasks stored in a Postgres DB on EC2. Cursor talks MCP over SSE/HTTPS to the EC2 MCP server; it never touches Postgres directly.

Architecture

Jira Issue
    ↓
n8n Workflow (triggered by Jira)
    ↓ HTTP POST /ingest
EC2: Ingest API (FastAPI) — validates, normalizes, writes to Postgres
    ↓
EC2: Postgres — tasks table (pending, in_progress, completed, failed)
    ↑
EC2: MCP Server (SSE) — tools operate on tasks, exposes /mcp/sse
    ↑ SSE/HTTPS
Laptop: Cursor — configured to connect to EC2 MCP server

Project layout

app/
  __init__.py
  config.py       # DATABASE_URL, INGEST_TOKEN
  database.py     # async Postgres task CRUD
  ingest_api.py   # FastAPI routes: /health, POST /ingest
  mcp_server.py   # FastMCP with tools (list_tasks, get_task, ...)
  mcp_sse.py      # SSE transport wiring

ingest_app.py     # Entry: uvicorn ingest_app:app
mcp_sse_app.py    # Entry: uvicorn mcp_sse_app:app
init_db.py        # Create tasks table
env.example       # Template for .env

Install

python -m venv .venv
source .venv/bin/activate   # Windows: .\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
cp env.example .env
# Edit .env: DATABASE_URL, INGEST_TOKEN

Database migrations

Create the tasks table once:

python init_db.py

Schema: id, source, title, instructions, acceptance_criteria (JSONB), file_hints (JSONB), meta (JSONB), status, timestamps (created_at, started_at, completed_at, failed_at, updated_at), completion_note, failure_reason, previous_status.

Run the services

Ingest API (n8n webhook)

uvicorn ingest_app:app --host 0.0.0.0 --port 8787
  • GET /health — health check
  • POST /ingest — requires header X-Ingest-Token: <INGEST_TOKEN>

MCP SSE server (Cursor endpoint)

uvicorn mcp_sse_app:app --host 0.0.0.0 --port 8080
  • GET /health — health check
  • GET /mcp/sse — MCP SSE endpoint (Cursor connects here)
  • POST /mcp/messages/ — MCP message endpoint (used by client after SSE)

Configure Cursor (client)

Configure Cursor on your laptop to talk to the EC2 MCP server over SSE. Copy mcp.json.example to .cursor/mcp.json or add to global MCP settings:

{
  "mcpServers": {
    "ec2-tasks": {
      "url": "https://<YOUR_DOMAIN_OR_IP>/mcp/sse",
      "env": {}
    }
  }
}

Replace <YOUR_DOMAIN_OR_IP> with your EC2 hostname or IP. If using a non-standard port, include it: https://example.com:8080/mcp/sse. For local dev: http://localhost:8080/mcp/sse.

Important: Cursor connects to the EC2 MCP server over SSE/HTTPS. EC2 talks to Postgres; Cursor never touches the database.

Rules & work prompt

Edit rules.md in the project root to add rules and instructions the MCP server will include in work prompts. This content is combined with each task and passed to the agent.

  • MCP prompt task_work_prompt(task_id) — Returns the full prompt (rules + task) to pass to the agent.
  • Tool get_work_prompt(task_id) — Same content as JSON for programmatic use.

MCP tools

Tool Description
list_tasks List tasks (inbox by default; filter by status)
get_task Get full task by id
get_work_prompt Build full prompt (rules + task) for a task id
enqueue_task Manually create a task (for testing)
start_task Set status to in_progress
complete_task Set status to completed
fail_task Set status to failed

n8n HTTP Request (Jira → ingest)

  • Method: POST
  • URL: https://<YOUR_EC2>/ingest (or via ngrok / load balancer)
  • Headers: Content-Type: application/json, X-Ingest-Token: <INGEST_TOKEN>
  • Body: JSON with at least id, instructions; optional source, title, acceptance_criteria, file_hints, meta

EC2 deployment notes

  1. Environment: Set DATABASE_URL and INGEST_TOKEN (e.g. via .env or systemd env).
  2. Processes:
    • Ingest: uvicorn ingest_app:app --host 0.0.0.0 --port 8787
    • MCP SSE: uvicorn mcp_sse_app:app --host 0.0.0.0 --port 8080
  3. Reverse proxy (Nginx):
    • Proxy /ingest and /health to ingest on 8787.
    • Proxy /mcp/sse and /mcp/messages/ to MCP on 8080.
    • Use HTTPS and keep MCP paths under the same origin.
  4. ngrok:
    • Expose both ports or put a reverse proxy in front and expose one.
    • Example: ngrok http 8080 for MCP, ngrok http 8787 for ingest (separate tunnels).

Ingest behavior

  • New task → insert as pending.
  • Existing, status pending or in_progress → return duplicate error (no overwrite).
  • Existing, status completed or failed → upsert as new pending version, preserve previous_status.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选