php-auth-implementation

php-auth-implementation is a cursor rule for Cursor from dalehurley/php-mcp-sdk. It costs 11 tokens per session (2,878 once invoked), scanned A, original, MIT.

A PHP guide for implementing authentication and authorization in MCP software, including OAuth 2.0, tokens, clients, scopes, and expiration times.

In plain words
What is it for?
Use it when adding OAuth login, token exchange, client management, scope handling, or token validation to a PHP MCP server.
Why use it?
It provides the interfaces and structures needed to validate users and control what authenticated clients can access.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when adding OAuth login, token exchange, client management, scope handling, or token validation to a PHP MCP server.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/dalehurley/php-mcp-sdk/php-auth-implementation
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.

Clone the repo
git clone --depth 1 https://github.com/dalehurley/php-mcp-sdk

Made for: Cursor.

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 php-auth-implementation

README.md
[![agentmods](https://agentmods.dev/badge/rules/dalehurley/php-mcp-sdk/php-auth-implementation/github.svg)](https://agentmods.dev/rules/dalehurley/php-mcp-sdk/php-auth-implementation)
Your own site
<a href="https://agentmods.dev/rules/dalehurley/php-mcp-sdk/php-auth-implementation"><img src="https://agentmods.dev/badge/rules/dalehurley/php-mcp-sdk/php-auth-implementation/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for php-auth-implementation

Your own site · 80×15
<a href="https://agentmods.dev/rules/dalehurley/php-mcp-sdk/php-auth-implementation"><img src="https://agentmods.dev/badge/rules/dalehurley/php-mcp-sdk/php-auth-implementation.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 11 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,878 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00011 $0.02878
Opus 5.5 $0.00004 $0.01151
Sonnet 5.5 $0.00002 $0.00576
Haiku 4.5 $0.00001 $0.00288

Measured 1mo ago against content hash 64333f75b97d, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

php-auth-implementation 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 1mo 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.

.cursor/rules/php-auth-implementation.mdc · 435 lines

How it starts

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

PHP MCP Authentication and Authorization Guide

Authentication Architecture

MCP supports OAuth 2.0 authentication with proper token validation and client management.

AuthInfo Interface

namespace MCP\Auth;

interface AuthInfo {
    public function getToken(): string;
    public function getClientId(): string;
    public function getScopes(): array;
    public function getExpiresAt(): ?int;
    public function getResource(): ?string;
    public function getExtra(): array;
}

class DefaultAuthInfo implements AuthInfo {
    public function __construct(
        private string $token,
        private string $clientId,
        private array $scopes,
        private ?int $expiresAt = null,
        private ?string $resource = null,
        private array $extra = []
    ) {}

    // Implement interface methods...
}

OAuth Provider Interface

namespace MCP\Server\Auth;

use React\Promise\PromiseInterface;

interface OAuthProvider {
    /**
     * Get authorization URL
     */
    public function getAuthorizationUrl(array $params): string;

    /**
     * Exchange authorization code for tokens
     */
    public function exchangeCode(string $code, array $params): PromiseInterface;

    /**
     * Refresh an access token
     */
    public function refreshToken(string $refreshToken): PromiseInterface;

    /**
     * Verify an access token
     */
    public function verifyAccessToken(string $token): PromiseInterface;

    /**
     * Revoke a token
     */
    public function revokeToken(string $token, string $tokenType): PromiseInterface;

    /**
     * Get client information
     */
    public function getClient(string $clientId): PromiseInterface;
}

Proxy OAuth Provider

For proxying OAuth requests to an external provider:

namespace MCP\Server\Auth\Providers;

use GuzzleHttp\Client;
use React\Promise\Promise;
use React\Promise\PromiseInterface;

class ProxyOAuthProvider implements OAuthProvider {
    private Client $httpClient;
    private array $endpoints;
    private callable $verifyAccessToken;
    private callable $getClient;

    public function __construct(array $config) {
        $this->httpClient = new Client();
        $this->endpoints = $config['endpoints'];
        $this->verifyAccessToken = $config['verifyAccessToken'];
        $this->getClient = $config['getClient'];
    }

    public function exchangeCode(string $code, array $params): PromiseInterface {
        return new Promise(function ($resolve, $reject) use ($code, $params) {
            try {
                $response = $this->httpClient->post($this->endpoints['tokenUrl'], [
                    'form_params' => [
                        'grant_type' => 'authorization_code',
                        'code' => $code,
                        'redirect_uri' => $params['redirect_uri'],
                        'client_id' => $params['client_id'],
                        'client_secret' => $params['client_secret'] ?? null,
                        'code_verifier' => $params['code_verifier'] ?? null,
                    ]
                ]);

                $data = json_decode($response->getBody()->getContents(), true);
                $resolve($data);
            } catch (\Exception $e) {
                $reject($e);
            }
        });
    }

    public function verifyAccessToken(string $token): PromiseInterface {
        return new Promise(function ($resolve, $reject) use ($token) {
            try {
                $authInfo = ($this->verifyAccessToken)($token);
                $resolve($authInfo);
            } catch (\Exception $e) {
                $reject($e);
            }
        });
    }
}

Read the full file on GitHub · 435 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. 1mo ago First seen · 435 lines · 11 tokens per session scan A 64333f75b97d

Subscribe to this mod's changes

php-auth-implementation is a cursor rule published in the GitHub repository dalehurley/php-mcp-sdk (27 stars, last pushed 11mo ago), licensed MIT. It adds 11 tokens to every session and 2,878 once invoked, about $0.0000 per session on Opus 5.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.