Download the PHP package code-wheel/mcp-events without Composer
On this page you can find all versions of the php package code-wheel/mcp-events. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download code-wheel/mcp-events
More information about code-wheel/mcp-events
Files in code-wheel/mcp-events
Package mcp-events
Short Description Standardized event classes for MCP (Model Context Protocol) tool execution lifecycle
License MIT
Informations about the package mcp-events
MCP Events
Standardized event classes for MCP (Model Context Protocol) tool execution lifecycle in PHP.
Zero dependencies - pure PHP 8.1+, framework-agnostic.
Installation
Usage
These events follow a standard structure for MCP tool execution observability. Use them with any PSR-14 compatible event dispatcher.
Dispatching Events
Listening to Events
Events
ToolExecutionStartedEvent
Dispatched when tool execution begins.
| Property | Type | Description |
|---|---|---|
toolName |
string | MCP tool name |
pluginId |
string | Implementation plugin ID |
arguments |
array | Sanitized tool arguments |
requestId |
string|int|null | MCP request correlation ID |
timestamp |
float | Start timestamp (microtime) |
ToolExecutionSucceededEvent
Dispatched when tool execution completes successfully.
| Property | Type | Description |
|---|---|---|
toolName |
string | MCP tool name |
pluginId |
string | Implementation plugin ID |
arguments |
array | Sanitized tool arguments |
result |
object | Result object (e.g., CallToolResult from mcp/sdk) |
durationMs |
float | Execution duration in ms |
requestId |
string|int|null | MCP request correlation ID |
ToolExecutionFailedEvent
Dispatched when tool execution fails.
| Property | Type | Description |
|---|---|---|
toolName |
string | MCP tool name |
pluginId |
string | Implementation plugin ID |
arguments |
array | Sanitized tool arguments |
reason |
string | Failure reason constant |
result |
object|null | Result object if available |
exception |
Throwable|null | Exception if thrown |
durationMs |
float | Duration until failure in ms |
requestId |
string|int|null | MCP request correlation ID |
Failure Reasons
| Constant | Description |
|---|---|
REASON_VALIDATION |
Input validation failed |
REASON_ACCESS_DENIED |
Permission denied |
REASON_INSTANTIATION |
Failed to create tool instance |
REASON_INVALID_TOOL |
Tool not found or invalid |
REASON_RESULT |
Result processing failed |
REASON_EXECUTION |
General execution failure |
REASON_POLICY |
Blocked by policy |
REASON_POLICY_APPROVAL |
Requires approval |
REASON_POLICY_BUDGET |
Budget exceeded |
REASON_POLICY_DRY_RUN |
Dry run mode |
REASON_POLICY_SCOPE |
Insufficient scope |
Helper Methods
JSON Serialization
All events implement JsonSerializable for easy logging:
Note: The result object is intentionally excluded from serialization as it may contain sensitive data.
Framework Integration
This package has zero dependencies. When using with mcp/sdk, the result object will be a CallToolResult:
License
MIT