Skip to content

Feat/mcp server#1

Merged
maxjneto merged 10 commits into
mainfrom
feat/mcp-server
May 25, 2026
Merged

Feat/mcp server#1
maxjneto merged 10 commits into
mainfrom
feat/mcp-server

Conversation

@maxjneto
Copy link
Copy Markdown
Owner

@maxjneto maxjneto commented May 25, 2026

DocForge MCP Server

This PR ships the DocForge MCP server and the full product surface needed to support it: API key management, agent activity tracking, a harness classification system, and a redesigned frontend.


What's new

MCP Server (packages/mcp)

A Streamable HTTP MCP server that lets AI agents (Claude Code, Cursor, Codex, etc.) create and write to shared DocForge documents in real-time. The user opens the document URL in their browser and watches the agent fill it in live via SSE — no copy-pasting.

  • Tools: create_document, write_section, snapshot_section, get_section_content, list_versions, get_version_content, select_active_version, rename_version, get_activity, get_user_info, get_document_url
  • Resources: docforge://documents, docforge://document/{id}, docforge://document/{id}/versions, docforge://guide/system-prompt (agent orientation brief), docforge://recipes/{slug} (workflow playbooks: safe-rewrite, collaborative-edit, incremental-draft)
  • Prompt: docforge_orientation — surfaces the system-prompt guide via prompts/list so MCP clients can inject it automatically
  • Transport: Streamable HTTP only. Deployed once; users connect via URL + X-API-Key header. stdio removed.

API key system (backend)

  • ApiKey model with name, key_hash (SHA-256), harness, created_at, last_used_at, revoked_at
  • PATCH /users/api-keys/{id} — update harness on an existing key
  • X-API-Key authentication path in auth.py alongside the existing Clerk JWT path
  • DocumentActivity model: records every MCP write, snapshot, and version switch, attributed to the originating API key

Harness field

API keys can be tagged by agent type (claude_code, codex, cursor, generic). The harness value flows through to activity logs, the editor activity rail, and dashboard cards, where each harness renders with its own icon, color, and label.

User activity feed (backend)

  • GET /users/me/activity — cross-document activity feed for the dashboard sidebar, joined with ApiKey.name and Document.title
  • GET /documents now returns has_api_key_activity and last_api_key_name per document, used by the dashboard MCP tab filter

Dashboard redesign (frontend)

HomePage is rebuilt around a two-column layout:

  • Main: TwinModeTabs (All / Forger / MCP Agent), search, DocTableRow cards with harness badges
  • Sidebar: ConnectedAgentsCard (active API keys), RecentActivityCard (live cross-doc feed), DashboardTipCard

The MCP Agent tab filters for editor documents that have had agent activity.

MCP setup page (/mcp)

Dedicated agent configuration hub, tabbed by harness. Each tab shows the exact ~/.claude.json / IDE config snippet for that agent. Users can generate, tag, and revoke API keys without leaving the page.

Billing page (/billing)

Pricing tier cards (Free / Builder / Team). Builder and Team show "Coming soon."

Editor activity rail

EditorActivityRail renders the last 8 activity entries inline in the editor nav panel, refreshed on every SSE tick. Each entry shows the actor name, action, time ago, and a harness-specific icon badge.

Marketing page overhaul

LandingPage, HowItWorksPage, and PricingPage are rewritten using an extracted components/marketing/ library: MarketingNav, TrackPickerCards, PhaseTimelineRow, AgentBadgesStrip, LiveSectionPourMock, McpTeaserCard, ScrollNarratedPhases, McpStepBlocks, ClosingCta, BrandMark.

TopBar navigation

TopBar gains a dashboardNav prop that renders a centered NavLink row (Dashboard / How it works / DocForge MCP / Billing) when no document phase is active.

CI/CD

GitHub Actions workflow (deploy-mcp.yml) builds and deploys the MCP server on push to main.


Database migrations

Migration Change
015_add_api_keys api_keys table
016_add_document_activity document_activity table
017_add_api_key_harness harness column on api_keys

Run npm run db:migrate before starting the backend.


