Skip to content

feat!: introduce McpObserver for telemetry and message monitoring#136

Merged
hashemix merged 16 commits into
mainfrom
feat/issue-133-telemetry-support
Mar 13, 2026
Merged

feat!: introduce McpObserver for telemetry and message monitoring#136
hashemix merged 16 commits into
mainfrom
feat/issue-133-telemetry-support

Conversation

@hashemix
Copy link
Copy Markdown
Member

📌 Summary

This PR introduces a new McpObserver trait to the SDK, providing a hook mechanism to intercept incoming and outgoing MCP messages. This allows developers to easily apply telemetry, structured logging, debugging, or custom monitoring solutions across their servers and clients without modifying core business logic.

🔍 Related Issues

✨ Changes Made

  • Introduced the McpObserver trait with on_receive and on_send hooks.
  • Integrated message_observer configuration directly into McpClientOptions and HyperServerOptions (ServerOptions).
  • Updated internal client and server runtimes to trigger observer logic on message dispatch and receipt.
  • Added comprehensive examples showing how to build remote HTTP loggers: client_observer.rs and server_observer.rs.
  • Updated hello-world-mcp-server-stdio and simple-mcp-client-streamable-http examples to utilize the new observers.
  • Added a new Message Observer (Telemetry & Monitoring) section to the base and crates README files.
  • Added end-to-end tests for observer logic.

🛠️ Testing Steps

  1. Run the new observer tests locally: cargo test --package rust-mcp-sdk --test test_observer
  2. Launch the hello-world-mcp-server-stdio example and monitor logs using https://app.beeceptor.com/console/rustmcp to see outgoing/incoming server telemetry.

💡 Additional Notes

Operations within on_receive and on_send of the McpObserver trair are on the critical message path. So implementations should either be very fast or spawn an asynchronous, non-blocking task for heavy operations (like HTTP requests) to prevent backpressure.

@hashemix hashemix changed the title Feat/issue 133 telemetry support feat: introduce McpObserver for telemetry and message monitoring Mar 12, 2026
@hashemix hashemix changed the title feat: introduce McpObserver for telemetry and message monitoring feat!: introduce McpObserver for telemetry and message monitoring Mar 12, 2026
@hashemix hashemix merged commit 58df88f into main Mar 13, 2026
3 checks passed
@hashemix hashemix mentioned this pull request Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant