Agent Integration

Connecting AI Agents

Roll out governed LLM access and remote MCP tools across developer IDEs, CLI coding agents, native desktop apps, and M365 Copilot Studio—starting in 30 minutes with zero MDM.

30-Minute Rollout Overview

You do not need MDM, enterprise vendor contracts, or a full directory sync to validate Control Proxy. Teams typically roll out in four lightweight phases:

  1. Phase 1 — First LLM traffic (10 minutes): Seal one pay-as-you-go API key per vendor under Catalog & Models → Model providers, add a per-user daily/monthly cap under Activity → Usage limits, create a personal gateway key (mcpr_...) on Your profile, and confirm your first test prompt appears in Activity → Model log.
  2. Phase 2 — Pilot 2–5 users (10 minutes): Invite pilot users (local accounts or corporate SSO) to generate their own revocable mcpr_... key and copy the 2-line setup snippet from AI models.
  3. Phase 3 — Approved MCP tools (10 minutes): Enable AI tools sign in through your sign-in system under Setup → Sign-in system, set your gateway name under Setup → Settings, publish 1–2 remote Streamable HTTP MCP servers, and commit secret-free .vscode/mcp.json or .cursor/mcp.json files to Git.
  4. Phase 4 — Scale with MDM, cost routing & SIEM: Turn on Shadow Mode routing to measure savings, enforce DLP and Threat Protection rules, push /usr/local/bin/cp-auth-token via Jamf/Kandji/Intune, and enable Splunk HEC or JSON Lines export.

Seat Subscriptions vs. API Billing

Important routing boundary: Flat-rate consumer or team seat logins (claude.ai, chatgpt.com, gemini.google.com) authenticate directly to the vendor and bypass any third-party LLM gateway. Furthermore, while Anthropic bundles monthly API credits with Claude Max, Ultra, and Team plans, Anthropic’s terms exclude interactive Claude Code from those bundled credits.

You do not have to cancel existing seats on Day 1. Organizations commonly adopt one of three patterns:

  • 2-week API pilot: Route 3–5 users through pay-as-you-go API billing with Shadow Mode routing enabled and compare real spend in Activity → Model log against flat monthly seats.
  • Hybrid deployment: Keep flat seats for a small number of extreme heavy users (while governing their tools via the MCP Gateway) and move remaining staff onto governed pay-as-you-go API pools.
  • MCP Gateway on Day 1: Connect every agent—including seat-based Claude, ChatGPT, and Microsoft 365 Copilot—to /mcp immediately for centralized approvals, DLP, argument guardrails, and audit logging.

MDM Zero-Key SSO with /usr/local/bin/cp-auth-token

For fleet-wide rollouts using Jamf, Kandji, or Microsoft Intune, deploy Control Proxy’s zero-dependency OAuth 2.0 + PKCE helper to /usr/local/bin/cp-auth-token (chmod +x, requires Node.js 20+).

  • Automatic discovery: Resolves RFC 9728 (/.well-known/oauth-protected-resource) and RFC 8414 / OIDC discovery metadata, using Dynamic Client Registration (DCR) or the Gateway Sign-in Relay when --client-id is omitted.
  • Secure token caching: Completes loopback PKCE (S256) browser login once, stores tokens in the macOS Keychain (service controlproxy-llm-auth) or ~/.config/controlproxy/tokens.json (mode 0600 with --no-keychain), silently refreshes access tokens, and prints only the raw access token to stdout.
Flag Environment Variable Purpose
--url <url> CONTROLPROXY_URL / ANTHROPIC_BASE_URL / OPENAI_BASE_URL Gateway base or provider URL (required via flag or env).
--client-id <id> CONTROLPROXY_CLIENT_ID Public OAuth client ID (omit when DCR or Sign-in Relay is active).
--scope <scopes> CONTROLPROXY_SCOPES Space-separated OAuth scopes.
--redirect-port <n> CONTROLPROXY_REDIRECT_PORT Fixed loopback callback port (default: ephemeral free port).
--login / --logout / --status — Force browser SSO login, clear cached tokens, or print token expiry to stderr.
--no-keychain CONTROLPROXY_NO_KEYCHAIN=1 Store tokens in ~/.config/controlproxy/tokens.json (0600) instead of macOS Keychain.
cp-auth-token --url https://yourcompany.controlproxy.com/llm/anthropic --status
cp-auth-token --url https://yourcompany.controlproxy.com/llm/anthropic --login

