Skip to content

Commit 7b5fd86

Browse files
committed
move files to intregations directory
1 parent 25297f6 commit 7b5fd86

File tree

5 files changed

+22
-25
lines changed

5 files changed

+22
-25
lines changed

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export { featureFlagsIntegration, type FeatureFlagsIntegration } from './integra
118118
export { profiler } from './profiling';
119119
export { instrumentFetchRequest } from './fetch';
120120
export { trpcMiddleware } from './trpc';
121-
export { wrapMcpServerWithSentry } from './mcp-server';
121+
export { wrapMcpServerWithSentry } from './integrations/mcp-server';
122122
export { captureFeedback } from './feedback';
123123
export type { ReportDialogOptions } from './report-dialog';
124124
export { _INTERNAL_captureLog, _INTERNAL_flushLogsBuffer, _INTERNAL_captureSerializedLog } from './logs/exports';

packages/core/src/mcp-server.ts renamed to packages/core/src/integrations/mcp-server/index.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
import type {
2-
ExtraHandlerData,
3-
MCPServerInstance,
4-
MCPTransport,
5-
} from './utils/mcp-server/types';
1+
import { fill } from '../../utils/object';
2+
import type { ExtraHandlerData, MCPServerInstance, MCPTransport } from './types';
63
import {
74
createMcpNotificationSpan,
85
createMcpOutgoingNotificationSpan,
96
createMcpServerSpan,
107
isJsonRpcNotification,
118
isJsonRpcRequest,
129
validateMcpServerInstance,
13-
} from './utils/mcp-server/utils';
14-
import { fill } from './utils/object';
10+
} from './utils';
1511

1612
const wrappedMcpServerInstances = new WeakSet();
1713

packages/core/src/utils/mcp-server/utils.ts renamed to packages/core/src/integrations/mcp-server/utils.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
1010
} from '../../semanticAttributes';
1111
import { startSpan } from '../../tracing';
12-
import { logger } from '../logger';
12+
import { logger } from '../../utils/logger';
1313
import {
1414
CLIENT_ADDRESS_ATTRIBUTE,
1515
CLIENT_PORT_ATTRIBUTE,
@@ -30,6 +30,7 @@ import {
3030
NETWORK_TRANSPORT_ATTRIBUTE,
3131
} from './attributes';
3232
import type { ExtraHandlerData, JsonRpcNotification, JsonRpcRequest, McpSpanConfig, MCPTransport, MethodConfig } from './types';
33+
import { isURLObjectRelative, parseStringToURLObject } from '../../utils/url';
3334

3435
/** Validates if a message is a JSON-RPC request */
3536
export function isJsonRpcRequest(message: unknown): message is JsonRpcRequest {
@@ -102,17 +103,17 @@ const METHOD_CONFIGS: Record<string, MethodConfig> = {
102103
};
103104

104105
/** Extracts target info from method and params based on method type */
105-
function extractTargetInfo(method: string, params: Record<string, unknown>): {
106-
target?: string;
107-
attributes: Record<string, string>
106+
function extractTargetInfo(method: string, params: Record<string, unknown>): {
107+
target?: string;
108+
attributes: Record<string, string>
108109
} {
109110
const config = METHOD_CONFIGS[method as keyof typeof METHOD_CONFIGS];
110111
if (!config) {
111112
return { attributes: {} };
112113
}
113114

114-
const target = config.targetField && typeof params?.[config.targetField] === 'string'
115-
? params[config.targetField] as string
115+
const target = config.targetField && typeof params?.[config.targetField] === 'string'
116+
? params[config.targetField] as string
116117
: undefined;
117118

118119
return {
@@ -125,7 +126,7 @@ function extractTargetInfo(method: string, params: Record<string, unknown>): {
125126
function getRequestArguments(method: string, params: Record<string, unknown>): Record<string, string> {
126127
const args: Record<string, string> = {};
127128
const config = METHOD_CONFIGS[method as keyof typeof METHOD_CONFIGS];
128-
129+
129130
if (!config) {
130131
return args;
131132
}
@@ -160,13 +161,13 @@ function getTransportTypes(transport: MCPTransport): { mcpTransport: string; net
160161
if (transportName.includes('stdio')) {
161162
return { mcpTransport: 'stdio', networkTransport: 'pipe' };
162163
}
163-
164+
164165
// Streamable HTTP is the standard HTTP-based transport
165166
// The official SDK uses 'StreamableHTTPServerTransport' / 'StreamableHTTPClientTransport'
166167
if (transportName.includes('streamablehttp') || transportName.includes('streamable')) {
167168
return { mcpTransport: 'http', networkTransport: 'tcp' };
168169
}
169-
170+
170171
// SSE is the deprecated HTTP+SSE transport (backwards compatibility)
171172
// Note: Modern Streamable HTTP can use SSE internally, but SSE transport is deprecated
172173
if (transportName.includes('sse')) {
@@ -335,7 +336,7 @@ function buildTypeSpecificAttributes(
335336
if (type === 'request') {
336337
const request = message as JsonRpcRequest;
337338
const targetInfo = extractTargetInfo(request.method, params || {});
338-
339+
339340
return {
340341
...(request.id !== undefined && { [MCP_REQUEST_ID_ATTRIBUTE]: String(request.id) }),
341342
...targetInfo.attributes,
@@ -354,7 +355,7 @@ function buildTypeSpecificAttributes(
354355
function buildSentryAttributes(type: McpSpanConfig['type']): Record<string, string> {
355356
let op: string;
356357
let origin: string;
357-
358+
358359
switch (type) {
359360
case 'request':
360361
op = MCP_SERVER_OP_VALUE;
@@ -369,7 +370,7 @@ function buildSentryAttributes(type: McpSpanConfig['type']): Record<string, stri
369370
origin = MCP_NOTIFICATION_ORIGIN_VALUE;
370371
break;
371372
}
372-
373+
373374
return {
374375
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,
375376
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,
@@ -432,17 +433,17 @@ export function createMcpOutgoingNotificationSpan(
432433
/**
433434
* Combine the two extraction functions into one
434435
*/
435-
function extractClientInfo(extra: ExtraHandlerData): {
436-
address?: string;
437-
port?: number
436+
function extractClientInfo(extra: ExtraHandlerData): {
437+
address?: string;
438+
port?: number
438439
} {
439440
return {
440441
address: extra?.requestInfo?.remoteAddress ||
441442
extra?.clientAddress ||
442443
extra?.request?.ip ||
443444
extra?.request?.connection?.remoteAddress,
444-
port: extra?.requestInfo?.remotePort ||
445-
extra?.clientPort ||
445+
port: extra?.requestInfo?.remotePort ||
446+
extra?.clientPort ||
446447
extra?.request?.connection?.remotePort
447448
};
448449
}

0 commit comments

Comments
 (0)