@@ -11,12 +11,14 @@ call `MCPServer(...)`.
1111```
1212
1313That is a complete, traced server. Call ` search_books ` and a span is created for it. The same is
14- true for the low-level ` Server ` : the tracing lives on both.
14+ true when a client reads ` catalog://featured ` or renders ` reading_prompt ` . The low-level ` Server `
15+ is traced too.
1516
1617## What you get
1718
18- Every inbound message becomes a ` SERVER ` span named after the method and its target. So a
19- ` tools/call ` for ` search_books ` is the span ` tools/call search_books ` , and a bare ` tools/list `
19+ Every inbound message becomes a ` SERVER ` span named after the method, plus a target for named
20+ operations. So a ` tools/call ` for ` search_books ` is the span ` tools/call search_books ` ,
21+ a ` prompts/get ` for ` reading_prompt ` is ` prompts/get reading_prompt ` , and a bare ` tools/list `
2022is just ` tools/list ` .
2123
2224Each span carries a few attributes:
@@ -31,13 +33,25 @@ OpenTelemetry's [GenAI semantic conventions](https://opentelemetry.io/docs/specs
3133* ` gen_ai.operation.name ` , set to ` "execute_tool" ` .
3234* ` gen_ai.tool.name ` , set to the tool being called.
3335
34- A ` prompts/get ` span gets ` gen_ai.prompt.name ` in the same spirit. The list methods carry no
36+ A ` prompts/get ` span gets ` gen_ai.prompt.name ` in the same spirit. ` resources/read ` spans are
37+ created by the same middleware and carry the common ` mcp.* ` attributes; the SDK does not add the
38+ resource URI to the span name or to a ` gen_ai.* ` attribute today. The list methods carry no
3539` gen_ai.* ` keys, because there is nothing to name.
3640
3741!!! tip
3842 Those GenAI attributes are the reason a tracing UI groups your tool calls the way it groups
3943 any other agent's. You get that grouping for free, with no extra code.
4044
45+ ## Adding your own detail
46+
47+ The SDK span wraps the request handler. That means a tool, resource, or prompt function runs with
48+ the SDK-created span already current.
49+
50+ If you need more detail than the default attributes provide, create child spans inside your handler
51+ or in your own middleware. For example, a resource handler can add a child span for a database read,
52+ and a prompt handler can add one for template assembly. Those spans nest under ` resources/read ` or
53+ ` prompts/get ` , so a tracing backend still shows one connected request.
54+
4155## It costs nothing until you want it
4256
4357Here is the part that makes "on by default" a comfortable default.
0 commit comments