Skip to content

Commit c03a3cc

Browse files
committed
Make AddServerHooks private
1 parent 1467efe commit c03a3cc

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

contrib/mark3labs/mcp-go/mcpgo.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ type textIOAnnotator interface {
3131
AnnotateTextIO(input, output string, opts ...llmobs.AnnotateOption)
3232
}
3333

34-
// AddServerHooks appends Datadog tracing hooks to an existing server.Hooks object.
35-
func AddServerHooks(hooks *server.Hooks) {
36-
ddHooks := newHooks()
37-
hooks.AddBeforeInitialize(ddHooks.onBeforeInitialize)
38-
hooks.AddAfterInitialize(ddHooks.onAfterInitialize)
39-
hooks.AddOnError(ddHooks.onError)
34+
// appendTracingHooks appends Datadog tracing hooks to an existing server.Hooks object.
35+
func appendTracingHooks(hooks *server.Hooks) {
36+
tracingHooks := newHooks()
37+
hooks.AddBeforeInitialize(tracingHooks.onBeforeInitialize)
38+
hooks.AddAfterInitialize(tracingHooks.onAfterInitialize)
39+
hooks.AddOnError(tracingHooks.onError)
4040
}
4141

4242
func NewToolHandlerMiddleware() server.ToolHandlerMiddleware {

contrib/mark3labs/mcp-go/mcpgo_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestAddServerHooks(t *testing.T) {
3434
defer mt.Stop()
3535

3636
serverHooks := &server.Hooks{}
37-
AddServerHooks(serverHooks)
37+
appendTracingHooks(serverHooks)
3838

3939
assert.Len(t, serverHooks.OnBeforeInitialize, 1)
4040
assert.Len(t, serverHooks.OnAfterInitialize, 1)
@@ -46,7 +46,7 @@ func TestIntegrationSessionInitialize(t *testing.T) {
4646
defer tt.Stop()
4747

4848
srv := server.NewMCPServer("test-server", "1.0.0",
49-
WithTracing(&TracingConfig{}))
49+
WithTracing(nil))
5050

5151
ctx := context.Background()
5252
initRequest := `{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test-client","version":"1.0.0"}}}`
@@ -99,7 +99,7 @@ func TestIntegrationToolCallSuccess(t *testing.T) {
9999
defer tt.Stop()
100100

101101
srv := server.NewMCPServer("test-server", "1.0.0",
102-
WithTracing(&TracingConfig{}))
102+
WithTracing(nil))
103103

104104
calcTool := mcp.NewTool("calculator",
105105
mcp.WithDescription("A simple calculator"))

contrib/mark3labs/mcp-go/option.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func WithTracing(options *TracingConfig) server.ServerOption {
3030
if hooks == nil {
3131
hooks = &server.Hooks{}
3232
}
33-
AddServerHooks(hooks)
33+
appendTracingHooks(hooks)
3434

3535
server.WithHooks(hooks)(s)
3636

0 commit comments

Comments
 (0)