Skip to content

Commit fe2c865

Browse files
committed
refactor(mcp-server): improve notification span handling and set attribute names to match OTEL draft semantic convention
1 parent 08c39f1 commit fe2c865

File tree

3 files changed

+179
-174
lines changed

3 files changed

+179
-174
lines changed

packages/core/src/utils/mcp-server/attributes.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,6 @@ export const MCP_RESOURCE_URI_ATTRIBUTE = 'mcp.resource.uri';
5555
*/
5656
export const MCP_PROMPT_NAME_ATTRIBUTE = 'mcp.prompt.name';
5757

58-
// =============================================================================
59-
// NOTIFICATION ATTRIBUTES
60-
// =============================================================================
61-
62-
/**
63-
* Direction of the notification (client_to_server or server_to_client)
64-
* @see https://github.com/open-telemetry/semantic-conventions/blob/3097fb0af5b9492b0e3f55dc5f6c21a3dc2be8df/docs/gen-ai/mcp.md#notification-attributes
65-
*/
66-
export const MCP_NOTIFICATION_DIRECTION_ATTRIBUTE = 'mcp.notification.direction';
67-
6858
// =============================================================================
6959
// NETWORK ATTRIBUTES (OpenTelemetry Standard)
7060
// =============================================================================
@@ -102,6 +92,18 @@ export const CLIENT_PORT_ATTRIBUTE = 'client.port';
10292
*/
10393
export const MCP_SERVER_OP_VALUE = 'mcp.server';
10494

95+
/**
96+
* Sentry operation value for client-to-server notifications
97+
* Following OpenTelemetry MCP semantic conventions
98+
*/
99+
export const MCP_NOTIFICATION_CLIENT_TO_SERVER_OP_VALUE = 'mcp.notification.client_to_server';
100+
101+
/**
102+
* Sentry operation value for server-to-client notifications
103+
* Following OpenTelemetry MCP semantic conventions
104+
*/
105+
export const MCP_NOTIFICATION_SERVER_TO_CLIENT_OP_VALUE = 'mcp.notification.server_to_client';
106+
105107
/**
106108
* Sentry origin value for MCP function spans
107109
*/

0 commit comments

Comments
 (0)