DEV Community

unbowedgod
unbowedgod

Posted on Originally published at spicapost.com

Why Dumping 200+ MCP Tools Into Claude Code Breaks Your Agent (And How Progressive Discovery + OAuth Role Caps Fix It)

When developers wire an AI coding agent (Claude Code, Cursor, Codex CLI, VS Code, or Antigravity) to a broad SaaS API over Model Context Protocol (MCP), two production failure modes show up immediately:

  1. Context-window bloat: Exposing 200+ JSON tool schemas upfront eats 50,000 to 80,000 input tokens on every turn before the user even writes a prompt, degrading tool selection accuracy and inflating cost.
  2. Over-privileged static secrets: Pasting an organization-wide API key into ~/.claude.json or .cursor/mcp.json turns a single hallucinated parameter into an unapproved live post on the wrong brand.

Here is the three-part architecture we built for Spica Post's hosted OAuth 2.1 MCP server (plus the open-source GitHub Action starter we just shipped on top of @spicapost/sdk) that solves both problems.

1. Progressive tool discovery: 39 default tools instead of 250+ upfront

Instead of forcing every MCP client to swallow all 250+ tools at handshake time, bare https://app.spicapost.com/mcp mounts a lean 39-tool default surface (~12K tokens total): 36 daily publishing and inspection tools plus 3 progressive-discovery meta-tools:

  • tools_search: keyword or domain lookup across the full catalog (returning exact names, safety hints, and whether to call directly or via tools_read / tools_run).
  • tools_read: invoke any read-only catalog tool outside the default 36 without bloating the schema list.
  • tools_run: invoke any write catalog tool outside the default 36 through the exact same server-side brand wall, validator, and audit log.

You can still pin explicit profiles in the URL when a workflow is narrow:

URL Tools loaded Best for
https://app.spicapost.com/mcp 39 default + progressive discovery Claude Code, Codex, Cursor, ChatGPT daily workflows
https://app.spicapost.com/mcp?profile=core 28 minimal tools Tight CI or release-note drafting agents
https://app.spicapost.com/mcp?profile=publishing,links Domain toolsets Composable single-domain agents
https://app.spicapost.com/mcp?profile=full All 250+ flat tools Clients that prefer every schema preloaded

2. Remote OAuth 2.1 with per-assistant role caps

Zero static keys in chat configs. Any MCP client that supports Streamable HTTP with OAuth metadata discovery and dynamic client registration connects in one command:

# Claude Code
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 mcp add spica-post https://app.spicapost.com/mcp
Enter fullscreen mode Exit fullscreen mode

On the browser approval screen, you pick the exact role cap for that assistant grant:

  • Full access (within your workspace role)
  • Write drafts only (the server refuses publish and schedule calls with structured assistantAccess errors)
  • Read only (analytics, inbox inspection, calendar reads only)

For multi-brand workspaces, every tool call must include an explicit brandId parameter; omitting it fails closed on the server so an agent cannot accidentally cross-post Client A's launch to Client B.

3. Deterministic CI pipelines: @spicapost/sdk, spica-cli and GitHub Actions

Conversational drafting belongs on OAuth MCP; deterministic CI belongs on a single-brand Bearer key (sp_live_...) with idempotency keys. Both packages are live on npm with zero runtime dependencies:

# Machine-readable CLI for terminal and agent shell workflows
npx spica-cli help --json

# Zero-dependency TypeScript/JavaScript SDK
npm install @spicapost/sdk
Enter fullscreen mode Exit fullscreen mode
import { SpicaClient } from '@spicapost/sdk';

const spica = new SpicaClient({ apiKey: process.env.SPICA_API_KEY! });

// Save a validated draft (human approves before publishing)
const draft = await spica.drafts.create({
  title: 'v1.4.0 Release',
  variants: [{ accountId: 'acc_123', text: 'v1.4.0 is live with OAuth 2.1 discovery.' }],
});
await spica.drafts.validate(draft.draft.id, { version: draft.draft.version });
Enter fullscreen mode Exit fullscreen mode

We packaged a ready-to-use GitHub Action starter at github.com/unbowedgod/spica-release-poster that turns GitHub Releases into per-network validated drafts (respecting X 280 weighted chars, Bluesky 300 graphemes via Intl.Segmenter, Mastodon 500 chars, and LinkedIn) and drops the review link right into your GitHub Actions Step Summary.

Honest status of supported networks

Transparency matters for dev tools: X, LinkedIn (personal profiles + PDF carousels), Bluesky (including video and chained threads), Mastodon (any public server), and WordPress (REST API v2) are live today. Instagram, Facebook Pages, Threads, Google Business Profile, YouTube, TikTok, Pinterest, and LinkedIn Company Pages are built in the codebase and unlock as each platform clears official app review.

Read the full architecture breakdown, security checklist, and client configs in the original guide: Remote OAuth MCP Server for Coding Agents. Machine-readable agent docs live at spicapost.com/agents.txt and spicapost.com/.well-known/mcp/server-card.json.

Top comments (1)

Collapse
 
sandscale profile image
Sandscale •

The failure mode of loading 200+ tool schemas on every turn is real, even before the product around it. Starting from a small default set and discovering the rest with a search tool is the part I'd steal for any wide MCP server. The other half is not putting an org-wide API key in ~/.claude.json: a hallucinated argument then has the full permission of that key. A per-assistant role that cannot publish, plus a required brand or account id that fails closed when omitted, is the right shape for write tools.