|Agent-Auth.
MCP Server

MCP Server

Run the Agent Auth client as an MCP server — expose protocol tools to AI agents in Claude, Cursor, ChatGPT, and other MCP-compatible hosts.

The @auth/agent-cli package includes a built-in MCP (Model Context Protocol) server. When started in MCP mode, it exposes all Agent Auth protocol operations as MCP tools that AI agents can call directly. This is the most common way to give AI tools access to external services through Agent Auth.

Installation

npm install -g @auth/agent-cli

Or run directly with npx:

npx @auth/agent-cli mcp

Configure your MCP host

Add the Agent Auth MCP server to your AI tool's configuration.

Cursor

In your Cursor MCP settings (.cursor/mcp.json):

{
  "mcpServers": {
    "auth-agent": {
      "command": "npx",
      "args": [
        "@auth/agent-cli",
        "mcp",
        "--url", "https://api.example.com"
      ]
    }
  }
}

Claude Desktop

In your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "auth-agent": {
      "command": "npx",
      "args": [
        "@auth/agent-cli",
        "mcp",
        "--url", "https://api.example.com"
      ]
    }
  }
}

Claude Code

claude mcp add auth-agent -- npx @auth/agent-cli mcp --url https://api.example.com

With multiple providers

Pass multiple --url flags to pre-discover several providers at startup:

{
  "mcpServers": {
    "auth-agent": {
      "command": "npx",
      "args": [
        "@auth/agent-cli",
        "mcp",
        "--url", "https://api.bank.com",
        "--url", "https://api.github.com",
        "--directory-url", "https://directory.example.com"
      ]
    }
  }
}

MCP flags

These flags are passed after mcp and control server behavior:

FlagEnv varDescription
--url <urls...>AGENT_AUTH_URLSProvider URLs to auto-discover at startup
--directory-url <url>AGENT_AUTH_DIRECTORY_URLDirectory URL for provider search
--storage-dir <path>AGENT_AUTH_STORAGE_DIRStorage directory (default: ~/.agent-auth)
--host-name <name>AGENT_AUTH_HOST_NAMEHost name for identification
--no-browserAGENT_AUTH_NO_BROWSER=1Don't auto-open browser for approval URLs

Available tools

The MCP server exposes 15 tools that map to the Agent Auth protocol operations. The typical agent workflow is: discover → list capabilities → connect → execute.

Discovery

ToolParametersDescription
list_providersList already discovered/connected providers
search_providersintent (required)Search the directory by name or intent
discover_providerurl (required)Look up a provider from its service URL

Capabilities

ToolParametersDescription
list_capabilitiesprovider (required), query, agent_id, limit, cursorList capabilities offered by a provider
describe_capabilityprovider (required), name (required), agent_idGet full capability definition including input schema

Agent management

ToolParametersDescription
connect_agentprovider (required), capabilities, mode, name, reason, preferred_method, login_hint, binding_message, force_newRegister an agent with a provider
agent_statusagent_id (required)Check agent status and capability grants
request_capabilityagent_id (required), capabilities (required), reason, preferred_method, login_hint, binding_messageRequest additional capabilities
disconnect_agentagent_id (required)Disconnect and revoke an agent
reactivate_agentagent_id (required)Reactivate an expired agent

Execution

ToolParametersDescription
execute_capabilityagent_id (required), capability (required), argumentsExecute a granted capability

Security

ToolParametersDescription
sign_jwtagent_id (required), capabilities, audienceSign an agent JWT for manual auth
rotate_agent_keyagent_id (required)Rotate an agent's keypair
rotate_host_keyissuer (required)Rotate the host keypair for a provider
enroll_hostprovider (required), enrollment_token (required), nameEnroll a host with a one-time enrollment token

How it works

  1. The CLI starts an MCP server over stdio using @modelcontextprotocol/sdk
  2. If --url is provided, those providers are discovered and cached before the server starts accepting connections
  3. All tools from the @auth/agent SDK are registered as MCP tools with JSON Schema validation
  4. When an AI agent calls a tool, the MCP server executes it through the AgentAuthClient and returns the result as JSON
  5. Keys and agent connections are persisted to ~/.agent-auth (or --storage-dir) so state survives restarts

Environment variables

All configuration can also be set via environment variables:

VariableDescription
AGENT_AUTH_STORAGE_DIRStorage directory (default: ~/.agent-auth)
AGENT_AUTH_DIRECTORY_URLDirectory URL for provider search
AGENT_AUTH_HOST_NAMEHost name for identification
AGENT_AUTH_NO_BROWSERSet to 1 to disable auto-opening browser for approval
AGENT_AUTH_URLSComma-separated provider URLs to auto-discover
AGENT_AUTH_ENCRYPTION_KEYKey for encrypting private keys at rest (AES-256-GCM)
AGENT_AUTH_PROVIDERS_FILEPath to JSON file with provider configs
AGENT_AUTH_PROVIDERSJSON string of provider config(s)

Storage

The MCP server uses file-based storage at ~/.agent-auth by default:

FilePurpose
host.jsonHost identity (shared across providers)
agents/<agent-id>.jsonAgent connections
providers/<issuer>.jsonCached provider configs

Private keys are encrypted at rest when AGENT_AUTH_ENCRYPTION_KEY is set.