Download the PHP package rasuvaeff/yii3-mcp-telemetry-bridge without Composer

On this page you can find all versions of the php package rasuvaeff/yii3-mcp-telemetry-bridge. 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 yii3-mcp-telemetry-bridge

rasuvaeff/yii3-mcp-telemetry-bridge

Stable Version Total Downloads Build Static analysis Psalm level PHP Русская версия

Observability for MCP servers: a trace span and RED-style metrics for every rasuvaeff/yii3-mcp tools/call, via rasuvaeff/yii3-telemetry and rasuvaeff/yii3-metrics.

Using an AI coding assistant? llms.txt contains a compact API reference you can share with the model. Contributors: see AGENTS.md.

Requirements

Requirement Version
PHP 8.3 – 8.5
rasuvaeff/yii3-mcp ^1.6 \|\| ^2.0
rasuvaeff/yii3-telemetry ^1.0
rasuvaeff/yii3-metrics ^1.0

Both observability cores are vendor-neutral; wire a backend (yii3-telemetry-otel, yii3-metrics-prometheus) or the Null* providers.

Installation

Usage

One params line — the interceptors are resolved through the DI container (the telemetry/metrics facades must be wired, which their configs do):

Use either interceptor alone if you only run one of the two stacks.

Tracing: TracingToolCallInterceptor

Every tools/call — attribute tools, OpenAPI-bridged operations, configurator-registered handlers — becomes one span:

Span field Value
name mcp.tool <tool name> (e.g. mcp.tool order.status)
mcp.tool tool name
mcp.tool.argument.<name> one scalar attribute per argument: masked (***), stringified (arrays as JSON), truncated at 200 bytes
mcp.outcome success / rejected / error (yii3-mcp's shared CallOutcome)
mcp.client.id identity from the endpoint secret (multi-secret setups); absent on stdio
mcp.client.name / mcp.client.version client from the initialize handshake
mcp.session.id MCP session UUID
mcp.session.calls_used tools/call count in this session (when the session budget is on)
mcp.session.budget_remaining remaining budget (when sessionBudget is configured, see below)
status Error + recorded exception on failure; Unset on success

A tool exception is recorded on the span and rethrown — the MCP error envelope the agent sees is unchanged.

Arguments are flattened to per-argument scalar attributes on purpose: the OTel attribute model accepts only primitives and homogeneous lists, so a single nested-array attribute would be silently dropped by an OTel backend.

Manual wiring:

sessionBudget only feeds the mcp.session.budget_remaining attribute — the budget itself is enforced by yii3-mcp's SessionBudgetInterceptor. Since an int cannot be autowired, mirror your session.budget param in a DI factory:

null and the core default 0 both mean unlimited and omit mcp.session.budget_remaining; every positive value publishes it. Negative values are rejected.

OpenTelemetry and SDK Fibers

mcp/sdk runs request handlers in Fibers. The supported concurrent deployment uses OTel automatic Fiber propagation: NTS PHP, ext-ffi, OTEL_PHP_FIBERS_ENABLED=true, and (where FPM loads the observer too late) preloaded vendor/autoload.php. The Integration suite verifies one HTTP parent, one child mcp.tool ... span and isolation across alternating Fibers:

For strictly sequential php-fpm only, a limited fallback is Context::setStorage(new ContextStorage()) before tracing starts. It shares a single current context and is unsafe for event loops or any Fiber that can suspend/resume concurrently. Do not add fork()/switch() only around TracingToolCallInterceptor::$next: the SDK Fiber already exists and the interceptor cannot observe every lifecycle transition.

Metrics: MetricsToolCallInterceptor

Metric Type Labels
mcp_tool_calls_total counter tool, outcome (success/rejected/error)
mcp_tool_call_duration_seconds histogram tool

Duration is the wall time of the wrapped chain (hrtime()), observed on both success and failure. The histogram carries no outcome label to keep cardinality low — errors are counted in the counter.

Manual wiring:

Interceptor order

Put tracing outermost so the span covers the whole chain (rate limits, RBAC, audit) and other interceptors' failures land on the span:

What the telemetry does NOT see

stdio mode (mcp:serve)

The stdio worker is long-running: make sure your tracing backend exports spans per call rather than only on process shutdown (for yii3-telemetry-otel, use a batch processor with a scheduled delay or a simple processor), otherwise spans buffer until the agent disconnects.

Security

Examples

See examples/ — runs offline.

Script Shows Needs server?
tool-call-observability.php A tool call producing a span (logged via LogTracer) and metrics (in-memory snapshot), with a masked password argument no

Dependency analysers

This leaf package is selected by the root application through config-plugin and may legitimately have no class reference in an autoloaded source directory. Keep the direct dependency: the application, not a core package, selects the backend or bridge. Scope the Composer Dependency Analyser exception to this package:

composer-require-checker detects used but undeclared symbols, not unused packages, so this config-only dependency needs no require-checker suppression.

Development

No PHP/Composer on the host — run in Docker via the composer:2 image:

Or with Make: make build, make cs-fix, make psalm, make test.

License

BSD-3-Clause. See LICENSE.md.


All versions of yii3-mcp-telemetry-bridge with dependencies

PHP Build Version
Package Version
Requires php Version 8.3 - 8.5
rasuvaeff/yii3-mcp Version ^1.6 || ^2.0
rasuvaeff/yii3-metrics Version ^1.0
rasuvaeff/yii3-telemetry Version ^1.0
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 rasuvaeff/yii3-mcp-telemetry-bridge contains the following files

Loading the files please wait ...