Skip to content

[jaegermcp] Log tool name in MCP middleware for tools/call requests#8235

Open
lopster568 wants to merge 1 commit intojaegertracing:mainfrom
lopster568:jaegermcp-log-tool-name
Open

[jaegermcp] Log tool name in MCP middleware for tools/call requests#8235
lopster568 wants to merge 1 commit intojaegertracing:mainfrom
lopster568:jaegermcp-log-tool-name

Conversation

@lopster568
Copy link
Copy Markdown
Contributor

Which problem is this PR solving?

The logging middleware logs the MCP method (e.g. tools/call) but not which specific tool was invoked. Operators cannot distinguish between search_traces, get_services, or health calls in logs, making it difficult to debug issues or understand tool-level usage patterns.

Before:

MCP request  session_id=abc  method=tools/call
MCP response session_id=abc  method=tools/call  duration=5ms

After:

MCP request  session_id=abc  method=tools/call  tool=search_traces
MCP response session_id=abc  method=tools/call  tool=search_traces  duration=5ms

This aligns with ADR-002 Phase 4 Item 10 (structured logging for debugging).

Description of the changes

  • Extract tool name from CallToolParamsRaw when the method is tools/call
  • Include tool field in both request and response log entries
  • Add extractToolName helper that returns empty string for non-tool methods
  • Refactor log field construction to build fields once and reuse for request/response
  • Add TestLoggingMiddlewareToolName test that verifies tool name appears in logs
  • Refactor test helpers (sendMCPRequest, deleteMCPSession) to reduce duplication

How was this change tested?

go test ./cmd/jaeger/internal/extension/jaegermcp/ -run TestLogging -v -count=1
make fmt && make lint && make test

Checklist

@lopster568 lopster568 requested a review from a team as a code owner March 23, 2026 11:50
Copilot AI review requested due to automatic review settings March 23, 2026 11:50
@dosubot dosubot bot added the enhancement label Mar 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances Jaeger MCP’s logging middleware to include the invoked tool name for tools/call requests, improving operator visibility into tool-level usage and debugging signals.

Changes:

  • Extract tool name from tools/call request params and add it as a structured tool log field on both request/response logs.
  • Refactor logging middleware to build a shared set of log fields reused between request and response log entries.
  • Add unit test coverage validating that tool name is present in logs for tools/call requests, and refactor test helpers to reduce duplication.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cmd/jaeger/internal/extension/jaegermcp/logging_middleware.go Adds tool field logging for tools/call via extractToolName and reuses built fields for request/response logs.
cmd/jaeger/internal/extension/jaegermcp/logging_middleware_test.go Adds TestLoggingMiddlewareToolName and introduces request/session helper functions used by logging tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lopster568 lopster568 force-pushed the jaegermcp-log-tool-name branch from ebdb8a9 to 5300493 Compare March 23, 2026 11:55
The logging middleware currently logs the MCP method (e.g. "tools/call")
but not which tool was invoked. This makes it difficult for operators to
identify tool-level usage patterns, latency, and errors from logs alone.

Extract the tool name from CallToolParamsRaw on tools/call requests and
include it as a "tool" field in both request and response log entries.

Signed-off-by: lopster568 <lopster568@users.noreply.github.com>
Signed-off-by: Roshan <rosh.s568@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants