Download the PHP package sw9t/php-mcp-tool-definition without Composer

On this page you can find all versions of the php package sw9t/php-mcp-tool-definition. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-mcp-tool-definition

php-mcp-tool-definition

PHP >=8.2 Version

Zero-dependency PHP library for describing Model Context Protocol (MCP) tool definitions via typed PHP classes.

Produces the exact JSON structure that MCP clients and servers expect, with full support for all four official protocol versions.


Table of Contents


Requirements

No runtime dependencies. PHPUnit 11 is required for running tests.


Installation


Protocol Version Support

The library ships one namespace per official MCP protocol version. Each version is a class that extends the previous one — fields are strictly additive, so you always get a superset of the older version's output.

Namespace Protocol date New fields
McpToolDefinition\V20241105 2024-11-05 name, description, inputSchema
McpToolDefinition\V20250326 2025-03-26 annotations (title + behaviour hints)
McpToolDefinition\V20250618 2025-06-18 title (top-level), outputSchema
McpToolDefinition\V20251125 2025-11-25 execution (task support mode)
McpToolDefinition\Latest always latest alias — points to the most recent above

McpSchema and McpProperty are shared across all versions — import them from the root namespace.


Quick Start

Use McpToolDefinition\Latest to always stay on the most recent protocol version, or pick a specific versioned namespace if you need to pin to a particular protocol date.


Class Reference

Latest — always current version

The McpToolDefinition\Latest namespace is a stable alias that always points to the most recent protocol version. Use this if you don't need to pin to a specific protocol version.

When a new MCP protocol version is released and added to the library, the Latest files are updated to point to it — your use statements stay untouched.

Why is TaskSupport not in Latest? PHP does not support extending enums, so it is impossible to create a Latest\TaskSupport that is a subtype of V20251125\TaskSupport. Import it directly from the version namespace — it is a simple backed enum and unlikely to change between versions.


McpSchema

Represents a JSON Schema object. Wraps an array of McpProperty instances and builds the properties map and required array automatically.

When constructed with no arguments it produces {"type":"object","properties":{}} — a valid empty schema for tools that accept no input.


McpProperty

Represents one property inside a schema. All factory methods accept $name, $description, and $required. The string factory additionally accepts $enum.

Factory JSON type Extra parameters
McpProperty::string($name, $desc, $req, $enum, $maxLength) string enum: list<string>, maxLength: int
McpProperty::integer($name, $desc, $req, $min, $max, $enum) integer minimum, maximum: int\|float, enum: list<int>
McpProperty::number($name, $desc, $req, $min, $max) number minimum, maximum: int\|float
McpProperty::boolean($name, $desc, $req) boolean
McpProperty::object($name, McpSchema, $desc, $req) object
McpProperty::array($name, McpSchema\|PropertyType, $desc, $req, $minItems, $maxItems) array minItems, maxItems: int

Pass PropertyType::StringType (or any other PropertyType) as $items to produce a primitive item schema (e.g. "items": {"type": "string"}). Pass a McpSchema for arrays of objects.


V20241105 — McpToolDefinition

Minimal tool definition. Suitable for servers running the initial 2024-11-05 protocol.


V20250326 — McpToolDefinition + McpToolAnnotations

Adds annotations with a display title and four behavioural hints.

All annotation fields are optional; null values are omitted from the output.


V20250618 — McpToolDefinition

Adds a top-level title field and outputSchema.

Display name precedence (highest to lowest): titleannotations.titlename.


V20251125 — McpToolDefinition + McpToolExecution + TaskSupport

Adds execution to support long-running tools via the MCP task polling mechanism.


Usage Examples

Tool without parameters


Tool with typed parameters


Enum constraint


Numeric constraints


Array of primitives


Nested object


Array of objects


Annotations and hints (2025-03-26+)


Output schema (2025-06-18+)


Long-running task execution (2025-11-25+)


Full example — latest version


Development

No local PHP installation required — all commands run inside Docker.


License

MIT — see LICENSE.


All versions of php-mcp-tool-definition with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sw9t/php-mcp-tool-definition contains the following files

Loading the files please wait ...