@fractalizer/mcp-search 0.1.0
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.
- package/README.md +408 -0
- package/dist/constants.d.ts +12 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +12 -0
- package/dist/constants.js.map +1 -0
- package/dist/engine/index.d.ts +5 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +5 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/tool-search-engine.d.ts +70 -0
- package/dist/engine/tool-search-engine.d.ts.map +1 -0
- package/dist/engine/tool-search-engine.js +213 -0
- package/dist/engine/tool-search-engine.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/scoring/strategy-weights.d.ts +20 -0
- package/dist/scoring/strategy-weights.d.ts.map +1 -0
- package/dist/scoring/strategy-weights.js +51 -0
- package/dist/scoring/strategy-weights.js.map +1 -0
- package/dist/strategies/category-search.strategy.d.ts +30 -0
- package/dist/strategies/category-search.strategy.d.ts.map +1 -0
- package/dist/strategies/category-search.strategy.js +81 -0
- package/dist/strategies/category-search.strategy.js.map +1 -0
- package/dist/strategies/description-search.strategy.d.ts +38 -0
- package/dist/strategies/description-search.strategy.d.ts.map +1 -0
- package/dist/strategies/description-search.strategy.js +68 -0
- package/dist/strategies/description-search.strategy.js.map +1 -0
- package/dist/strategies/fuzzy-search.strategy.d.ts +65 -0
- package/dist/strategies/fuzzy-search.strategy.d.ts.map +1 -0
- package/dist/strategies/fuzzy-search.strategy.js +158 -0
- package/dist/strategies/fuzzy-search.strategy.js.map +1 -0
- package/dist/strategies/index.d.ts +12 -0
- package/dist/strategies/index.d.ts.map +1 -0
- package/dist/strategies/index.js +11 -0
- package/dist/strategies/index.js.map +1 -0
- package/dist/strategies/name-search.strategy.d.ts +35 -0
- package/dist/strategies/name-search.strategy.d.ts.map +1 -0
- package/dist/strategies/name-search.strategy.js +99 -0
- package/dist/strategies/name-search.strategy.js.map +1 -0
- package/dist/strategies/search-strategy.interface.d.ts +28 -0
- package/dist/strategies/search-strategy.interface.d.ts.map +1 -0
- package/dist/strategies/search-strategy.interface.js +12 -0
- package/dist/strategies/search-strategy.interface.js.map +1 -0
- package/dist/strategies/weighted-combined.strategy.d.ts +37 -0
- package/dist/strategies/weighted-combined.strategy.d.ts.map +1 -0
- package/dist/strategies/weighted-combined.strategy.js +90 -0
- package/dist/strategies/weighted-combined.strategy.js.map +1 -0
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +7 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/search-tools.definition.d.ts +18 -0
- package/dist/tools/search-tools.definition.d.ts.map +1 -0
- package/dist/tools/search-tools.definition.js +93 -0
- package/dist/tools/search-tools.definition.js.map +1 -0
- package/dist/tools/search-tools.metadata.d.ts +12 -0
- package/dist/tools/search-tools.metadata.d.ts.map +1 -0
- package/dist/tools/search-tools.metadata.js +57 -0
- package/dist/tools/search-tools.metadata.js.map +1 -0
- package/dist/tools/search-tools.schema.d.ts +31 -0
- package/dist/tools/search-tools.schema.d.ts.map +1 -0
- package/dist/tools/search-tools.schema.js +60 -0
- package/dist/tools/search-tools.schema.js.map +1 -0
- package/dist/tools/search-tools.tool.d.ts +57 -0
- package/dist/tools/search-tools.tool.d.ts.map +1 -0
- package/dist/tools/search-tools.tool.js +141 -0
- package/dist/tools/search-tools.tool.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +112 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/build-index-from-registry.d.ts +28 -0
- package/dist/utils/build-index-from-registry.d.ts.map +1 -0
- package/dist/utils/build-index-from-registry.js +80 -0
- package/dist/utils/build-index-from-registry.js.map +1 -0
- package/dist/utils/text-utils.d.ts +48 -0
- package/dist/utils/text-utils.d.ts.map +1 -0
- package/dist/utils/text-utils.js +50 -0
- package/dist/utils/text-utils.js.map +1 -0
- package/package.json +79 -0
package/README.md
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
# @fractalizer/mcp-search
|
|
2
|
+
|
|
3
|
+
**Advanced Tool Search Engine with compile-time indexing and 5 search strategies**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@fractalizer/mcp-search)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## π― Purpose
|
|
11
|
+
|
|
12
|
+
**Principle:** Fast, intelligent tool discovery with compile-time indexing
|
|
13
|
+
|
|
14
|
+
**Key Features:**
|
|
15
|
+
- β
**Compile-time indexing** β zero runtime overhead for index generation
|
|
16
|
+
- β
**5 search strategies** β name, description, category, fuzzy, weighted-combined
|
|
17
|
+
- β
**LRU cache** β fast repeated searches
|
|
18
|
+
- β
**MCP tool included** β `search_tools` for Claude to discover tools
|
|
19
|
+
|
|
20
|
+
**Architecture rule:** Search depends ONLY on `@fractalizer/mcp-core`
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## π¦ Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install @fractalizer/mcp-search
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Dependencies:**
|
|
31
|
+
- `@fractalizer/mcp-core` (BaseTool, utilities)
|
|
32
|
+
- `@fractalizer/mcp-infrastructure` (via core)
|
|
33
|
+
- `lru-cache` (caching)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## π Structure
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
src/
|
|
41
|
+
βββ engine/
|
|
42
|
+
β βββ tool-search-engine.ts # Main search engine with LRU cache
|
|
43
|
+
βββ strategies/ # 5 search strategies
|
|
44
|
+
β βββ search-strategy.interface.ts
|
|
45
|
+
β βββ name-search.strategy.ts # Match by tool name
|
|
46
|
+
β βββ description-search.strategy.ts # Match in description
|
|
47
|
+
β βββ category-search.strategy.ts # Match by category
|
|
48
|
+
β βββ fuzzy-search.strategy.ts # Fuzzy matching
|
|
49
|
+
β βββ weighted-combined.strategy.ts # Combine all strategies
|
|
50
|
+
βββ scoring/
|
|
51
|
+
β βββ strategy-weights.ts # Configurable weights
|
|
52
|
+
βββ tools/ # MCP tool for search
|
|
53
|
+
β βββ search-tools.tool.ts
|
|
54
|
+
β βββ search-tools.metadata.ts # Metadata
|
|
55
|
+
β βββ search-tools.definition.ts
|
|
56
|
+
β βββ search-tools.schema.ts
|
|
57
|
+
βββ utils/ # Utilities
|
|
58
|
+
β βββ build-index-from-registry.ts # Index builder
|
|
59
|
+
β βββ text-utils.ts # Text processing
|
|
60
|
+
βββ constants.ts # Constants
|
|
61
|
+
βββ types.ts # Type definitions
|
|
62
|
+
βββ index.ts # Public exports
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## π§ Core Components
|
|
68
|
+
|
|
69
|
+
### ToolSearchEngine
|
|
70
|
+
|
|
71
|
+
**Main search engine** with LRU cache and strategy selection.
|
|
72
|
+
|
|
73
|
+
**Usage:**
|
|
74
|
+
```typescript
|
|
75
|
+
import { ToolSearchEngine } from '@fractalizer/mcp-search';
|
|
76
|
+
|
|
77
|
+
// Create engine with tool metadata
|
|
78
|
+
const engine = new ToolSearchEngine(toolMetadataArray);
|
|
79
|
+
|
|
80
|
+
// Search with default strategy (weighted-combined)
|
|
81
|
+
const results = engine.search('find issues');
|
|
82
|
+
|
|
83
|
+
// Search with specific strategy
|
|
84
|
+
const nameResults = engine.search('get_issue', 'name');
|
|
85
|
+
const fuzzyResults = engine.search('isue', 'fuzzy');
|
|
86
|
+
|
|
87
|
+
console.log(results);
|
|
88
|
+
// [
|
|
89
|
+
// { tool: ToolMetadata, score: 0.95 },
|
|
90
|
+
// { tool: ToolMetadata, score: 0.78 },
|
|
91
|
+
// ...
|
|
92
|
+
// ]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Cache:**
|
|
96
|
+
- LRU cache with max 100 entries
|
|
97
|
+
- Cache key: `${query}_${strategy}`
|
|
98
|
+
- Automatic eviction of least recently used
|
|
99
|
+
|
|
100
|
+
### Search Strategies
|
|
101
|
+
|
|
102
|
+
**5 strategies with different matching algorithms:**
|
|
103
|
+
|
|
104
|
+
#### 1. NameSearchStrategy
|
|
105
|
+
Matches query against tool name.
|
|
106
|
+
|
|
107
|
+
**Example:**
|
|
108
|
+
```typescript
|
|
109
|
+
Query: "get_issue"
|
|
110
|
+
Matches: "get_issue" (exact), "get_issues" (partial)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
#### 2. DescriptionSearchStrategy
|
|
114
|
+
Matches query words in tool description.
|
|
115
|
+
|
|
116
|
+
**Example:**
|
|
117
|
+
```typescript
|
|
118
|
+
Query: "retrieve task details"
|
|
119
|
+
Matches tools with descriptions containing "retrieve", "task", "details"
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### 3. CategorySearchStrategy
|
|
123
|
+
Matches query against tool category.
|
|
124
|
+
|
|
125
|
+
**Example:**
|
|
126
|
+
```typescript
|
|
127
|
+
Query: "api"
|
|
128
|
+
Matches all tools with category: "api"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### 4. FuzzySearchStrategy
|
|
132
|
+
Fuzzy matching using Levenshtein distance.
|
|
133
|
+
|
|
134
|
+
**Example:**
|
|
135
|
+
```typescript
|
|
136
|
+
Query: "isue" (typo)
|
|
137
|
+
Matches: "issue" (distance: 1)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
#### 5. WeightedCombinedStrategy (Default)
|
|
141
|
+
Combines all strategies with configurable weights.
|
|
142
|
+
|
|
143
|
+
**Default weights:**
|
|
144
|
+
```typescript
|
|
145
|
+
{
|
|
146
|
+
name: 0.4, // 40% - name match most important
|
|
147
|
+
description: 0.3, // 30% - description match
|
|
148
|
+
category: 0.2, // 20% - category match
|
|
149
|
+
fuzzy: 0.1, // 10% - fuzzy fallback
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Usage:**
|
|
154
|
+
```typescript
|
|
155
|
+
import { WeightedCombinedStrategy, STRATEGY_WEIGHTS } from '@fractalizer/mcp-search';
|
|
156
|
+
|
|
157
|
+
// Custom weights
|
|
158
|
+
const customWeights = {
|
|
159
|
+
...STRATEGY_WEIGHTS,
|
|
160
|
+
fuzzy: 0.2, // Increase fuzzy matching importance
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const strategy = new WeightedCombinedStrategy(customWeights);
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## π οΈ Compile-time Indexing
|
|
169
|
+
|
|
170
|
+
**Automatic index generation at build time:**
|
|
171
|
+
|
|
172
|
+
1. **prebuild script** (in package.json):
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"scripts": {
|
|
176
|
+
"prebuild": "tsx scripts/generate-tool-index.ts"
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
2. **Script scans** `TOOL_CLASSES` and extracts `METADATA`:
|
|
182
|
+
```typescript
|
|
183
|
+
// scripts/generate-tool-index.ts
|
|
184
|
+
const TOOL_CLASSES = [
|
|
185
|
+
GetIssueTool,
|
|
186
|
+
FindIssuesTool,
|
|
187
|
+
// ...
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
// Generates: src/generated-index.ts
|
|
191
|
+
export const TOOL_INDEX = [
|
|
192
|
+
{ name: 'get_issue', category: 'api', description: '...' },
|
|
193
|
+
{ name: 'find_issues', category: 'api', description: '...' },
|
|
194
|
+
];
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
3. **Search engine** uses pre-generated index (no runtime reflection):
|
|
198
|
+
```typescript
|
|
199
|
+
import { TOOL_INDEX } from './generated-index.js';
|
|
200
|
+
|
|
201
|
+
const engine = new ToolSearchEngine(TOOL_INDEX);
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Benefits:**
|
|
205
|
+
- β‘ Zero runtime overhead for index generation
|
|
206
|
+
- π Type-safe (compile-time validation)
|
|
207
|
+
- π¦ Smaller bundle (no reflection code)
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## π MCP Tool: search_tools
|
|
212
|
+
|
|
213
|
+
**Included MCP tool** for Claude to discover available tools.
|
|
214
|
+
|
|
215
|
+
**Tool name:** `search_tools`
|
|
216
|
+
|
|
217
|
+
**Usage in Claude:**
|
|
218
|
+
```
|
|
219
|
+
User: "What tools are available for working with issues?"
|
|
220
|
+
Claude uses: search_tools { query: "issues" }
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Parameters:**
|
|
224
|
+
```typescript
|
|
225
|
+
{
|
|
226
|
+
query: string; // Search query
|
|
227
|
+
strategy?: string; // Optional: 'name' | 'description' | 'category' | 'fuzzy' | 'weighted'
|
|
228
|
+
limit?: number; // Optional: max results (default: 10)
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**Example response:**
|
|
233
|
+
```json
|
|
234
|
+
{
|
|
235
|
+
"results": [
|
|
236
|
+
{
|
|
237
|
+
"name": "get_issue",
|
|
238
|
+
"category": "api",
|
|
239
|
+
"description": "Retrieve issue details by key",
|
|
240
|
+
"score": 0.95
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"name": "find_issues",
|
|
244
|
+
"category": "api",
|
|
245
|
+
"description": "Search issues using JQL query",
|
|
246
|
+
"score": 0.82
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## π¨ Critical Rules
|
|
255
|
+
|
|
256
|
+
### 1. Always regenerate index after adding tools
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
# Index is regenerated automatically on build
|
|
260
|
+
npm run build
|
|
261
|
+
|
|
262
|
+
# Or manually:
|
|
263
|
+
npm run prebuild
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### 2. METADATA is required for all tools
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
// β
CORRECT
|
|
270
|
+
class MyTool extends BaseTool<TFacade> {
|
|
271
|
+
static readonly METADATA: StaticToolMetadata = {
|
|
272
|
+
name: 'my_tool',
|
|
273
|
+
category: 'api',
|
|
274
|
+
description: 'Tool description',
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// β WRONG (no METADATA)
|
|
279
|
+
class MyTool extends BaseTool<TFacade> {
|
|
280
|
+
// Search won't find this tool
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### 3. Use WeightedCombinedStrategy for best results
|
|
285
|
+
|
|
286
|
+
```typescript
|
|
287
|
+
// β
CORRECT (default, best accuracy)
|
|
288
|
+
const results = engine.search('find tasks');
|
|
289
|
+
|
|
290
|
+
// β οΈ OK (specific strategy for special cases)
|
|
291
|
+
const exactMatch = engine.search('get_issue', 'name');
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## π API Reference
|
|
297
|
+
|
|
298
|
+
### Exports
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
// Engine
|
|
302
|
+
export { ToolSearchEngine } from './engine/tool-search-engine.js';
|
|
303
|
+
|
|
304
|
+
// Strategies
|
|
305
|
+
export type { SearchStrategy } from './strategies/search-strategy.interface.js';
|
|
306
|
+
export { NameSearchStrategy } from './strategies/name-search.strategy.js';
|
|
307
|
+
export { DescriptionSearchStrategy } from './strategies/description-search.strategy.js';
|
|
308
|
+
export { CategorySearchStrategy } from './strategies/category-search.strategy.js';
|
|
309
|
+
export { FuzzySearchStrategy } from './strategies/fuzzy-search.strategy.js';
|
|
310
|
+
export { WeightedCombinedStrategy } from './strategies/weighted-combined.strategy.js';
|
|
311
|
+
|
|
312
|
+
// Scoring
|
|
313
|
+
export { STRATEGY_WEIGHTS } from './scoring/strategy-weights.js';
|
|
314
|
+
|
|
315
|
+
// Tools
|
|
316
|
+
export { SearchToolsTool } from './tools/search-tools.tool.js';
|
|
317
|
+
export { SearchToolsDefinition } from './tools/search-tools.definition.js';
|
|
318
|
+
|
|
319
|
+
// Generated index
|
|
320
|
+
export { TOOL_INDEX } from './generated-index.js';
|
|
321
|
+
|
|
322
|
+
// Types
|
|
323
|
+
export type { ToolMetadata, SearchResult, StrategyWeights } from './types.js';
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## π§ͺ Testing
|
|
329
|
+
|
|
330
|
+
**Run tests:**
|
|
331
|
+
```bash
|
|
332
|
+
cd packages/framework/search
|
|
333
|
+
npm run test
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**With coverage:**
|
|
337
|
+
```bash
|
|
338
|
+
npm run test:coverage
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**Watch mode:**
|
|
342
|
+
```bash
|
|
343
|
+
npm run test:watch
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## π― Advanced Usage
|
|
349
|
+
|
|
350
|
+
### Custom Search Strategy
|
|
351
|
+
|
|
352
|
+
```typescript
|
|
353
|
+
import { SearchStrategy, ToolMetadata } from '@fractalizer/mcp-search';
|
|
354
|
+
|
|
355
|
+
class CustomSearchStrategy implements SearchStrategy {
|
|
356
|
+
search(query: string, tools: ToolMetadata[]) {
|
|
357
|
+
return tools
|
|
358
|
+
.filter((tool) => /* custom logic */)
|
|
359
|
+
.map((tool) => ({
|
|
360
|
+
tool,
|
|
361
|
+
score: /* custom scoring */,
|
|
362
|
+
}));
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Use custom strategy
|
|
367
|
+
const engine = new ToolSearchEngine(TOOL_INDEX);
|
|
368
|
+
engine.registerStrategy('custom', new CustomSearchStrategy());
|
|
369
|
+
const results = engine.search('query', 'custom');
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Adjusting Weights
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
import { STRATEGY_WEIGHTS } from '@fractalizer/mcp-search';
|
|
376
|
+
|
|
377
|
+
const customWeights = {
|
|
378
|
+
...STRATEGY_WEIGHTS,
|
|
379
|
+
name: 0.5, // Increase name importance
|
|
380
|
+
description: 0.3,
|
|
381
|
+
category: 0.1,
|
|
382
|
+
fuzzy: 0.1,
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
const strategy = new WeightedCombinedStrategy(customWeights);
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## π€ Contributing
|
|
391
|
+
|
|
392
|
+
See [../../.github/CONTRIBUTING.md](../../.github/CONTRIBUTING.md)
|
|
393
|
+
|
|
394
|
+
**Architecture rules:** [../../CLAUDE.md](../../CLAUDE.md)
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## π License
|
|
399
|
+
|
|
400
|
+
MIT License
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
## π Links
|
|
405
|
+
|
|
406
|
+
- **Monorepo root:** [../../README.md](../../README.md)
|
|
407
|
+
- **Architecture:** [../../ARCHITECTURE.md](../../ARCHITECTURE.md)
|
|
408
|
+
- **Core package:** [../core/README.md](../core/README.md)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ΠΠΎΠ½ΡΡΠ°Π½ΡΡ Π΄Π»Ρ ΡΠΈΡΡΠ΅ΠΌΡ ΠΏΠΎΠΈΡΠΊΠ° tools
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* ΠΠ΅ΡΠΎΠ»ΡΠ½ΠΎΠ΅ ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠΎΠ² ΠΏΠΎΠΈΡΠΊΠ°
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_TOOL_SEARCH_LIMIT: 10;
|
|
8
|
+
/**
|
|
9
|
+
* ΠΠ΅ΡΠΎΠ»ΡΠ½ΡΠΉ ΡΡΠΎΠ²Π΅Π½Ρ Π΄Π΅ΡΠ°Π»ΠΈΠ·Π°ΡΠΈΠΈ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠΎΠ²
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_TOOL_SEARCH_DETAIL_LEVEL: "name_and_description";
|
|
12
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAG,EAAW,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,gCAAgC,EAAG,sBAA+B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ΠΠΎΠ½ΡΡΠ°Π½ΡΡ Π΄Π»Ρ ΡΠΈΡΡΠ΅ΠΌΡ ΠΏΠΎΠΈΡΠΊΠ° tools
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* ΠΠ΅ΡΠΎΠ»ΡΠ½ΠΎΠ΅ ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠΎΠ² ΠΏΠΎΠΈΡΠΊΠ°
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT_TOOL_SEARCH_LIMIT = 10;
|
|
8
|
+
/**
|
|
9
|
+
* ΠΠ΅ΡΠΎΠ»ΡΠ½ΡΠΉ ΡΡΠΎΠ²Π΅Π½Ρ Π΄Π΅ΡΠ°Π»ΠΈΠ·Π°ΡΠΈΠΈ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠΎΠ²
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_TOOL_SEARCH_DETAIL_LEVEL = 'name_and_description';
|
|
12
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAW,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,sBAA+B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ΠΠ»Π°Π²Π½ΡΠΉ ΠΊΠ»Π°ΡΡ ΠΏΠΎΠΈΡΠΊΠΎΠ²ΠΎΠΉ ΡΠΈΡΡΠ΅ΠΌΡ tools
|
|
3
|
+
*
|
|
4
|
+
* Responsibilities:
|
|
5
|
+
* - ΠΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΏΠΎΠΈΡΠΊΠ° ΡΠ΅ΡΠ΅Π· ΡΡΡΠ°ΡΠ΅Π³ΠΈΠΈ
|
|
6
|
+
* - Π€ΠΈΠ»ΡΡΡΠ°ΡΠΈΡ ΠΏΠΎ ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΡΠΌ ΠΈ ΡΠΈΠΏΠ°ΠΌ
|
|
7
|
+
* - ΠΠ΅ΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠΎΠ²
|
|
8
|
+
* - Π€ΠΎΡΠΌΠ°ΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠΎΠ² ΠΏΠΎ ΡΡΠΎΠ²Π½Ρ Π΄Π΅ΡΠ°Π»ΠΈΠ·Π°ΡΠΈΠΈ
|
|
9
|
+
* - Lazy loading ΠΏΠΎΠ»Π½ΡΡ
ΠΌΠ΅ΡΠ°Π΄Π°Π½Π½ΡΡ
|
|
10
|
+
*/
|
|
11
|
+
import type { ISearchStrategy } from '../strategies/search-strategy.interface.js';
|
|
12
|
+
import type { SearchParams, SearchResponse, StaticToolIndex } from '../types.js';
|
|
13
|
+
import type { ToolRegistry } from '@fractalizer/mcp-core';
|
|
14
|
+
/**
|
|
15
|
+
* ΠΠΎΠΈΡΠΊΠΎΠ²ΡΠΉ Π΄Π²ΠΈΠΆΠΎΠΊ Π΄Π»Ρ tools
|
|
16
|
+
*/
|
|
17
|
+
export declare class ToolSearchEngine {
|
|
18
|
+
private readonly staticIndex;
|
|
19
|
+
private readonly toolRegistry;
|
|
20
|
+
private searchStrategy;
|
|
21
|
+
private cache;
|
|
22
|
+
private lazyIndex;
|
|
23
|
+
/**
|
|
24
|
+
* ΠΠ°ΠΊΡΠΈΠΌΠ°Π»ΡΠ½ΡΠΉ ΡΠ°Π·ΠΌΠ΅Ρ ΠΊΠ΅ΡΠ° (LRU)
|
|
25
|
+
*/
|
|
26
|
+
private readonly MAX_CACHE_SIZE;
|
|
27
|
+
constructor(staticIndex: readonly StaticToolIndex[] | null, toolRegistry: ToolRegistry, searchStrategy: ISearchStrategy);
|
|
28
|
+
/**
|
|
29
|
+
* ΠΠΎΠ»ΡΡΠΈΡΡ ΠΈΠ½Π΄Π΅ΠΊΡ (ΡΡΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΠΉ ΠΈΠ»ΠΈ Π΄ΠΈΠ½Π°ΠΌΠΈΡΠ΅ΡΠΊΠΈΠΉ ΠΈΠ· ToolRegistry)
|
|
30
|
+
*/
|
|
31
|
+
private getIndex;
|
|
32
|
+
/**
|
|
33
|
+
* ΠΠΎΡΡΡΠΎΠΈΡΡ ΠΈΠ½Π΄Π΅ΠΊΡ ΠΈΠ· ToolRegistry
|
|
34
|
+
*/
|
|
35
|
+
private buildIndexFromRegistry;
|
|
36
|
+
/**
|
|
37
|
+
* ΠΡΠΏΠΎΠ»Π½ΠΈΡΡ ΠΏΠΎΠΈΡΠΊ Ρ ΠΊΠ΅ΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ
|
|
38
|
+
*/
|
|
39
|
+
search(params: SearchParams): SearchResponse;
|
|
40
|
+
/**
|
|
41
|
+
* ΠΡΠΏΠΎΠ»Π½ΠΈΡΡ ΠΏΠΎΠΈΡΠΊ Π±Π΅Π· ΠΊΠ΅ΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ
|
|
42
|
+
*/
|
|
43
|
+
private performSearch;
|
|
44
|
+
/**
|
|
45
|
+
* Π€ΠΈΠ»ΡΡΡΠΎΠ²Π°ΡΡ ΠΈΠ½Π΄Π΅ΠΊΡ ΠΏΠΎ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠ°ΠΌ
|
|
46
|
+
*/
|
|
47
|
+
private filterIndex;
|
|
48
|
+
/**
|
|
49
|
+
* Π€ΠΎΡΠΌΠ°ΡΠΈΡΠΎΠ²Π°ΡΡ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΡ ΠΏΠΎ ΡΡΠΎΠ²Π½Ρ Π΄Π΅ΡΠ°Π»ΠΈΠ·Π°ΡΠΈΠΈ
|
|
50
|
+
*/
|
|
51
|
+
private formatResults;
|
|
52
|
+
/**
|
|
53
|
+
* ΠΠ΅Π½Π΅ΡΠΈΡΠΎΠ²Π°ΡΡ ΠΊΠ»ΡΡ ΠΊΠ΅ΡΠ° ΠΈΠ· ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠΎΠ² ΠΏΠΎΠΈΡΠΊΠ°
|
|
54
|
+
*/
|
|
55
|
+
private getCacheKey;
|
|
56
|
+
/**
|
|
57
|
+
* ΠΡΠΈΡΡΠΈΡΡ ΠΊΠ΅Ρ
|
|
58
|
+
*
|
|
59
|
+
* ΠΠΎΠ»Π΅Π·Π½ΠΎ Π΄Π»Ρ ΡΠ΅ΡΡΠΎΠ² ΠΈ ΠΏΡΠΈ ΠΎΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΠΈ ΠΈΠ½Π΄Π΅ΠΊΡΠ°
|
|
60
|
+
*/
|
|
61
|
+
clearCache(): void;
|
|
62
|
+
/**
|
|
63
|
+
* ΠΠΎΠ»ΡΡΠΈΡΡ ΡΡΠ°ΡΠΈΡΡΠΈΠΊΡ ΠΊΠ΅ΡΠ°
|
|
64
|
+
*/
|
|
65
|
+
getCacheStats(): {
|
|
66
|
+
size: number;
|
|
67
|
+
maxSize: number;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=tool-search-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-search-engine.d.ts","sourceRoot":"","sources":["../../src/engine/tool-search-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EAEd,eAAe,EAGhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAI1D;;GAEG;AACH,qBAAa,gBAAgB;IAWzB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAX/B,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,KAAK,CAA8B;IAC3C,OAAO,CAAC,SAAS,CAAkC;IAEnD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAO;gBAGnB,WAAW,EAAE,SAAS,eAAe,EAAE,GAAG,IAAI,EAC9C,YAAY,EAAE,YAAY,EAC3C,cAAc,EAAE,eAAe;IAMjC;;OAEG;IACH,OAAO,CAAC,QAAQ;IAchB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA+B9B;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc;IA2B5C;;OAEG;IACH,OAAO,CAAC,aAAa;IAiCrB;;OAEG;IACH,OAAO,CAAC,WAAW;IAgBnB;;OAEG;IACH,OAAO,CAAC,aAAa;IA6CrB;;OAEG;IACH,OAAO,CAAC,WAAW;IAUnB;;;;OAIG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,aAAa,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CAMnD"}
|