@@ -11,13 +11,33 @@ import (
1111
1212// The file contains methods for easily adding tracing to a MCP server.
1313
14+ // TracingConfig holds configuration for adding tracing to an MCP server.
1415type TracingConfig struct {
16+ // Hooks allows you to provide custom hooks that will be merged with Datadog tracing hooks.
17+ // If nil, only Datadog tracing hooks will be added and any custom hooks provided via server.WithHooks(...) will be removed.
18+ // If provided, your custom hooks will be executed alongside Datadog tracing hooks.
1519 Hooks * server.Hooks
1620}
1721
18- // Pass to server.NewMCPServer to add tracing to the server.
22+ // WithTracing adds Datadog tracing to an MCP server.
23+ // Pass this option to server.NewMCPServer to enable tracing.
24+ //
1925// Do not use with `server.WithHooks(...)`, as this overwrites the hooks.
20- // Pass custom hooks in the TracingConfig instead, which in turn is passed to server.WithHooks(...).
26+ // Instead, pass custom hooks in the TracingConfig, which will be merged with tracing hooks.
27+ //
28+ // Usage:
29+ //
30+ // // Simple usage with only tracing hooks
31+ // srv := server.NewMCPServer("my-server", "1.0.0",
32+ // WithTracing(nil))
33+ //
34+ // // With custom hooks
35+ // customHooks := &server.Hooks{}
36+ // customHooks.AddBeforeInitialize(func(ctx context.Context, id any, request *mcp.InitializeRequest) {
37+ // // Your custom logic here
38+ // })
39+ // srv := server.NewMCPServer("my-server", "1.0.0",
40+ // WithTracing(&TracingConfig{Hooks: customHooks}))
2141func WithTracing (options * TracingConfig ) server.ServerOption {
2242 return func (s * server.MCPServer ) {
2343 if options == nil {
0 commit comments