Skip to content

Commit 29ee2e6

Browse files
committed
Fix formatting on behalf of bread
1 parent 02f30dc commit 29ee2e6

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

packages/mcp-common/src/tools/docs-ai-search.tools.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,30 @@ interface RequiredEnv {
1010
const AiSearchResponseSchema = z.object({
1111
object: z.string(),
1212
search_query: z.string(),
13-
data: z.array(z.object({
14-
file_id: z.string(),
15-
filename: z.string(),
16-
score: z.number(),
17-
attributes: z.object({
18-
modified_date: z.number().optional(),
19-
folder: z.string().optional(),
20-
}).catchall(z.any()),
21-
content: z.array(z.object({
22-
id: z.string(),
23-
type: z.string(),
24-
text: z.string(),
25-
})),
26-
})),
13+
data: z.array(
14+
z.object({
15+
file_id: z.string(),
16+
filename: z.string(),
17+
score: z.number(),
18+
attributes: z
19+
.object({
20+
modified_date: z.number().optional(),
21+
folder: z.string().optional(),
22+
})
23+
.catchall(z.any()),
24+
content: z.array(
25+
z.object({
26+
id: z.string(),
27+
type: z.string(),
28+
text: z.string(),
29+
})
30+
),
31+
})
32+
),
2733
has_more: z.boolean(),
2834
next_page: z.string().nullable(),
2935
})
3036

31-
3237
/**
3338
* Registers the docs search tool with the MCP server using AI Search
3439
* @param server The MCP server instance
@@ -114,7 +119,7 @@ ${result.text}
114119

115120
async function queryAiSearch(ai: Ai, query: string) {
116121
const rawResponse = await doWithRetries(() =>
117-
ai.autorag("docs-mcp-rag").search({
122+
ai.autorag('docs-mcp-rag').search({
118123
query,
119124
})
120125
)
@@ -127,7 +132,7 @@ async function queryAiSearch(ai: Ai, query: string) {
127132
id: item.file_id,
128133
url: sourceToUrl(item.filename),
129134
title: extractTitle(item.filename),
130-
text: item.content.map(c => c.text).join('\n'),
135+
text: item.content.map((c) => c.text).join('\n'),
131136
}))
132137
}
133138

@@ -136,9 +141,7 @@ function sourceToUrl(filename: string): string {
136141
// Example: "workers/configuration/index.md" -> "https://developers.cloudflare.com/workers/configuration/"
137142
return (
138143
'https://developers.cloudflare.com/' +
139-
filename
140-
.replace(/index\.mdx?$/, '')
141-
.replace(/\.mdx?$/, '')
144+
filename.replace(/index\.mdx?$/, '').replace(/\.mdx?$/, '')
142145
)
143146
}
144147

@@ -154,9 +157,7 @@ function extractTitle(filename: string): string {
154157
}
155158

156159
// Convert kebab-case or snake_case to title case
157-
return lastPart
158-
.replace(/[-_]/g, ' ')
159-
.replace(/\b\w/g, l => l.toUpperCase())
160+
return lastPart.replace(/[-_]/g, ' ').replace(/\b\w/g, (l) => l.toUpperCase())
160161
}
161162

162163
/**
@@ -214,4 +215,4 @@ function isRetryableError(error: unknown): boolean {
214215

215216
// Default to retryable for unknown errors (conservative approach)
216217
return true
217-
}
218+
}

0 commit comments

Comments
 (0)