mcp-resend 1.0.0-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +257 -0
  3. package/data/embeddings.json +245241 -0
  4. package/dist/config/environment.d.ts +152 -0
  5. package/dist/config/environment.d.ts.map +1 -0
  6. package/dist/config/environment.js +217 -0
  7. package/dist/config/environment.js.map +1 -0
  8. package/dist/index.d.ts +13 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +119 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/services/rate-limiter.d.ts +90 -0
  13. package/dist/services/rate-limiter.d.ts.map +1 -0
  14. package/dist/services/rate-limiter.js +267 -0
  15. package/dist/services/rate-limiter.js.map +1 -0
  16. package/dist/services/tool-registry.d.ts +219 -0
  17. package/dist/services/tool-registry.d.ts.map +1 -0
  18. package/dist/services/tool-registry.js +459 -0
  19. package/dist/services/tool-registry.js.map +1 -0
  20. package/dist/tools/docs/embeddings-loader.d.ts +69 -0
  21. package/dist/tools/docs/embeddings-loader.d.ts.map +1 -0
  22. package/dist/tools/docs/embeddings-loader.js +218 -0
  23. package/dist/tools/docs/embeddings-loader.js.map +1 -0
  24. package/dist/tools/docs/errors.d.ts +75 -0
  25. package/dist/tools/docs/errors.d.ts.map +1 -0
  26. package/dist/tools/docs/errors.js +145 -0
  27. package/dist/tools/docs/errors.js.map +1 -0
  28. package/dist/tools/docs/index.d.ts +11 -0
  29. package/dist/tools/docs/index.d.ts.map +1 -0
  30. package/dist/tools/docs/index.js +14 -0
  31. package/dist/tools/docs/index.js.map +1 -0
  32. package/dist/tools/docs/metrics.d.ts +94 -0
  33. package/dist/tools/docs/metrics.d.ts.map +1 -0
  34. package/dist/tools/docs/metrics.js +174 -0
  35. package/dist/tools/docs/metrics.js.map +1 -0
  36. package/dist/tools/docs/search-docs-tool.d.ts +54 -0
  37. package/dist/tools/docs/search-docs-tool.d.ts.map +1 -0
  38. package/dist/tools/docs/search-docs-tool.js +231 -0
  39. package/dist/tools/docs/search-docs-tool.js.map +1 -0
  40. package/dist/tools/docs/types.d.ts +70 -0
  41. package/dist/tools/docs/types.d.ts.map +1 -0
  42. package/dist/tools/docs/types.js +7 -0
  43. package/dist/tools/docs/types.js.map +1 -0
  44. package/dist/tools/docs/vector-search.d.ts +80 -0
  45. package/dist/tools/docs/vector-search.d.ts.map +1 -0
  46. package/dist/tools/docs/vector-search.js +297 -0
  47. package/dist/tools/docs/vector-search.js.map +1 -0
  48. package/dist/tools/index.d.ts +27 -0
  49. package/dist/tools/index.d.ts.map +1 -0
  50. package/dist/tools/index.js +3413 -0
  51. package/dist/tools/index.js.map +1 -0
  52. package/dist/utils/mcp-errors.d.ts +109 -0
  53. package/dist/utils/mcp-errors.d.ts.map +1 -0
  54. package/dist/utils/mcp-errors.js +306 -0
  55. package/dist/utils/mcp-errors.js.map +1 -0
  56. package/package.json +77 -0
