mech.app

The mech.app newsletter

Agentic AI, minus the noise.

Get practical field notes on AI agents, automation, developer tools and security delivered to your inbox.

No spam. Unsubscribe anytime.

Dev Tools

Spotify Portal AI Plugins: How Production Service Catalogs Become Agent Tool Registries

Spotify exposes Portal CLI workflows as MCP plugins, turning service catalogs into agent tool surfaces with auth, diagnostics, and safe mutation gates.

Source: github.com
Spotify Portal AI Plugins: How Production Service Catalogs Become Agent Tool Registries

Spotify just published a pattern that turns internal developer platforms into agent tool surfaces. The Portal AI Plugins repository (3,116 stars, trending #2 for TypeScript) exposes Spotify’s Portal CLI as MCP-compatible plugins for Claude Code, Codex, Cursor, and pi. Instead of treating service catalogs as read-only dashboards for humans, this approach makes catalog search, diagnostics, service briefings, and even mutating operations like Fleetshift runs available to coding agents with built-in approval gates.

The plumbing matters because it shows how to bridge enterprise platform tooling and agentic workflows without rebuilding everything from scratch. You get authentication setup, dry-run previews, confirmation prompts, and a clear boundary between safe discovery and dangerous mutations.

What Portal Plugins Actually Do

Portal is Spotify’s internal developer platform (think Backstage-style service catalog plus operational tooling). The CLI already wraps authentication, catalog queries, health checks, and deployment workflows. The plugins translate those CLI commands into agent-callable tools.

Core workflows:

  • setup: Configure Portal CLI authentication for the current coding environment.
  • doctor: Run read-only diagnostics to verify plugin, CLI, auth, and action readiness.
  • search: Query the software catalog and technical docs using natural language.
  • service: Generate a concise briefing with ownership, health, incidents, and documentation.
  • actions: Discover, inspect, preview, and invoke Portal actions with help, dry-run, and confirmation safeguards.
  • fleetshift-create-shift: Draft and execute Fleetshift shifts, open PRs from completed runs, stop runs on request.

The shunt plugin (Claude Code only for now) routes I/O-heavy tasks like bulk file reads and boilerplate generation to cheaper worker models via the Portal CLI actions registry. This is token-saving delegation, not just parallelism.

Architecture: CLI as Agent Tool Surface

The plugin layer sits between the coding agent and the Portal CLI. The agent calls plugin methods, the plugin invokes CLI commands, the CLI hits Portal APIs, and results flow back to the agent.

┌─────────────────┐
│ Coding Agent    │
│ (Claude, Cursor)│
└────────┬────────┘
         │ MCP protocol
         ▼
┌─────────────────┐
│ Portal Plugin   │
│ (TypeScript)    │
└────────┬────────┘
         │ shell exec
         ▼
┌─────────────────┐
│ Portal CLI      │
│ (Node.js)       │
└────────┬────────┘
         │ HTTPS + auth
         ▼
┌─────────────────┐
│ Portal APIs     │
│ (Spotify infra) │
└─────────────────┘

Authentication flow:

  1. Agent calls /portal:setup.
  2. Plugin runs portal auth login.
  3. CLI opens browser for OAuth or device code flow.
  4. Token stored in local config.
  5. Subsequent plugin calls reuse token.

Diagnostic flow:

  1. Agent calls /portal:doctor.
  2. Plugin runs portal doctor.
  3. CLI checks plugin version, auth status, action registry connectivity.
  4. Results returned as structured JSON.

Action invocation flow:

  1. Agent calls /portal:actions with action name.
  2. Plugin runs portal actions help <action> to show parameters.
  3. Agent confirms or requests dry-run via portal actions run <action> --dry-run.
  4. Plugin prompts for confirmation.
  5. Agent approves, plugin runs portal actions run <action>.
  6. CLI executes, returns output.

Safe Mutation Boundaries

The plugin design enforces a clear split between read-only discovery and mutating operations.

Operation TypeExamplesSafeguards
Read-onlysearch, service, doctorNone needed, always safe
Discoverableactions (list/help)No execution, just metadata
Dry-runactions run --dry-runPreview changes, no side effects
Mutatingactions run, fleetshift-create-shiftRequires confirmation prompt

Confirmation prompt pattern:

// Simplified from plugin code
async function invokeAction(actionName: string, params: object) {
  const dryRunResult = await exec(`portal actions run ${actionName} --dry-run`, params);
  
  const confirmed = await agent.confirm({
    message: `About to run ${actionName}`,
    preview: dryRunResult.stdout
  });
  
  if (!confirmed) {
    return { status: 'cancelled' };
  }
  
  return await exec(`portal actions run ${actionName}`, params);
}

This pattern prevents accidental mutations. The agent must explicitly request a dry-run, show the preview to the user, and wait for approval before executing.

Shunt Plugin: Delegating Expensive Work

The shunt plugin routes I/O-heavy tasks to cheaper worker models. It uses the Portal CLI actions registry as a dispatch mechanism.

Use cases:

  • Bulk file reads across a monorepo.
  • Boilerplate generation for new services.
  • Large-scale search-and-replace operations.

Flow:

  1. Agent detects high-token operation (e.g., “read all TypeScript files in /src”).
  2. Shunt plugin registers a temporary action in Portal CLI registry.
  3. Action definition includes file patterns, transformation logic.
  4. Portal CLI spawns worker process with cheaper model (e.g., GPT-3.5 instead of GPT-4).
  5. Worker executes, returns results.
  6. Shunt plugin streams results back to agent.

This is cost optimization, not just parallelism. The main agent stays in context, the worker handles grunt work.

Fleetshift Integration

Fleetshift is Spotify’s deployment orchestration tool. The plugin exposes shift creation, execution, PR opening, and run management.

Workflow:

  1. Agent calls /portal:fleetshift-create-shift with shift definition.
  2. Plugin runs portal fleetshift create with YAML config.
  3. CLI validates shift, returns shift ID.
  4. Agent calls /portal:fleetshift-run-shift with shift ID.
  5. Plugin runs portal fleetshift run, streams logs.
  6. On completion, agent calls /portal:fleetshift-open-pr to create PR from shift output.

Safety:

  • Shift creation is dry-run by default.
  • Agent must confirm before running.
  • Stop command available via /portal:fleetshift-stop-run.

Observability and Failure Modes

Diagnostics:

The doctor workflow checks:

  • Plugin version vs. CLI version compatibility.
  • Authentication token validity.
  • Portal API reachability.
  • Actions registry connectivity.

Common failure modes:

FailureSymptomFix
Auth expired401 from Portal APIsRe-run /portal:setup
CLI version mismatchPlugin calls unsupported CLI flagsUpdate CLI via npm install -g @spotify/portal-cli
Network partitionTimeout on catalog searchCheck VPN, retry
Action not foundportal actions run failsRun /portal:actions to list available actions

Logging:

Plugin logs to agent’s debug stream. CLI logs to ~/.portal/logs. Portal APIs log to Spotify’s internal observability stack (not exposed to plugin).

Deployment Shape

For end users:

  1. Install plugin via agent marketplace.
  2. Run setup workflow to authenticate.
  3. Use plugin commands in agent sessions.

For platform teams:

  1. Publish Portal CLI to npm.
  2. Publish plugin to GitHub.
  3. Register plugin in agent marketplaces (Claude Code, Codex, Cursor, pi).
  4. Update plugin when CLI adds new actions.

Version compatibility:

Plugin checks CLI version on startup. If mismatch, warns user and suggests upgrade path.

Security Boundaries

Authentication:

  • OAuth tokens stored in ~/.portal/config.
  • Tokens scoped to user’s Spotify identity.
  • No shared credentials between users.

Action execution:

  • All actions run with user’s permissions.
  • No privilege escalation.
  • Audit logs in Portal backend.

Plugin isolation:

  • Plugin runs in agent’s sandbox.
  • No direct network access (all I/O via CLI).
  • No filesystem access outside agent’s workspace.

Risk:

If an agent is compromised, it can invoke any Portal action the user has permissions for. This is the same risk as giving a human the CLI. The confirmation prompts mitigate accidental execution but do not prevent intentional misuse.

Technical Verdict

Use this pattern when:

  • You have an existing CLI tool that wraps platform APIs.
  • You want to expose platform workflows to coding agents without rebuilding everything.
  • You need clear boundaries between read-only discovery and mutating operations.
  • You want to reuse existing authentication, authorization, and audit infrastructure.

Avoid this pattern when:

  • Your platform APIs are not stable enough for agent consumption.
  • You cannot enforce confirmation prompts for dangerous operations.
  • Your CLI tool does not support dry-run or preview modes.
  • You need sub-second latency (shell exec overhead adds 100-500ms per call).

Key insight:

Service catalogs are not just human dashboards. By exposing catalog search, diagnostics, and operational workflows as agent tools, you turn your internal platform into an agent-native surface. The Portal plugins show how to do this safely with authentication, dry-run previews, and confirmation gates. The shunt plugin shows how to optimize token costs by delegating expensive I/O to cheaper worker models.

This is production-grade plumbing for agentic infrastructure, not a prototype.