Skip to content

Context7 Platform -- Up-to-date docs for AI agents

feat: log sse usage counter

enesgules7f86335cfa19
diff --git a/src/index.ts b/src/index.ts
index 592db175..237a311e 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -69,6 +69,18 @@ const CLI_PORT = (() => {
// Store SSE transports by session ID
const sseTransports: Record<string, SSEServerTransport> = {};
+// Counter for SSE deprecation notice usage
+let sseDeprecationCounter = 0;
+
+/**
+ * Tracks SSE deprecation notice usage and logs every 10th occurrence
+ */
+function trackSseDeprecation(): void {
+ sseDeprecationCounter++;
+ if (sseDeprecationCounter % 10 === 0) {
+ console.error(`SSE deprecated usage count: ${sseDeprecationCounter}`);
+ }
+}
function getClientIp(req: IncomingMessage): string | undefined {
// Check both possible header casings
@@ -166,6 +178,11 @@ For ambiguous queries, request clarification before proceeding with a best-guess
const resultsText = formatSearchResults(searchResponse);
+ // Track SSE deprecation usage
+ if (transportType === "sse") {
+ trackSseDeprecation();
+ }
+
const responseText = `${transportType === "sse" ? sseDeprecationNotice + "\n\n" : ""}Available Libraries (top matches):
Each result includes:
@@ -240,6 +257,11 @@ ${resultsText}`;
};
}
+ // Track SSE deprecation usage
+ if (transportType === "sse") {
+ trackSseDeprecation();
+ }
+
const responseText =
(transportType === "sse" ? sseDeprecationNotice + "\n\n" : "") + fetchDocsResponse;