add-api

add-api is a command for Claude Code from alifanov/scopegate. It costs 15 tokens per session (985 once invoked), scanned A, original, MIT.

A command for adding a complete connection between ScopeGate and a third-party service. ScopeGate is a gateway that lets AI agents use external APIs through OAuth, a standard login and permission process.

In plain words
What is it for?
Use it after naming the service to add. It researches the service’s authentication details, follows an existing integration pattern, and adds the required server, agent-tool, permission, and user-interface pieces.
Why use it?
It organizes the many parts of an integration—login, token handling, API calls, permissions, and interface changes—so none are easily overlooked.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/alifanov/scopegate/add-api
Clone the repo
git clone --depth 1 https://github.com/alifanov/scopegate

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for add-api

README.md
[![agentmods](https://agentmods.dev/badge/commands/alifanov/scopegate/add-api.svg)](https://agentmods.dev/commands/alifanov/scopegate/add-api)
Your own site
<a href="https://agentmods.dev/commands/alifanov/scopegate/add-api"><img src="https://agentmods.dev/badge/commands/alifanov/scopegate/add-api.svg" alt="Measured on agentmods" height="20"></a>
Per session 15 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 985 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00015 $0.00985
Opus 5 $0.00008 $0.00492
Sonnet 5 $0.00003 $0.00197
Haiku 4.5 $0.00002 $0.00098

Measured 6d ago against content hash fd026f8b23c5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

add-api scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/add-api.md · 80 lines

How it starts

The opening of the file, as written. The whole thing — 80 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Context

ScopeGate is an MCP gateway that connects AI agents to third-party APIs via OAuth. Each integration requires:

  1. An OAuth module (src/lib/{provider}-oauth.ts)
  2. OAuth route handlers (src/app/api/oauth/{provider}/route.ts + callback/route.ts)
  3. An MCP API wrapper (src/lib/mcp/{provider}.ts)
  4. MCP tool definitions (src/lib/mcp/tools.ts)
  5. Permission groups (src/lib/mcp/permissions.ts)
  6. UI updates for service connection (src/components/)

The user will specify which API/service to add. Use $ARGUMENTS for the service name.

Your Task

Add a complete API integration for the specified service.

Steps

  1. Research the API auth flow

    • Search the web for the service's OAuth documentation
    • Identify: auth URL, token URL, required scopes, token refresh mechanism
    • Check if it uses OAuth 2.0, OAuth 1.0a, or API key auth
    • Determine token expiration and refresh strategy
  2. Study existing patterns

    • Read a similar existing OAuth module (e.g., src/lib/threads-oauth.ts for simple OAuth 2.0, src/lib/google-oauth.ts for refresh token flows)
    • Read the corresponding callback route in src/app/api/oauth/
    • Read the MCP wrapper in src/lib/mcp/
    • Note the structure and follow it exactly
  3. Implement OAuth module (src/lib/{provider}-oauth.ts)

    • buildAuthUrl() — construct OAuth authorization URL with correct scopes
    • exchangeCodeForTokens() — exchange auth code for access (and refresh) tokens
    • getUserInfo() — fetch authenticated user info for the account label
    • getValidAccessToken() — retrieve + auto-refresh token from DB
    • Add env vars: {PROVIDER}_CLIENT_ID, {PROVIDER}_CLIENT_SECRET
  4. Implement OAuth routes

    • src/app/api/oauth/{provider}/route.ts — initiate OAuth flow (redirect to auth URL)
    • src/app/api/oauth/{provider}/callback/route.ts — handle callback, store tokens in DB
  5. Implement MCP wrapper (src/lib/mcp/{provider}.ts)

    • Create {provider}Fetch() function that handles auth and API calls
    • Follow the pattern from existing wrappers (e.g., src/lib/mcp/twitter.ts)

Read the full file on GitHub · 80 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 80 lines · 15 tokens per session scan A fd026f8b23c5

Subscribe to this mod's changes

add-api is a command published in the GitHub repository alifanov/scopegate (15 stars, last pushed yesterday), licensed MIT. It adds 15 tokens to every session and 985 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.