@sendinel/mcp-server 1.0.204 → 1.0.205
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.
|
@@ -12,7 +12,7 @@ export interface ScoredTool<T extends SearchableTool = SearchableTool> {
|
|
|
12
12
|
score: number;
|
|
13
13
|
}
|
|
14
14
|
export interface RankResult<T extends SearchableTool = SearchableTool> {
|
|
15
|
-
/** Every tool with score > 0, best first (not truncated). */
|
|
15
|
+
/** Every eligible tool with score > 0, best first (not truncated). */
|
|
16
16
|
matches: ScoredTool<T>[];
|
|
17
17
|
/** Closest tools when nothing matched; empty only when `entries` is empty. */
|
|
18
18
|
nearest: ScoredTool<T>[];
|
|
@@ -122,13 +122,32 @@ function fuzzyScore(entry, queryTokens, aliases) {
|
|
|
122
122
|
}
|
|
123
123
|
return score;
|
|
124
124
|
}
|
|
125
|
+
// These filler/catalog words carry no description-only signal even in a small catalog.
|
|
126
|
+
// Keep them out of tokenize/scoreTool: a name, alias or group hit remains valid (#4628).
|
|
127
|
+
const DESCRIPTION_FILLER = new Set(['no', 'such', 'tool', 'thing']);
|
|
125
128
|
const byScoreThenName = (a, b) => b.score - a.score || a.entry.name.localeCompare(b.entry.name);
|
|
126
129
|
export function rankTools(entries, query, options = {}) {
|
|
127
130
|
const aliases = options.aliases ?? TOOL_ALIASES;
|
|
128
131
|
const nearestLimit = options.nearestLimit ?? 5;
|
|
129
132
|
const queryTokens = tokenize(query);
|
|
133
|
+
// Count each stemmed word once per description, using only the permitted/scoped catalog.
|
|
134
|
+
const descriptions = entries.map((entry) => toolTokens(entry, aliases).description);
|
|
135
|
+
const frequency = new Map();
|
|
136
|
+
for (const words of descriptions) {
|
|
137
|
+
for (const word of words)
|
|
138
|
+
frequency.set(word, (frequency.get(word) ?? 0) + 1);
|
|
139
|
+
}
|
|
140
|
+
// A single occurrence stays useful in catalogs smaller than four entries.
|
|
141
|
+
const maxFrequency = Math.max(1, Math.floor(entries.length / 4));
|
|
142
|
+
const distinctive = queryTokens.filter((token) => !STOPWORDS.has(token)
|
|
143
|
+
&& !DESCRIPTION_FILLER.has(token) && (frequency.get(token) ?? 0) <= maxFrequency);
|
|
130
144
|
const matches = entries
|
|
131
|
-
.map((entry) =>
|
|
145
|
+
.map((entry, index) => {
|
|
146
|
+
// Preserve all existing scores and OR semantics once there is meaningful evidence.
|
|
147
|
+
const eligible = scoreTool({ ...entry, description: '' }, queryTokens, query, aliases) > 0
|
|
148
|
+
|| distinctive.some((token) => descriptions[index].has(token));
|
|
149
|
+
return { entry, score: eligible ? scoreTool(entry, queryTokens, query, aliases) : 0 };
|
|
150
|
+
})
|
|
132
151
|
.filter((s) => s.score > 0)
|
|
133
152
|
.sort(byScoreThenName);
|
|
134
153
|
if (matches.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sendinel/mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.205",
|
|
4
4
|
"description": "AI-controlled email operations control plane for campaigns, contacts, segments, analytics, and multi-provider sending via MCP.",
|
|
5
5
|
"mcpName": "ai.sendinel/mcp-server",
|
|
6
6
|
"type": "module",
|