Claude Code (CLI & VS Code Extension)

Routes 100% of LLM traffic (via Anthropic or DeepSeek Anthropic-compatible API billing) and 100% of MCP tools. If a user previously signed into a personal claude.ai seat, run /logout inside Claude Code so it does not bypass the gateway.

LLM Gateway — Personal Gateway Key (~/.zshrc or ~/.bashrc)

Do not append /v1 to ANTHROPIC_BASE_URL; Claude Code appends /v1/messages automatically.

export ANTHROPIC_BASE_URL="https://yourcompany.controlproxy.com/llm/anthropic"
export ANTHROPIC_AUTH_TOKEN="<your-personal-gateway-key>"

For the Claude Code VS Code GUI extension, mirror the variables in VS Code User Settings (settings.json) and ~/.claude/settings.json:

{
  "claudeCode.environmentVariables": {
    "ANTHROPIC_BASE_URL": "https://yourcompany.controlproxy.com/llm/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "<your-personal-gateway-key>"
  }
}

LLM Gateway — MDM Zero-Key SSO (managed-settings.json)

Deploy to /Library/Application Support/ClaudeCode/managed-settings.json (macOS), C:\Program Files\ClaudeCode\managed-settings.json (Windows), or /etc/claude-code/managed-settings.json (Linux):

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://yourcompany.controlproxy.com/llm/anthropic"
  },
  "apiKeyHelper": "/usr/local/bin/cp-auth-token"
}

MCP Gateway Connection

claude mcp add --transport http <gateway-name> https://yourcompany.controlproxy.com/mcp
claude mcp login <gateway-name>

Note: If your deployment uses a fixed public OAuth client ID (such as a non-relay Entra ID registration), copy the command directly from My servers → How to connect so any --client-id and --callback-port flags are included.

Claude Desktop (3P — Cowork & Code)

Anthropic’s Third-Party Inference (3P) Gateway mode turns native macOS and Windows Claude Desktop (including Cowork and Code) into a fully governed app with zero claude.ai seat required.

Honest 3P trade-offs: In 3P mode, conversations stay local on the device; claude.ai web/mobile chat sync, Anthropic’s Skills Marketplace, cloud-scheduled tasks, and Anthropic cloud connectors are disabled. Control Proxy’s End-User Catalog and /mcp gateway provide your governed company tools instead.
  • Interactive setup: Open Help → Enable Developer Mode (or Settings → Developer) → Configure Third-Party Inference…
  • Provider: Gateway
  • Gateway base URL: https://yourcompany.controlproxy.com/llm/anthropic (or /llm/deepseek-claude for lower-cost DeepSeek / US-hosted DeepSeek; do not append /v1).
  • Authentication: Choose Static API key (Authorization: Bearer or x-api-key with a mcpr_... key) or Interactive sign-in (corporate OIDC).
  • MDM fleet rollout: Push com.anthropic.claudefordesktop managed preferences on macOS or HKLM\SOFTWARE\Policies\Claude on Windows.
  • MCP tools: Configure https://yourcompany.controlproxy.com/mcp in claude_desktop_config.json (or keep existing claude.ai seats in MCP-only mode under Settings → Connectors).

OpenAI Codex CLI & VS Code Extension

Both the Codex CLI and the Codex VS Code GUI extension read ~/.codex/config.toml (Windows: %USERPROFILE%\.codex\config.toml). Export your personal gateway key as CONTROLPROXY_API_KEY in your shell profile, then configure both gateways together:

# ~/.codex/config.toml
model_provider = "controlproxy_openai"

