MCP & AI
Remote OAuth MCP Servers for Coding Agents: Context Budgets and Safe Publishing
Connect Claude Code, Cursor, Codex and Antigravity to a remote OAuth MCP server with progressive tool discovery, role caps and zero API keys.
A remote OAuth 2.1 Model Context Protocol (MCP) server lets coding agents such as Claude Code, Cursor, Codex CLI, VS Code and Antigravity (agy) draft release notes, validate platform limits and queue social posts directly from a terminal without storing static API keys in dotfiles or flooding the context window with hundreds of unused tool schemas. The difference between a fragile prototype and a production-safe setup comes down to four engineering choices: Streamable HTTP with OAuth discovery, progressive tool discovery that holds schema overhead near 12,000 tokens, server-enforced role caps and brand isolation, and a headless CLI twin for CI pipelines where no browser exists.
Developers ship features all week and still forget to announce them. By the time a release tag lands on GitHub, opening three social dashboards, resizing screenshots, rewriting one changelog into four character-limited formats and checking alt text feels like a separate job. Coding agents already sit inside the repository where the diff, release notes and screenshots live. Connecting that agent cleanly to your publishing stack turns release distribution into a repeatable engineering step rather than a forgotten marketing chore.
Most early MCP integrations fail in practice for predictable reasons. Teams wrap a REST API into 150 raw endpoints, paste a super-admin bearer token into ~/.cursor/mcp.json, hit editor tool limits on turn one, and watch the model burn tens of thousands of tokens just reading tool definitions before a single prompt runs. Worse, a misread workspace ID can publish a changelog to a client account instead of your own product handle.
Snapshot verified December 2026. Protocol details below match the Model Context Protocol specification, OAuth metadata standards (RFC 9728, RFC 8414, RFC 7591), and Spica Post’s live production configuration documented at spicapost.com/agents.txt and spicapost.com/brand-facts/. Check Spica Post pricing for current plans and limits.
Why static API keys and local stdio wrappers break for coding agents
The earliest wave of MCP servers ran locally over stdio via npx or Docker containers, taking a static API key from an environment variable. That pattern works for reading a local SQLite file, but it creates four operational headaches the moment you connect external SaaS accounts across a team.
1. Secret sprawl across local IDE configs
Every coding client keeps its own MCP file: ~/.claude.json, ~/.cursor/mcp.json, .vscode/mcp.json, or Codex config files. Pasting a static Bearer token into project-level configs risks committing live publishing credentials into version control or leaking them into bug reports. When a contractor leaves or a laptop is replaced, somebody has to remember which key lived in which editor.
2. Local runtime drift and install failures
Local stdio servers rely on whatever Node, Python or Docker version sits on the developer’s machine. An outdated global package caches old API parameters, breaks silently after a server schema change, or stalls an agent mid-task on an npm registry error. A hosted remote MCP endpoint updates once on the server so every connected coding agent immediately reads current schemas and network limits.
3. Missing human consent at connection time
A raw API key gives every prompt the exact same blast radius unless someone manually creates a separate restricted key for each assistant. OAuth 2.1 authorization puts a human approval screen in the middle of the handshake, showing the exact client name, which account is signing in, and how much authority the assistant receives before a single tool call runs.
4. Unexplained 401 loops
Autonomous coding agents often react to a bare 401 Unauthorized response by probing undocumented paths, retrying registration in a tight loop, or inventing fake header formats. A well-behaved remote MCP server pairs standard WWW-Authenticate metadata (RFC 9728) with a plain-English JSON response pointing straight to /agents.txt, telling the agent that only browser approval lets it in, that there is no static key for MCP, and that headless runs should stop and ask the human instead of looping.
How OAuth 2.1 Streamable HTTP authentication actually works
Modern MCP clients (Claude Code, Cursor, Codex CLI and Antigravity agy) support remote Streamable HTTP servers with zero manual client IDs. Understanding the five-step handshake helps you debug auth in seconds instead of guessing.
- Initial probe and Protected Resource Metadata: The client sends a request to
https://app.spicapost.com/mcp. Because no token is attached, the server returns401 Unauthorizedwith aWWW-Authenticateheader pointing to/.well-known/oauth-protected-resource(RFC 9728). - Authorization Server Discovery: The client fetches the protected resource document, finds the authorization server metadata URL (
/.well-known/oauth-authorization-serverper RFC 8414), and reads the token, authorization and registration endpoints. - Client identification or Dynamic Client Registration (DCR): Clients that host a verified client metadata document identify themselves directly; terminal clients without one register dynamically under RFC 7591 with PKCE (
S256) enabled. - Browser sign-in and permission cap: The client opens your default browser on the same machine (for localhost callbacks) or displays a redirect code (for remote callbacks such as Antigravity’s Google callback page). You sign in once, review the assistant’s name, choose its permission ceiling (full access, Write drafts only, or Read only), and press Allow.
- Scoped token exchange and Origin validation: The client exchanges the short-lived authorization code plus PKCE verifier for an access token. On every subsequent Streamable HTTP request, the server validates the
Originheader against an allowlist to block cross-site DNS-rebinding attacks from untrusted browser tabs while allowing local CLI and native clients cleanly.
Exact one-line setup commands across major coding agents
Because discovery and registration happen automatically, connecting a coding agent takes one command or one JSON block:
- Claude Code (plugin with connector and 15 workflow skills):
/plugin install spica-post --marketplace unbowedgod/spica-post-mcp - Claude Code (MCP connector only):
claude mcp add --transport http spica-post https://app.spicapost.com/mcp - Codex CLI:
codex mcp add spica-post --url https://app.spicapost.com/mcp - Antigravity (
agy):agy mcp add spica-post https://app.spicapost.com/mcp, then run/mcpinsideagy, select Authenticate, press Allow in the browser, and paste the returned verification code back intoagy. - Cursor and VS Code: Add a
streamable-httpentry pointing tohttps://app.spicapost.com/mcpinside~/.cursor/mcp.jsonor.vscode/mcp.json.
A frequent failure mode with terminal agents is opening the emailed magic sign-in link on a phone while the CLI waits on a localhost callback on a laptop. Good approval pages detect mobile browsers when the callback targets loopback and tell the user outright to open the sign-in link on the computer running the assistant so Allow does not end on a dead loopback error.
Context budgets and progressive tool discovery
Context efficiency is the single most overlooked bottleneck in production MCP design. Every tool returned by tools/list injects its name, prose description, JSON input schema and optional output schema into the model’s system context on every single turn of the conversation.
The real math of a flat tool catalog
When a full publishing, CRM, analytics, client-portal and inbox platform exposes its entire API surface flat (over 200 tools), the raw tools/list payload easily crosses 61,000 input tokens before the developer writes a single sentence. Two things break immediately:
- Hard IDE caps: Several editors and agent harnesses warn or truncate tool lists past 40 active tools across all connected MCP servers. If one social server consumes 200 slots, your database, GitHub and browser MCP servers get squeezed out.
- Tool-selection accuracy drops: Asking a model to choose among 200 similarly named tools causes parameter hallucinations, wrong defaults and unnecessary round-trips.
How safety-split progressive discovery solves it
Spica Post solves context bloat without stripping capabilities by separating the default menu from the full catalog:
- Lean default endpoint (
/mcp): Returns 39 tools (~12,000 tokens total, every individual tool schema trimmed under 1,200 tokens with zero$refindirection and typedoutputSchemaplusstructuredContent). That default covers daily drafting, validation, scheduling, media upload, brand kit inspection, account connect links, results and setup. - Three safety-split discovery tools: Instead of one opaque catch-all runner, progressive discovery splits read and write risk cleanly.
tools_search(read-only) searches the full 250-tool catalog by keyword or domain;tools_read(read-only) inspects exact schemas and runs read-only catalog tools;tools_run(write / open-world) executes write tools with full Zod validation, role enforcement, brand routing and audit logging. - Composable URL profiles: Developers who want an even smaller footprint can connect
/mcp?profile=core(28 tools), narrow domain bundles such as/mcp?profile=publishing,links,growth, or/mcp?profile=fullfor clients that want every tool flat.
This design keeps ~80% of the context window free for your actual codebase diff while preserving 100% reach across publishing, auto-crosspost, RSS feeds, WordPress, Marketing CRM, audience campaign pages and client portals.
Comparing integration paths for developer and agent workflows
Not every automation belongs on MCP. Choosing the right interface depends on whether a human is in the loop and whether a browser is available for OAuth.
| Integration path | Auth mechanism | Context overhead | Best workflow fit | Human approval model |
|---|---|---|---|---|
| Remote OAuth MCP | OAuth 2.1 + PKCE + DCR | Low (~12K tokens lean) | Interactive coding agents (Claude Code, Cursor, Codex, agy) | Browser Allow + optional Drafts-only or Read-only role cap |
| Local stdio MCP | Local env var / static key | Medium to High | Local-only filesystem or private LAN tools | Depends on local key scope |
Zero-dep CLI (spica-cli) |
Brand-scoped SPICA_API_KEY |
Zero MCP overhead | GitHub Actions, release scripts, cron jobs, headless agents | Draft or queue by default (--draft, --queue), JSON help |
Direct REST API (/v1) |
Brand-scoped Bearer key | Zero MCP overhead | Custom apps, internal dashboards, signed webhook receivers | Explicit idempotency keys and approval queue routes |
Notice how agents.txt bridges all four paths cleanly. Before writing code or installing tools, a coding agent can fetch https://spicapost.com/agents.txt to read the exact MCP endpoint, profile query strings, live npm CLI commands (npx spica-cli help --json), OpenAPI 3.0.3 location (https://app.spicapost.com/v1/openapi.json), live vs pending networks, and every non-negotiable publishing guardrail in one plain-text file.
Multi-brand isolation, role caps and approval guardrails
Giving an autonomous coding agent access to social accounts requires defense in depth. Prompt instructions (“please ask before posting”) are helpful, but server-side enforcement is what prevents costly mistakes.
1. Explicit brandId on every multi-brand call
When one login manages multiple brands (for example, your main SaaS product, a side project and two client workspaces), silently defaulting to “whichever brand was opened last in the web UI” is a recipe for cross-posting the wrong changelog to the wrong audience. On Spica Post, any login with more than one brand must pass an explicit brandId on every MCP tool call after reading brands_list; calls that omit brandId are refused by the server before touching data. On the REST API and CLI, every sp_live_... API key is permanently locked to a single brand at creation time.
2. Server-enforced assistant role caps
On the OAuth approval page, you can cap what an assistant is allowed to do regardless of your own workspace role:
- Everything you can do: Full drafting, scheduling, queue management and workspace administration within your role.
- Write drafts only: The assistant can read your brand kit, upload release screenshots, create and validate multi-network drafts, and submit drafts for review, but every publish or schedule call is refused by the server with
code: "approval_required"andassistantAccess: "editor". - Read only: Ideal for analytics briefings, growth audits (
growth_get), inbox triage previews and audit-log inspection with zero mutation risk.
3. Idempotency keys and canonical failure recovery
Network hiccups happen inside long agent turns. Every publish and schedule call requires the draft ID, its version number and a caller-supplied idempotencyKey. If a coding agent times out and retries the exact same call, the server returns the original delivery job instead of double-posting to X or LinkedIn. When a downstream network rejects a post, Spica Post classifies the error into nine canonical failure kinds (paused_by_network, daily_limit, login_ended, media_rejected, identity_check, email_unconfirmed, link_blocked, maybe_published, other) with a concrete next action and optional account queue holds (accounts_hold / accounts_resume) so queued posts do not keep slamming into a rate limit.
Headless CI and release pipelines with spica-cli and OpenAPI 3.0.3
Interactive MCP shines when you are pairing with Claude Code or Cursor on a launch announcement. When you want a GitHub Action to turn a tagged release into a ready-to-review draft automatically at 2 AM, there is no browser to click OAuth Allow. That is where a zero-dependency CLI and OpenAPI contract take over.
spica-cli (live on npm as spica-cli, requiring Node 18+ with zero third-party runtime dependencies) ships with machine-readable introspection (npx spica-cli help --json) so both shell scripts and autonomous agents can discover commands and flags without scraping HTML docs:
export SPICA_API_KEY="sp_live_xxxxx"
npx spica-cli accounts
npx spica-cli upload --file ./release-card.png --alt "Release v2.4 dashboard screenshot"
npx spica-cli post \
--text "v2.4 is live: faster exports, cleaner webhook retries, zero extra config." \
--accounts acc_linkedin,acc_bluesky \
--draft
Because the --draft flag creates a validated draft without publishing, your CI pipeline can run on every release tag and drop a review link into Slack via HMAC-SHA256 signed webhooks (draft.created, approval.requested, post.published, post.failed), letting a human press approve in ten seconds the next morning.
Real trade-offs on Spica Post for coding-agent setups
Being explicit about what is live today and what is still waiting prevents wasted integration time:
- Live publishing networks today: X, LinkedIn personal profiles (including single-page and multi-page PDF document carousels), Bluesky (including MP4 video and chained native threads), Mastodon (any public HTTPS server via dynamic OAuth 2.0 + PKCE) and WordPress (REST API v2 via Application Password) are live and connectable today.
- Networks built and awaiting platform approval: Instagram (feed, carousels, reels, stories, comment-to-DM), Facebook Pages, Threads, Google Business Profile (API approved; awaiting verification on first live profile), YouTube (OAuth verified; awaiting compliance audit), TikTok (submitted), Pinterest (Sandbox/Trial) and LinkedIn Company Pages are built in the codebase and activate as each vendor completes its review. If your CI pipeline must publish Instagram Reels or TikTok videos this week, wait for those approvals or pair with an already-approved publisher until they flip live.
- SDK registry status: The zero-dependency TypeScript/JavaScript SDK (
@spicapost/sdk) is packaged in the repository (packages/sdk), whilespica-cliis already live on npm today and the full/v1OpenAPI 3.0.3 REST API is live for any HTTP client. Check/developers/for current package status before wiring a build script. - No bundled AI model credits: Spica Post intentionally runs zero AI models of its own and charges zero token markups. You bring Claude, ChatGPT, Gemini, Codex, Cursor or any MCP client you already use, and check Spica Post pricing for flat account, brand and seat allocations.
Pre-production verification checklist for coding-agent publishing
Before wiring any coding agent or CI runner to a live brand workspace, walk through these seven concrete checks:
- Fetch
agents.txtfirst: Confirm your agent can readhttps://spicapost.com/agents.txtcleanly without JavaScript and recognizes the lean 39-tool default plus progressive discovery tools. - Test OAuth consent with a restricted role: Connect Claude Code, Cursor, Codex or
agyviahttps://app.spicapost.com/mcpand pick Write drafts only on the approval screen. Verify thatdrafts_createsucceeds andpublishis refused by the server. - Verify multi-brand safety: If your login holds two or more brands, call a write tool without
brandIdand confirm the server refuses it until you specify the exact brand frombrands_list. - Exercise progressive discovery: Ask the agent to find a non-default tool (such as RSS feeds or client portals) via
tools_search->tools_read->tools_runand confirm total context overhead stays lean. - Run a real validation pass: Have the agent call
drafts_validateon a post containing a link, a Bluesky 300-grapheme check and a LinkedIn PDF attachment so limits are caught before scheduling. - Verify CLI JSON help in a clean directory: Run
npx spica-cli help --jsonin an empty temp folder with zero repo context to confirm headless CI scripts work without local dependencies. - Test webhook signature verification: Trigger a webhook test event and validate the
Spica-SignatureHMAC-SHA256 header (t + "." + rawBody) before trusting downstream Slack or deployment notifications.
Questions people ask
- Why should a coding agent connect to a remote Streamable HTTP MCP server with OAuth instead of pasting an API key?
- OAuth 2.1 with PKCE and Dynamic Client Registration keeps long-lived secrets out of local config files, chat logs and git commits. You approve access once in your browser, choose a role cap such as drafts only or read only, and revoke any assistant from your account page without rotating production keys.
- How does progressive tool discovery prevent a 200-tool MCP server from filling the context window?
- Instead of sending every tool schema at connection time, the server exposes a compact daily set of roughly 39 tools plus three discovery helpers (tools_search, tools_read and tools_run). The agent stays around 12,000 schema tokens instead of 60,000 or more, stays under IDE tool caps, and loads rare tools only when a task asks for them.
- Can I let Claude Code or Cursor draft release posts while blocking it from publishing?
- Yes. On an OAuth approval screen with permission scoping, you can grant the assistant Write drafts only or Read only access. The server enforces that ceiling on every call, so even if a prompt asks the agent to publish immediately, the publish tool returns an approval refusal.
- When should a developer use a CLI with JSON output instead of MCP?
- Use OAuth MCP for interactive sessions inside Claude Code, Cursor, Codex, Antigravity or ChatGPT where a human can press Allow in a browser and review drafts. Use a zero-dependency CLI such as spica-cli with machine-readable JSON help and a brand-scoped API key inside headless CI pipelines, cron jobs and GitHub Actions.
- Which social networks are live today on Spica Post for coding-agent publishing?
- X, LinkedIn personal profiles (including PDF document carousels), Bluesky (including video and chained threads), Mastodon on any public server and WordPress via REST API v2 are live today. Instagram, Facebook Pages, Threads, Google Business Profile, YouTube, TikTok, Pinterest and LinkedIn Company Pages are built and open as each platform review approves.
Sources
- Model Context Protocol specification (Transports and Authorization)
- RFC 9728: OAuth 2.0 Protected Resource Metadata
- RFC 8414: OAuth 2.0 Authorization Server Metadata
- RFC 7591: OAuth 2.0 Dynamic Client Registration Protocol
- Anthropic Claude Code MCP documentation
- OpenAI Codex CLI documentation
- Cursor Model Context Protocol guide
- Spica Post agents.txt and live MCP reference


