Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 0 additions & 79 deletions packages/mcp-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,6 @@ function createResourceHandler(
attributes: {
"mcp.resource.name": resource.name,
"mcp.resource.uri": uri.toString(),
...(context.mcpClientName && {
"mcp.client.name": context.mcpClientName,
}),
...(context.mcpClientVersion && {
"mcp.client.version": context.mcpClientVersion,
}),
...(context.mcpProtocolVersion && {
"mcp.protocol.version": context.mcpProtocolVersion,
}),
"mcp.server.name": "Sentry MCP",
"mcp.server.version": LIB_VERSION,
...(context.constraints.organizationSlug && {
Expand Down Expand Up @@ -137,15 +128,6 @@ function createTemplateResourceHandler(
attributes: {
"mcp.resource.name": resource.name,
"mcp.resource.uri": uri.toString(),
...(context.mcpClientName && {
"mcp.client.name": context.mcpClientName,
}),
...(context.mcpClientVersion && {
"mcp.client.version": context.mcpClientVersion,
}),
...(context.mcpProtocolVersion && {
"mcp.protocol.version": context.mcpProtocolVersion,
}),
"mcp.server.name": "Sentry MCP",
"mcp.server.version": LIB_VERSION,
...(context.constraints.organizationSlug && {
Expand Down Expand Up @@ -200,12 +182,10 @@ export async function configureServer({
server,
context,
onToolComplete,
onInitialized,
}: {
server: McpServer;
context: ServerContext;
onToolComplete?: () => void;
onInitialized?: () => void | Promise<void>;
}) {
// Get granted scopes with default to read-only scopes
// Normalize to a mutable Set regardless of input being Set or ReadonlySet
Expand All @@ -226,47 +206,6 @@ export async function configureServer({
logIssue(error, transportLogOptions);
};

// Hook into the initialized notification to capture client information
server.server.oninitialized = () => {
const serverInstance = server.server as any;
const clientInfo = serverInstance._clientVersion;
const protocolVersion = serverInstance._protocolVersion;

// Update the context object with client information
if (clientInfo) {
context.mcpClientName = clientInfo.name;
context.mcpClientVersion = clientInfo.version;
}

if (protocolVersion) {
context.mcpProtocolVersion = protocolVersion;
}

// Call the custom onInitialized handler if provided
// Note: MCP SDK doesn't support async callbacks, so we handle promises
// without awaiting to avoid blocking the initialization flow
if (onInitialized) {
const result = onInitialized();
if (result instanceof Promise) {
result.catch((error) => {
const lifecycleLogOptions: LogIssueOptions = {
loggerScope: ["server", "lifecycle"] as const,
contexts: {
lifecycle: {
hook: "onInitialized",
clientName: context.mcpClientName ?? null,
clientVersion: context.mcpClientVersion ?? null,
protocolVersion: context.mcpProtocolVersion ?? null,
},
},
};

logIssue(error, lifecycleLogOptions);
});
}
}
};

for (const resource of RESOURCES) {
if (isTemplateResource(resource)) {
// Handle URI template resources
Expand Down Expand Up @@ -308,15 +247,6 @@ export async function configureServer({
name: `prompts/get ${prompt.name}`,
attributes: {
"mcp.prompt.name": prompt.name,
...(context.mcpClientName && {
"mcp.client.name": context.mcpClientName,
}),
...(context.mcpClientVersion && {
"mcp.client.version": context.mcpClientVersion,
}),
...(context.mcpProtocolVersion && {
"mcp.protocol.version": context.mcpProtocolVersion,
}),
"mcp.server.name": MCP_SERVER_NAME,
"mcp.server.version": LIB_VERSION,
...(context.constraints.organizationSlug && {
Expand Down Expand Up @@ -420,15 +350,6 @@ export async function configureServer({
name: `tools/call ${tool.name}`,
attributes: {
"mcp.tool.name": tool.name,
...(context.mcpClientName && {
"mcp.client.name": context.mcpClientName,
}),
...(context.mcpClientVersion && {
"mcp.client.version": context.mcpClientVersion,
}),
...(context.mcpProtocolVersion && {
"mcp.protocol.version": context.mcpProtocolVersion,
}),
"mcp.server.name": MCP_SERVER_NAME,
"mcp.server.version": LIB_VERSION,
...(context.constraints.organizationSlug && {
Expand Down
4 changes: 0 additions & 4 deletions packages/mcp-server/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,4 @@ export type ServerContext = {
grantedScopes?: Set<Scope> | ReadonlySet<Scope>;
// URL-based session constraints
constraints: Constraints;
// MCP client information captured during initialization
mcpClientName?: string;
mcpClientVersion?: string;
mcpProtocolVersion?: string;
};