[model_providers.controlproxy_openai]
name = "OpenAI (Control Proxy)"
base_url = "https://yourcompany.controlproxy.com/llm/openai/v1"
wire_api = "responses"
env_key = "CONTROLPROXY_API_KEY"
requires_openai_auth = false

[mcp_servers.<gateway-name>]
url = "https://yourcompany.controlproxy.com/mcp"
enabled = true

Authenticate MCP access once in your browser:

codex mcp login <gateway-name>

Checklist: base_url must end with /v1; wire_api must be "responses"; env_key must be the variable name (never the secret literal); and requires_openai_auth = false disables the ChatGPT seat login prompt.

Cursor

Commit a secret-free .cursor/mcp.json at the repository root (or save globally in ~/.cursor/mcp.json / %USERPROFILE%\.cursor\mcp.json):

{
  "mcpServers": {
    "<gateway-name>": {
      "url": "https://yourcompany.controlproxy.com/mcp"
    }
  }
}

Click Connect / Sign in in Cursor Settings → Tools & Integrations (Cursor returns via cursor://anysphere.cursor-mcp/oauth/callback; CLI users can run agent mcp login <gateway-name>).

To route Cursor Chat & Agent models through Control Proxy: open Cursor Settings → Models → API Keys, paste your mcpr_... key into OpenAI API Key, toggle on Override OpenAI Base URL, and enter https://yourcompany.controlproxy.com/llm/openai/v1 (with /v1, without /chat/completions).

Cursor nuances: (1) Inline autocomplete (Cursor Tab) always routes directly to Cursor’s own servers. (2) On Cursor Teams / Enterprise, if “Restrict Personal API Keys” is enabled in the Cursor Admin Dashboard, Cursor hides the Base URL override setting—turn that toggle off to route Chat/Agent models through Control Proxy.

VS Code & GitHub Copilot

Connect MCP tools in one click from My servers → How to connect → Add to VS Code, run the CLI helper, or commit .vscode/mcp.json directly to Git:

code --add-mcp '{"name":"<gateway-name>","type":"http","url":"https://yourcompany.controlproxy.com/mcp"}'
// .vscode/mcp.json
{
  "servers": {
    "<gateway-name>": {
      "type": "http",
      "url": "https://yourcompany.controlproxy.com/mcp"
    }
  }
}

Switch Copilot Chat to Agent mode and send a message to trigger lazy initialization and corporate SSO login. Optionally, route Copilot Chat models through Control Proxy via Manage Models… → Bring Your Own Key using https://yourcompany.controlproxy.com/llm/openai/v1 or https://yourcompany.controlproxy.com/llm/anthropic (standard inline completions stay with GitHub/Microsoft).

Microsoft 365 Copilot Studio

Microsoft hosts and bills the built-in LLM inside your M365 tenant, so no third-party LLM gateway sits in front of it. Control Proxy governs every external MCP tool and data source your Copilot Studio and M365 Copilot agents call, enforcing per-user Microsoft Entra ID identity, approvals, DLP, AI Judge, and audit logging.

  1. Prerequisites: Connect Microsoft Entra ID in Control Proxy, enable Generative orchestration under Settings → Generative AI in Copilot Studio, and publish your target MCP servers.
  2. Entra OAuth app: In Microsoft Entra admin center, register a single-tenant app (e.g., Control Proxy — Copilot Studio MCP), create a client secret, grant delegated permissions to your Control Proxy gateway API app scope (plus offline_access), and click Grant admin consent.
  3. Add MCP tool in Copilot Studio: Open Tools → + Add a tool → New tool → Model Context Protocol. Set Transport to Streamable HTTP (never deprecated SSE) and Server URL to https://yourcompany.controlproxy.com/mcp—or use a single-server URL https://yourcompany.controlproxy.com/s/<server-slug>/mcp to keep a focused business agent’s tool list small and accurate.
  4. Finish redirect URI: Enter your Entra OAuth 2.0 endpoints, Client ID, Client Secret, and Scopes, save to obtain Copilot Studio’s generated Redirect URL (https://global.consent.azure-apim.net/redirect/...), and add it as a Web redirect URI on the Entra app registration.