This is a working backend that follows the MCP-style tool pattern described in the design doc. It exposes a small set of agent tools via HTTP, runs an async worker/scheduler, and includes a mock Instagram connector. It uses SQLite for storage and is self-contained — no external services required.
- MCP-like tools (HTTP endpoints) the agent (or you) can call:
repurpose_reel_to_post— turn a "reel transcript" into a cross-platform post + hashtags.schedule_post— persist a scheduled post and enqueue a publishing task at the given time.publish_reel— immediately publish via a platform connector (mock Instagram here).fetch_engagement_metrics— returns fake metrics and stores analytics.
- Agent — a tiny heuristic caption/hashtag generator with A/B option.
- Scheduler & Worker — in-process asyncio scheduler + queue; safe for single-instance demos.
- Connectors — base class + Instagram mock (logs instead of calling real APIs).
- Storage — SQLite with SQLAlchemy models for posts, schedules, analytics.
- FastAPI — OpenAPI docs at
/docsfor quick testing.
Notes
- This MVP avoids real platform APIs so it runs anywhere. Swap the mock connector with real implementations later.
- For multi-instance production, replace the scheduler with a durable queue (Redis/Rabbit/Kafka) and a separate worker process.
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
uvicorn app.main:app --reloadOpen http://127.0.0.1:8000/docs to try endpoints.
docker build -t content-agent .
docker run -p 8000:8000 content-agentPOST /tools/repurpose_reel_to_postPOST /tools/schedule_postPOST /tools/publish_reelGET /tools/fetch_engagement_metricsGET /health
- Call
POST /tools/repurpose_reel_to_postwith a transcript to get platform-optimized text. - Call
POST /tools/schedule_post(orpublish_reel) with the content. - The in-process scheduler triggers the worker which calls the mock connector.
- Check
/tools/fetch_engagement_metrics?post_id=...for (fake) analytics.
- Implement
PlatformConnectorfor platforms (Instagram, TikTok, YouTube). - Register in
app/services/registry.py.
app/
main.py # FastAPI app, background workers, routes
db.py # SQLite engine + session
models/ # SQLAlchemy models
connectors/ # Base + Instagram mock
services/
registry.py # MCP-like tool registry
scheduler.py # Async scheduler + worker
agent.py # Simple caption/hashtag logic
media.py # (stub) media helpers
analytics.py # Analytics collection helpers
utils/time.py # helpers for timezone-aware scheduling
requirements.txt
Dockerfile
README.md
MIT — do whatever you want, no warranty.