@@ -75,24 +75,27 @@ func NewServer(
7575
7676 // Configure logging hooks to track tool calls and errors
7777 hooks := & mcpserver.Hooks {}
78- hooks .AddBeforeCallTool (func (id any , message * mcp.CallToolRequest ) {
79- logger .Debug (
78+ hooks .AddBeforeCallTool (func (ctx context.Context , id any , message * mcp.CallToolRequest ) {
79+ logger .DebugContext (
80+ ctx ,
8081 "received tool call request" ,
8182 slog .Any ("id" , id ),
8283 slog .String ("tool" , message .Params .Name ),
8384 slog .Any ("arguments" , message .Params .Arguments ),
8485 )
8586 })
86- hooks .AddAfterCallTool (func (id any , message * mcp.CallToolRequest , result * mcp.CallToolResult ) {
87- logger .Info (
87+ hooks .AddAfterCallTool (func (ctx context.Context , id any , message * mcp.CallToolRequest , result * mcp.CallToolResult ) {
88+ logger .InfoContext (
89+ ctx ,
8890 "tool call finished" ,
8991 slog .Any ("id" , id ),
9092 slog .String ("tool" , message .Params .Name ),
9193 slog .Any ("any" , result .Result ),
9294 )
9395 })
94- hooks .AddOnError (func (id any , method mcp.MCPMethod , message any , err error ) {
95- logger .Error (
96+ hooks .AddOnError (func (ctx context.Context , id any , method mcp.MCPMethod , message any , err error ) {
97+ logger .ErrorContext (
98+ ctx ,
9699 "error occurred" ,
97100 slog .Any ("id" , id ),
98101 slog .String ("method" , string (method )),
0 commit comments