You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/mcp/src/docs-search/docs-semantic-search.ts
+71-20Lines changed: 71 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -10,23 +10,34 @@ import type { ToolResult } from '../types/tool-result.js';
10
10
exportconstDOCS_SEMANTIC_SEARCH_CONFIG={
11
11
name: 'hf_doc_search',
12
12
description:
13
-
'Search documentation about all of Hugging Face products and libraries (Transformers, Datasets, Diffusers, Gradio, Hub, and more). Use this for the most up-to-date information '+
14
-
'Returns excerpts grouped by Product and Document.',
13
+
'Search and Discover Hugging Face Product and Library documentation. Use an empty query to discover structure and navigation hints and tips. '+
14
+
'You MUST consult this tool for the most up-to-date information when using Hugging Face libraries. Combine with the Product filter to focus results.',
15
15
schema: z.object({
16
16
query: z
17
17
.string()
18
-
.min(3,'Supply at least one search term')
19
18
.max(200,'Query too long')
20
-
.describe('Semantic search query'),
21
-
product: z
22
-
.string()
23
-
.optional()
19
+
.superRefine((value,ctx)=>{
20
+
consttrimmed=value.trim();
21
+
if(trimmed.length===0){
22
+
return;
23
+
}
24
+
if(trimmed.length<3){
25
+
ctx.addIssue({
26
+
code: z.ZodIssueCode.too_small,
27
+
type: 'string',
28
+
minimum: 3,
29
+
inclusive: true,
30
+
message: 'Supply at least one search term',
31
+
});
32
+
}
33
+
})
24
34
.describe(
25
-
'Filter by Product (e.g., "hub", "dataset-viewer", "transformers"). Supply when known for focused results'
35
+
'Start with an empty query for structure, endpoint discovery and navigation tips. Use semantic queries for targetted searches.'
26
36
),
37
+
product: z.string().optional().describe('Filter by Product. Supply when known for focused results'),
27
38
}),
28
39
annotations: {
29
-
title: 'Hugging Face Documentation Library Search',
40
+
title: 'Hugging Face Documentation Search',
30
41
destructiveHint: false,
31
42
readOnlyHint: true,
32
43
openWorldHint: true,
@@ -49,9 +60,16 @@ interface DocSearchApiParams {
49
60
product?: string;
50
61
}
51
62
63
+
interfaceDocsIndexEntry{
64
+
id: string;
65
+
url: string;
66
+
category: string;
67
+
}
68
+
52
69
// Token budget defaults
53
70
constDEFAULT_TOKEN_BUDGET=12500;
54
71
constTRUNCATE_EXCERPT_LENGTH=400;// chars for truncated excerpts
0 commit comments