@@ -0,0 +1,297 @@
1
+ /**
2
+ * Core vector search functionality for documentation.
3
+ * Provides semantic search using embeddings and keyword search as fallback.
4
+ */
5
+ import { loadEmbeddings } from "./embeddings-loader.js";
6
+ import { createDocsError, DocsErrorCode } from "./errors.js";
7
+ // NOTE: Use console.error for logging - stdout is reserved for MCP protocol
8
+ const log = (message) => console.error(`[docs-search] ${message}`);
9
+ /** Timeout for model loading in milliseconds (2 minutes) */
10
+ const MODEL_LOAD_TIMEOUT_MS = 120000;
11
+ /** Maximum retry attempts for model loading */
12
+ const MODEL_LOAD_MAX_RETRIES = 2;
13
+ /** Delay between retry attempts in milliseconds */
14
+ const MODEL_LOAD_RETRY_DELAY_MS = 1000;
15
+ /** Cached embedding pipeline */
16
+ let embedderPipeline = null;
17
+ /** Loading promise to prevent concurrent model loads */
18
+ let embedderLoadingPromise = null;
19
+ /**
20
+ * Helper to create a timeout promise.
21
+ *
22
+ * @param ms - Timeout in milliseconds
23
+ * @param operation - Description of the operation for error message
24
+ * @returns Promise that rejects after timeout
25
+ */
26
+ function createTimeout(ms, operation) {
27
+ return new Promise((_, reject) => {
28
+ setTimeout(() => {
29
+ reject(createDocsError(DocsErrorCode.NETWORK_TIMEOUT, `${operation} timed out after ${ms}ms`));
30
+ }, ms);
31
+ });
32
+ }
33
+ /**
34
+ * Helper to delay execution.
35
+ *
36
+ * @param ms - Delay in milliseconds
37
+ * @returns Promise that resolves after delay
38
+ */
39
+ function delay(ms) {
40
+ return new Promise((resolve) => setTimeout(resolve, ms));
41
+ }
42
+ /**
43
+ * Internal function to load the model without retry logic.
44
+ *
45
+ * @returns Promise resolving to the embedding pipeline
46
+ */
47
+ async function loadModelInternal() {
48
+ // Dynamic import to avoid loading the heavy transformers library until needed
49
+ const { pipeline } = await import("@xenova/transformers");
50
+ const extractor = await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2");
51
+ return extractor;
52
+ }
53
+ /**
54
+ * Load the embedding model (Xenova/all-MiniLM-L6-v2).
55
+ * Lazy loads on first call and caches for subsequent use.
56
+ * Includes timeout and retry logic for robustness.
57
+ *
58
+ * @returns Promise resolving to the embedding pipeline function
59
+ */
60
+ export async function loadEmbedder() {
61
+ if (embedderPipeline !== null) {
62
+ return embedderPipeline;
63
+ }
64
+ if (embedderLoadingPromise !== null) {
65
+ return embedderLoadingPromise;
66
+ }
67
+ log("Loading embedding model: Xenova/all-MiniLM-L6-v2");
68
+ const startTime = Date.now();
69
+ embedderLoadingPromise = (async () => {
70
+ let lastError = null;
71
+ for (let attempt = 0; attempt <= MODEL_LOAD_MAX_RETRIES; attempt++) {
72
+ if (attempt > 0) {
73
+ log(`Retrying model load (attempt ${attempt + 1}/${MODEL_LOAD_MAX_RETRIES + 1})...`);
74
+ await delay(MODEL_LOAD_RETRY_DELAY_MS);
75
+ }
76
+ try {
77
+ // Race between model loading and timeout
78
+ const extractor = await Promise.race([
79
+ loadModelInternal(),
80
+ createTimeout(MODEL_LOAD_TIMEOUT_MS, "Model loading"),
81
+ ]);
82
+ const loadTime = Date.now() - startTime;
83
+ log(`Embedding model loaded in ${loadTime}ms`);
84
+ embedderPipeline = extractor;
85
+ embedderLoadingPromise = null;
86
+ return embedderPipeline;
87
+ }
88
+ catch (error) {
89
+ lastError = error instanceof Error ? error : new Error(String(error));
90
+ log(`Model load attempt ${attempt + 1} failed: ${lastError.message}`);
91
+ // If it's a timeout or network error, retry
92
+ // If it's a different error (e.g., invalid model), don't retry
93
+ const isRetryable = lastError.message.includes("timeout") ||
94
+ lastError.message.includes("ETIMEDOUT") ||
95
+ lastError.message.includes("ECONNRESET") ||
96
+ lastError.message.includes("fetch");
97
+ if (!isRetryable || attempt >= MODEL_LOAD_MAX_RETRIES) {
98
+ break;
99
+ }
100
+ }
101
+ }
102
+ embedderLoadingPromise = null;
103
+ // Convert to DocsError if not already
104
+ if (lastError && "code" in lastError) {
105
+ throw lastError;
106
+ }
107
+ throw createDocsError(DocsErrorCode.MODEL_LOAD_FAILURE, `Failed to load embedding model after ${MODEL_LOAD_MAX_RETRIES + 1} attempts: ${lastError?.message ?? "Unknown error"}`);
108
+ })();
109
+ return embedderLoadingPromise;
110
+ }
111
+ /**
112
+ * Generate embedding vector for a query string.
113
+ *
114
+ * @param query - The text to embed
115
+ * @returns Promise resolving to 384-dimensional embedding vector
116
+ */
117
+ export async function embedQuery(query) {
118
+ const extractor = await loadEmbedder();
119
+ const result = await extractor([query], {
120
+ pooling: "mean",
121
+ normalize: true,
122
+ });
123
+ // Convert Float32Array to regular array
124
+ return Array.from(result.data);
125
+ }
126
+ /**
127
+ * Compute cosine similarity between two vectors.
128
+ * Assumes vectors are already normalized (which they are from the model).
129
+ *
130
+ * @param a - First vector
131
+ * @param b - Second vector
132
+ * @returns Cosine similarity score between -1 and 1
133
+ */
134
+ export function cosineSimilarity(a, b) {
135
+ if (a.length !== b.length) {
136
+ throw createDocsError(DocsErrorCode.DIMENSION_MISMATCH, `Vector dimension mismatch: query has ${a.length} dimensions, stored embedding has ${b.length}`);
137
+ }
138
+ let dotProduct = 0;
139
+ for (let i = 0; i < a.length; i++) {
140
+ dotProduct += a[i] * b[i];
141
+ }
142
+ // Vectors are already normalized, so we just return the dot product
143
+ return dotProduct;
144
+ }
145
+ /**
146
+ * Perform semantic search using vector embeddings.
147
+ *
148
+ * @param query - The search query
149
+ * @param limit - Maximum number of results to return
150
+ * @param maxTokensPerResult - Optional max tokens per result for truncation
151
+ * @returns Promise resolving to array of scored chunks
152
+ */
153
+ export async function semanticSearch(query, limit, maxTokensPerResult) {
154
+ const startTime = Date.now();
155
+ // Load embeddings and generate query embedding in parallel
156
+ const [index, queryEmbedding] = await Promise.all([
157
+ loadEmbeddings(),
158
+ embedQuery(query),
159
+ ]);
160
+ // Score all chunks by cosine similarity
161
+ const scoredChunks = index.chunks.map((chunk) => ({
162
+ id: chunk.id,
163
+ section: chunk.section,
164
+ content: chunk.content,
165
+ tokenCount: chunk.tokenCount,
166
+ sourceUrl: chunk.sourceUrl,
167
+ score: cosineSimilarity(queryEmbedding, chunk.embedding),
168
+ }));
169
+ // Sort by score descending and take top results
170
+ scoredChunks.sort((a, b) => b.score - a.score);
171
+ const topResults = scoredChunks.slice(0, limit);
172
+ // Optionally truncate content
173
+ if (maxTokensPerResult !== undefined) {
174
+ for (const result of topResults) {
175
+ if (result.tokenCount > maxTokensPerResult) {
176
+ result.content = truncateToTokenBudget(result.content, maxTokensPerResult);
177
+ result.tokenCount = maxTokensPerResult;
178
+ }
179
+ }
180
+ }
181
+ const searchTime = Date.now() - startTime;
182
+ log(`Semantic search completed in ${searchTime}ms, found ${topResults.length} results`);
183
+ return topResults;
184
+ }
185
+ /**
186
+ * Perform keyword-based search as fallback.
187
+ * Uses simple case-insensitive substring matching with basic relevance scoring.
188
+ *
189
+ * @param query - The search query
190
+ * @param limit - Maximum number of results to return
191
+ * @returns Promise resolving to array of scored chunks
192
+ */
193
+ export async function keywordSearch(query, limit) {
194
+ const startTime = Date.now();
195
+ const index = await loadEmbeddings();
196
+ // Normalize query for matching
197
+ const queryLower = query.toLowerCase();
198
+ const queryTerms = queryLower.split(/\s+/).filter((term) => term.length >= 2);
199
+ if (queryTerms.length === 0) {
200
+ return [];
201
+ }
202
+ // Score chunks based on keyword matches
203
+ const scoredChunks = [];
204
+ for (const chunk of index.chunks) {
205
+ const contentLower = chunk.content.toLowerCase();
206
+ const sectionLower = chunk.section.toLowerCase();
207
+ // Count term matches
208
+ let matchCount = 0;
209
+ let exactPhraseMatch = false;
210
+ // Check for exact phrase match (higher weight)
211
+ if (contentLower.includes(queryLower) || sectionLower.includes(queryLower)) {
212
+ exactPhraseMatch = true;
213
+ matchCount += queryTerms.length * 2;
214
+ }
215
+ // Check individual term matches
216
+ for (const term of queryTerms) {
217
+ if (contentLower.includes(term)) {
218
+ matchCount++;
219
+ }
220
+ if (sectionLower.includes(term)) {
221
+ matchCount += 0.5; // Section matches are valuable but less than content
222
+ }
223
+ }
224
+ if (matchCount > 0) {
225
+ // Normalize score to 0-1 range (roughly)
226
+ // Max possible score: terms * 2 (exact) + terms (content) + terms * 0.5 (section)
227
+ const maxScore = queryTerms.length * 3.5;
228
+ const normalizedScore = Math.min(matchCount / maxScore, 1);
229
+ scoredChunks.push({
230
+ id: chunk.id,
231
+ section: chunk.section,
232
+ content: chunk.content,
233
+ tokenCount: chunk.tokenCount,
234
+ sourceUrl: chunk.sourceUrl,
235
+ score: exactPhraseMatch ? Math.max(normalizedScore, 0.5) : normalizedScore,
236
+ });
237
+ }
238
+ }
239
+ // Sort by score descending and take top results
240
+ scoredChunks.sort((a, b) => b.score - a.score);
241
+ const topResults = scoredChunks.slice(0, limit);
242
+ const searchTime = Date.now() - startTime;
243
+ log(`Keyword search completed in ${searchTime}ms, found ${topResults.length} results`);
244
+ return topResults;
245
+ }
246
+ /**
247
+ * Truncate content to fit within a token budget.
248
+ * Uses approximate token estimation (4 chars per token).
249
+ *
250
+ * @param content - The content to truncate
251
+ * @param maxTokens - Maximum tokens allowed
252
+ * @returns Truncated content with ellipsis if needed
253
+ */
254
+ export function truncateToTokenBudget(content, maxTokens) {
255
+ // Approximate: 1 token ~= 4 characters for English text
256
+ const maxChars = maxTokens * 4;
257
+ if (content.length <= maxChars) {
258
+ return content;
259
+ }
260
+ // Find a good break point (end of sentence or word)
261
+ let truncateAt = maxChars;
262
+ // Try to find end of sentence within last 20% of allowed length
263
+ const searchStart = Math.floor(maxChars * 0.8);
264
+ const sentenceEnd = content.lastIndexOf(". ", truncateAt);
265
+ if (sentenceEnd > searchStart) {
266
+ truncateAt = sentenceEnd + 1;
267
+ }
268
+ else {
269
+ // Fall back to word boundary
270
+ const wordEnd = content.lastIndexOf(" ", truncateAt);
271
+ if (wordEnd > searchStart) {
272
+ truncateAt = wordEnd;
273
+ }
274
+ }
275
+ return content.slice(0, truncateAt).trim() + "...";
276
+ }
277
+ /**
278
+ * Get statistics about the loaded embeddings.
279
+ * Useful for debugging and status reporting.
280
+ *
281
+ * @returns Object with embeddings statistics, or null if not loaded
282
+ */
283
+ export async function getEmbeddingsStats() {
284
+ try {
285
+ const index = await loadEmbeddings();
286
+ return {
287
+ chunkCount: index.chunks.length,
288
+ dimensions: index.dimensions,
289
+ model: index.model,
290
+ generatedAt: index.generatedAt,
291
+ };
292
+ }
293
+ catch {
294
+ return null;
295
+ }
296
+ }
297
+ //# sourceMappingURL=vector-search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector-search.js","sourceRoot":"","sources":["../../../src/tools/docs/vector-search.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE7D,4EAA4E;AAC5E,MAAM,GAAG,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,iBAAiB,OAAO,EAAE,CAAC,CAAC;AAE3E,4DAA4D;AAC5D,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAErC,+CAA+C;AAC/C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AAM,cAAc,EAAE,CAAC;QACrC,OAAO;YACL,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM;YAC/B,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,WAAW,EAAE,KAAK,CAAC,WAAW;SAC/B,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Tool Definitions for MCP Server
3
+ *
4
+ * Central factory for creating ToolDefinition objects with proper
5
+ * tier and scope assignments per tool-curation.md.
6
+ *
7
+ * @module tools
8
+ */
9
+ import { Resend } from "resend";
10
+ import type { ToolDefinition } from "../services/tool-registry.js";
11
+ /**
12
+ * Create all tool definitions with Resend client.
13
+ * Returns array of ToolDefinition objects ready for registry.
14
+ *
15
+ * If resend is null, only the documentation search tool is returned
16
+ * (docs-only mode when no API key is provided).
17
+ *
18
+ * @param resend - Resend client instance or null for docs-only mode
19
+ * @returns Array of tool definitions
20
+ */
21
+ export declare function createToolDefinitions(resend: Resend | null): ToolDefinition[];
22
+ /**
23
+ * Get tool names by tier.
24
+ * Useful for verification and debugging.
25
+ */
26
+ export declare function getToolNamesByTier(): Record<string, string[]>;
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,8BAA8B,CAAC;AAsjHjF;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,cAAc,EAAE,CAsF7E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAgF7D"}