Skip to content

Commit 3cc27e3

Browse files
committed
feat: Add mcp-session-id header to HTTP request trace attributes
1 parent a33d5c0 commit 3cc27e3

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### feat: Add mcp-session-id header to HTTP request trace attributes
2+
3+
Includes the value of the [Mcp-Session-Id](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#session-management) HTTP header as an attribute of the trace for HTTP requests to the MCP Server

crates/apollo-mcp-server/src/server/states/starting.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ impl Starting {
222222
"mcp_server",
223223
method = %request.method(),
224224
uri = %request.uri(),
225+
session_id = %request.headers().get("mcp-session-id").and_then(|v| v.to_str().ok()).unwrap_or("none"),
225226
status_code = tracing::field::Empty,
226227
)
227228
})

crates/apollo-mcp-server/src/telemetry_attributes.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ impl TelemetryAttribute {
2929
TelemetryAttribute::ClientVersion => {
3030
Key::from_static_str(TelemetryAttribute::ClientVersion.as_str())
3131
}
32+
TelemetryAttribute::SessionId => {
33+
Key::from_static_str(TelemetryAttribute::SessionId.as_str())
34+
}
3235
}
3336
}
3437

crates/apollo-mcp-server/telemetry.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ success = "Sucess flag indicator"
77
raw_operation = "Graphql operation text and metadata used for Tool generation"
88
client_name = "The client name that initializes with the MCP Server"
99
client_version = "The client version that initializes with the MCP Server"
10+
session_id = "The value of the Mcp-Session-Id header in the HTTP request"
1011

1112
[metrics.apollo.mcp]
1213
"initialize.count" = "Number of times initialize has been called"

0 commit comments

Comments
 (0)