php-types-validation

A set of PHP rules for defining and validating types in an MCP software development kit. MCP is a protocol for connecting AI tools and applications.

In plain words
What is it for?
Use it when implementing or reviewing PHP MCP types, protocol versions, JSON-RPC errors, and validation code.
Why use it?
It keeps protocol values, error codes, metadata, and other data structures consistent and type-safe.

Cursor rule for Cursor

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 rules/dalehurley/php-mcp-sdk/php-types-validation
Clone the repo
git clone --depth 1 https://github.com/dalehurley/php-mcp-sdk

Made for: Cursor.

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,699 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 $0.00011 $0.02699
Opus 5 $0.00005 $0.01350
Sonnet 5 $0.00002 $0.00540
Haiku 4.5 $0.00001 $0.00270

Measured yesterday against content hash e45bd24ce3c1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

php-types-validation 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 yesterday.

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-types-validation.mdc · 490 lines

How it starts

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

PHP MCP Types and Validation Guide

Core Type Definitions

PHP MCP SDK should use strong typing with PHP 8+ features to match TypeScript's type safety.

Protocol Version Constants

namespace MCP\Types;

final class Protocol {
    public const LATEST_PROTOCOL_VERSION = '2025-06-18';
    public const DEFAULT_NEGOTIATED_PROTOCOL_VERSION = '2025-03-26';
    public const SUPPORTED_PROTOCOL_VERSIONS = [
        '2025-06-18',
        '2025-03-26',
        '2024-11-05',
        '2024-10-07',
    ];
    public const JSONRPC_VERSION = '2.0';
}

Error Codes Enum

namespace MCP\Types;

enum ErrorCode: int {
    // SDK error codes
    case ConnectionClosed = -32000;
    case RequestTimeout = -32001;

    // Standard JSON-RPC error codes
    case ParseError = -32700;
    case InvalidRequest = -32600;
    case MethodNotFound = -32601;
    case InvalidParams = -32602;
    case InternalError = -32603;
}

Base Types

namespace MCP\Types;

/**
 * Base metadata interface
 */
interface BaseMetadata {
    public function getName(): string;
    public function getTitle(): ?string;
}

/**
 * Implementation info
 */
class Implementation implements BaseMetadata {
    public function __construct(
        private string $name,
        private string $version,
        private ?string $title = null
    ) {}

    public function getName(): string {
        return $this->name;
    }

    public function getVersion(): string {
        return $this->version;
    }

    public function getTitle(): ?string {
        return $this->title;
    }

    public function toArray(): array {
        $data = [
            'name' => $this->name,
            'version' => $this->version,
        ];

        if ($this->title !== null) {
            $data['title'] = $this->title;
        }

        return $data;
    }
}

Content Types

namespace MCP\Types\Content;

interface ContentBlock {
    public function getType(): string;
    public function toArray(): array;
}

class TextContent implements ContentBlock {
    public function __construct(
        private string $text,
        private array $meta = []
    ) {}

    public function getType(): string {
        return 'text';
    }

    public function getText(): string {
        return $this->text;
    }

    public function toArray(): array {
        $data = [
            'type' => 'text',
            'text' => $this->text,
        ];

        if (!empty($this->meta)) {
            $data['_meta'] = $this->meta;
        }

        return $data;
    }
}

class ImageContent implements ContentBlock {
    public function __construct(
        private string $data,
        private string $mimeType,
        private array $meta = []
    ) {}

    public function getType(): string {
        return 'image';
    }

    public function toArray(): array {
        return [
            'type' => 'image',
            'data' => $this->data,
            'mimeType' => $this->mimeType,
            '_meta' => $this->meta ?: null,
        ];
    }
}

class ResourceLink implements ContentBlock {
    public function __construct(
        private string $uri,
        private string $name,
        private ?string $title = null,
        private ?string $description = null,
        private ?string $mimeType = null
    ) {}

    public function getType(): string {
        return 'resource_link';
    }

    public function toArray(): array {
        return array_filter([
            'type' => 'resource_link',
            'uri' => $this->uri,
            'name' => $this->name,
            'title' => $this->title,
            'description' => $this->description,
            'mimeType' => $this->mimeType,
        ], fn($v) => $v !== null);
    }
}

Read the full file on GitHub · 490 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. yesterday First seen · 490 lines · 11 tokens per session scan A e45bd24ce3c1

Subscribe to this mod's changes

php-types-validation is a cursor rule published in the GitHub repository dalehurley/php-mcp-sdk (27 stars, last pushed 9mo ago), licensed MIT. It adds 11 tokens to every session and 2,699 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.