Skip to content

Add Telemetry & Metrics Tool with Message Filters (dotnet_server_metrics) #63

@jongalloway

Description

@jongalloway

Expose lightweight, privacy-respecting metrics and leverage MCP SDK 1.0's Message Filters for telemetry collection.

Tool: dotnet_server_metrics

Returns counts per tool, avg duration ms, cache hit rate.

Implementation

Metrics Accumulator (original scope)

  • In-memory metrics collection
  • JSON response with per-tool stats
  • Reset metrics subcommand
  • No PII stored

Message Filters Integration (new — requires MCP SDK 1.0)

MCP SDK 1.0 introduces Message Filters — middleware for intercepting and processing MCP requests/responses. This provides the ideal infrastructure for collecting tool execution telemetry without modifying individual tool implementations.

Planned filters:

  • Telemetry filter: Automatically capture tool invocation counts, durations, success/failure rates — feeds the dotnet_server_metrics tool
  • Rate limiting filter: Protect against excessive tool invocations
  • Validation filter: Pre-validate common parameters (paths, framework TFMs) before tool execution
  • Logging filter: Structured logging of all MCP traffic for diagnostics

Implementation:

  • Create TelemetryFilter implementing IMessageFilter to capture metrics
  • Wire filter into MCP server pipeline in Program.cs
  • Feed filter-collected data to the metrics accumulator
  • Consider additional filters (rate limiting, validation) as follow-ups

References:

Acceptance Criteria

  • Metrics accumulator (in-memory)
  • JSON response
  • Reset metrics subcommand
  • No PII stored
  • At least one Message Filter wired in for telemetry collection

Dependencies

  • Blocked on MCP SDK 1.0 upgrade (see parent tracking issue)

Metadata

Metadata

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions