Skip to content

Add cloud backend: remote MCP server on Cloudflare Workers - #6

Closed
odfalik wants to merge 15 commits into
mainfrom
cloud-mcp-server
Closed

odfalik wants to merge 15 commits into
mainfrom
cloud-mcp-server

Conversation

@odfalik

@odfalik odfalik commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Remote MCP server via Cloudflare Workers (McpAgent + Streamable HTTP transport)
  • Web UI with paper browser, markdown viewer, and RAG chat (Claude + OpenAI streaming)
  • Full search stack: grep + RAG + hybrid, using Workers AI embeddings + Vectorize
  • Container setup for Marker PDF conversion (ready, pending CF Containers beta access)
  • 80 papers migrated and live at the deployed Worker URL

Services used

D1 (metadata + grep), R2 (PDF/image storage), Vectorize (vector search), Workers AI (bge-small-en-v1.5 embeddings), Durable Objects (McpAgent)

Test plan

  • Worker deploys and responds
  • Auth rejects unauthorized requests
  • Paper upload (markdown) → indexes + embeds in ~2s
  • 80 papers migrated with 0 errors
  • MCP tools/list returns search, get_paper_info, list_papers
  • MCP search returns hybrid results with line numbers + header context
  • Web UI loads, lists papers, renders markdown
  • RAG chat streams responses from Claude and OpenAI
  • TypeScript compiles clean, wrangler dry-run passes

odfalik added 15 commits April 9, 2026 12:29
Move Paper Intelligence to the cloud using Cloudflare's infrastructure:

- **Remote MCP server** via McpAgent (Streamable HTTP transport)
  - search, get_paper_info, list_papers tools
  - Bearer token auth
- **Search**: grep + RAG + hybrid (faithful port of Python logic)
  - Workers AI embeddings (@cf/baai/bge-small-en-v1.5)
  - Vectorize for vector search
  - D1 for markdown grep + metadata
- **Web UI** at root URL
  - Paper browser with markdown viewer
  - RAG chat with streaming (Claude + OpenAI)
  - Model selector, token-based auth
- **Container setup** for Marker PDF conversion (ready, pending CF Containers beta)
- **Migration script** to upload local papers to cloud

Services: D1, R2, Vectorize, Workers AI, Durable Objects
- Auto-parse paper titles from first H1 heading, display instead of filenames
- User-settable aliases via PATCH /papers/:id and rename UI
- Document outline panel (TOC) from parsed headers with click-to-scroll
- PDF/Markdown toggle viewer with PDF served from R2
- Chat moved to right-side vertical panel
- Processing status with live polling and animated indicators
- D1 schema: added title and alias columns to papers table
- Re-enable Marker Container in wrangler.jsonc (Workers Paid plan activated)
- Fix Vectorize deleteByIds batch size: 100, not 1000
- Clean markdown/HTML artifacts from auto-parsed titles
- Migration script now uploads both markdown + PDF per paper
- Re-uploaded 79 papers with PDFs for viewer toggle
- PDF viewer: fetch via JS with auth header, display via blob URL (fixes iframe 401)
- Marker container: load models at import time with gunicorn --preload
  (eliminates per-request model loading delay on first conversion)
- Increase container sleepAfter to 30m to keep models warm between uses
- Deep forest green (#004d3b) accent, warm off-white (#f2f1ed) canvas
- Restrained typography with generous spacing and flat surfaces
- 4px border radius on buttons/inputs, no shadows
- Remove model selector — hardcode Claude Opus 4.6
- Consistent toolbar-btn class for Outline/Chat toggles
- Warmer color palette throughout (green status dots, green active states)
- Replace raw HTML string with proper React SPA (Vite + TypeScript)
- Tailwind CSS with Strand AI design tokens (deep green, warm off-white)
- react-markdown + rehype-raw + remark-gfm for proper markdown rendering
- Lucide icons for toolbar actions
- Multi-file PDF upload modal with progress indicators
- Fuzzy search in paper sidebar
- Rename button always visible (not hidden by truncation)
- Alias input auto-populated with current title
- PDF default view with navpanes=0 (no thumbnail sidebar)
- Static assets served via wrangler assets config
- Chat hardcoded to Claude Opus 4.6
- cloud/mcp-upload.mjs: local stdio MCP server that reads PDFs from disk
  and POSTs them to the cloud Worker REST endpoint (multipart form)
- Supports multi-file uploads via paths array
- Reads API token from env or 1Password
- Removed upload_paper from remote MCP server (can't handle local files)
Architecture change: single local stdio MCP server that wraps the cloud
REST API, replacing the remote McpAgent on the Worker.

Worker changes:
- Add POST /search REST endpoint
- Remove McpAgent Durable Object (deleted_classes migration v5)
- Remove agents + @modelcontextprotocol/sdk Worker dependencies
- Delete src/mcp.ts

Local MCP server (mcp-server/):
- Node.js stdio MCP server, 5 tools: search, list_papers, upload_paper,
  delete_paper, rename_paper
- Reads PDFs from local disk for upload (no base64 size limits)
- Resolves paper names by fuzzy matching name/title/alias
- Auth via env var or 1Password fallback
- Publishable as npm package "paper-intelligence"

Cleanup:
- Remove cloud/mcp-upload.mjs (superseded)
- Remove paper-intelligence-cloud and paper-intelligence-upload MCP registrations
@odfalik

odfalik commented Apr 18, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by cloud-storage branch approach (rclone R2 sync)

@odfalik odfalik closed this Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant