Skip to content

mcp: real MCP server at /api/mcp exposing Promote (write + post to socials) - #108

Merged
ralyodio merged 1 commit into
masterfrom
mcp/promote-server
Jul 17, 2026
Merged

ralyodio merged 1 commit into
masterfrom
mcp/promote-server

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

What

A real Model Context Protocol server — built on the official @modelcontextprotocol/sdk via the mcp-handler Next adapter — mounted on the existing app at https://crawlproof.com/api/mcp. No new Railway service; same instance. Agents connect with your existing crp_ API token and get the Promote toolset, scoped to that user's own connected socials.

The user story works end to end:

"Write me a promo post for pairux.com and post it on my socials using the crawlproof MCP server."
→ the agent calls promote_url({ url }) and gets a per-account result.

Tools (module: promote)

  • list_accounts — the caller's connected accounts (platform/handle/id)
  • generate_promo_post — write an on-brand post for a URL (no publish)
  • post_to_socials — publish given text to all/account_ids
  • promote_url — one shot: write a per-platform variant per account and publish

All reuse the same generatePitch + postViaAccount pipeline as in-app Promote (cookie-auth platforms surface as queued).

How it's wired

  • app/api/mcp/route.ts — createMcpHandler(registerPromoteTools) wrapped in withMcpAuth(verifyToken, { required: true }); the verifier resolves the crp_ bearer via the existing sp_api_token auth and stashes userId on authInfo.
  • lib/mcp/promote.ts — registerPromoteTools(server); more capabilities drop in as additional registerXxxTools modules.
  • lib/sp/apiAuth.ts — extracted authenticateToken(token) (shared by the v1 API and the MCP verifier).
  • docs/mcp.md — connect-your-agent guide (URL + Bearer header, or mcp-remote bridge).

Deploy impact

Zero infra change — one new Next route on the existing web+worker service. Auth reuses the existing token scheme; no migration. Needs ANTHROPIC_API_KEY/OPENAI_API_KEY in the web env for generation (the worker already has them).

Verified

tsc clean · next build compiles /api/mcp · contract test registers the tools against the real SDK and discovers them over an in-memory MCP transport (4/4 tools + schemas).

🤖 Generated with Claude Code

A Model Context Protocol server built on the official @modelcontextprotocol/sdk
(via the mcp-handler Next adapter), mounted on the existing app — no new Railway
service. Agents connect at https://crawlproof.com/api/mcp with a crp_ API token
(the existing sp_api_token bearer auth) and get the Promote toolset, scoped to
that user's own connected socials.

Tools (module: promote): list_accounts, generate_promo_post, post_to_socials,
promote_url — reusing the same generatePitch + postViaAccount pipeline as the
in-app Promote feature. So an agent can "write a promo post for xxx.com and post
it on my socials" in one call. Cookie-auth platforms surface as 'queued'.

- app/api/mcp/route.ts: createMcpHandler + withMcpAuth(crp_ token verifier)
- lib/mcp/promote.ts: registerPromoteTools(server) — the promote module
- lib/sp/apiAuth.ts: extract authenticateToken(token) for the MCP verifier
- deps: mcp-handler, @modelcontextprotocol/sdk
- docs/mcp.md: connect-your-agent guide
- test: promote tools register + are discoverable over the MCP protocol (SDK
  in-memory transport)

Structured so more capabilities (audits, stats, …) drop in as additional
registerXxxTools modules.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedmcp-handler@​1.1.0991009990100
Added@​modelcontextprotocol/​sdk@​1.26.09910010092100

View full report

@ralyodio
ralyodio merged commit 38d7b08 into master Jul 17, 2026
8 checks passed
@ralyodio
ralyodio deleted the mcp/promote-server branch July 17, 2026 11:59
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