spring-projects / spring-projects/spring-ai
Expose server-side metrics for MCP @McpTool invocations
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Context
Spring AI is frequently used as an MCP server, exposing tools via methods annotated with @McpTool. For production reliability, debugging, and SLA monitoring, it's important to have native metrics for server-side tool invocations (calls from external MCP clients to tools/call).
Current Behavior
Currently, only client-side (ChatClient / agent) tool calls are instrumented with Micrometer/Observation metrics. Server-side MCP tool invocations (@McpTool methods called by external MCP clients) do not emit built-in metrics for latency, count, or success/error rates.
Expected Behavior
Spring AI should natively expose standardized metrics for each server-side invocation of an @McpTool method, tracking usage, latency, and success/failure rates per tool. Metrics should include low-cardinality tags such as tool.name, protocol, and async, and be available via Micrometer for dashboarding and alerting. This will provide consistent observability for both client and server tool calls.
Related Issues
- #3853
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the server-side @McpTool invocation path for external MCP tools/call requests, then compare it with the existing client-side Micrometer/Observation instrumentation. Done means server-side invocations expose latency, counts, and success/error metrics through Micrometer with the requested low-cardinality tool.name, protocol, and async tags.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100