Rocky_Mountain_Vending/.pnpm-store/v10/files/c7/a1e87bdc9fec3f18177be246c170819f39360ec85a337791436ad39a76066ef052b5c2c6ee1d777616e38db7eb34a51c53be44bb8f2b2105d4f7675994014c
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

70 lines
2.1 KiB
Text

import { fill } from '../../utils/object.js';
import { wrapAllMCPHandlers } from './handlers.js';
import { wrapTransportOnMessage, wrapTransportSend, wrapTransportOnClose, wrapTransportError } from './transport.js';
import { validateMcpServerInstance } from './validation.js';
/**
* Tracks wrapped MCP server instances to prevent double-wrapping
* @internal
*/
const wrappedMcpServerInstances = new WeakSet();
/**
* Wraps a MCP Server instance from the `@modelcontextprotocol/sdk` package with Sentry instrumentation.
*
* Compatible with versions `^1.9.0` of the `@modelcontextprotocol/sdk` package.
* Automatically instruments transport methods and handler functions for comprehensive monitoring.
*
* @example
* ```typescript
* import * as Sentry from '@sentry/core';
* import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
* import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
*
* const server = Sentry.wrapMcpServerWithSentry(
* new McpServer({ name: "my-server", version: "1.0.0" })
* );
*
* const transport = new StreamableHTTPServerTransport();
* await server.connect(transport);
* ```
*
* @param mcpServerInstance - MCP server instance to instrument
* @returns Instrumented server instance (same reference)
*/
function wrapMcpServerWithSentry(mcpServerInstance) {
if (wrappedMcpServerInstances.has(mcpServerInstance)) {
return mcpServerInstance;
}
if (!validateMcpServerInstance(mcpServerInstance)) {
return mcpServerInstance;
}
const serverInstance = mcpServerInstance ;
fill(serverInstance, 'connect', originalConnect => {
return async function ( transport, ...restArgs) {
const result = await (originalConnect ).call(
this,
transport,
...restArgs,
);
wrapTransportOnMessage(transport);
wrapTransportSend(transport);
wrapTransportOnClose(transport);
wrapTransportError(transport);
return result;
};
});
wrapAllMCPHandlers(serverInstance);
wrappedMcpServerInstances.add(mcpServerInstance);
return mcpServerInstance ;
}
export { wrapMcpServerWithSentry };
//# sourceMappingURL=index.js.map