Test plan

  • Generate an API key in the UI (/mcp) — verify it appears in ConnectedAgentsCard
  • Connect the MCP server with X-API-Key header — verify create_document + write_section work and SSE pushes to the browser
  • Confirm activity entries appear in the editor rail and RecentActivityCard with correct harness badge
  • Dashboard MCP tab filters correctly (only editor docs with agent activity)
  • Revoke a key — confirm subsequent requests are rejected
  • Run npm run db:migrate on a clean DB — all three migrations apply cleanly

maxjneto and others added 10 commits May 21, 2026 23:00
- Introduced ApiKeyPanel component for managing API keys.
- Updated TopBar to include a button for opening the API key management panel.
- Enhanced useDocument hook to track SSE ticks.
- Modified DocumentPage to pass SSE tick to EditorLayout.
- Added API key types and responses to types/index.ts.
- Implemented API functions for creating, listing, and revoking API keys.
- Created Dockerfile and README for the new MCP server.
- Developed the MCP server with tools for AI agents to interact with DocForge documents.
- Added comprehensive tool reference documentation for MCP server.
Remove the stdio entry point and DOCFORGE_API_KEY env-var fallback — the
server is HTTP-only. Add `docforge_mcp/resources/` with a system-prompt
guide and three workflow recipes (safe-rewrite, collaborative-edit,
incremental-draft), exposed via MCP resources and a `docforge_orientation`
prompt so clients can inject them automatically. TOOLS.md updated with the
new resource table and three new tool entries (get_version_content,
rename_version, get_activity).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add nullable `harness` column to the `api_keys` table (migration 017) to
tag keys by agent type (claude_code, codex, cursor, generic). The harness
value is stored on create, patchable via PATCH /users/api-keys/{id}, and
forwarded in activity log responses. Also adds GET /users/me/activity — a
cross-document activity feed for the dashboard sidebar — and enriches
GET /documents with `has_api_key_activity` + `last_api_key_name` per doc.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add harness.ts with the Harness enum, per-harness visual metadata
(label, logo path, colors) and isHarness() guard. Propagate `harness`
through all API types (ApiKey, ApiKeyCreateResponse, DocumentActivity)
and add MyActivityEvent for the cross-doc feed. New API calls:
apiUpdateApiKeyHarness, apiFetchMyActivity; apiCreateApiKey now accepts
an optional harness param.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the flat document table with a two-column layout: a main area
with TwinModeTabs (All / Forger / MCP Agent) + DocTableRow cards, and a
sidebar with ConnectedAgentsCard (active API keys), RecentActivityCard
(cross-doc feed via GET /users/me/activity), and DashboardTipCard. The
MCP tab filters for editor documents that have had agent activity, using
the new hasApiKeyActivity field from the backend.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
McpPage (/mcp) is a dedicated agent setup hub: tabbed by harness
(Claude Code, Codex, Cursor, Generic), shows tailored config snippets,
and handles API key generation with harness tagging + revocation. Existing
keys can have their harness updated inline. BillingPage (/billing) renders
the pricing tiers with a placeholder for future payment integration. Both
routes are protected and registered in App.tsx.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… to TopBar

EditorActivityRail shows the last 8 activity entries in the editor nav
panel, styled with per-harness icons and colors and refreshed on every
SSE tick. EditorNavPanel gains an activitySlot prop; EditorLayout wires it
up. TopBar gains a dashboardNav prop that renders a centered NavLink row
(Dashboard / How it works / DocForge MCP / Billing) when no phase is
active. index.css adds df-scroll-thin and marketing-page keyframe
animations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract all inline JSX from LandingPage, HowItWorksPage, and PricingPage
into a reusable marketing component library (BrandMark, MarketingNav,
TrackPickerCards, PhaseTimelineRow, AgentBadgesStrip, LiveSectionPourMock,
McpTeaserCard, ScrollNarratedPhases, McpStepBlocks, ClosingCta). Add
supporting SVG assets (claudecode.svg, codex.svg, cursor.svg, robot.svg)
for harness badges. Pages are now significantly leaner, delegating all
visual logic to their respective components.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@maxjneto maxjneto merged commit 8889cc9 into main May 25, 2026
2 checks passed
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