Skip to content

Commit cb3901f

Browse files
authored
Merge pull request #261 from triepod-ai/feat/add-tool-annotations
feat: Add tool annotations for improved LLM tool understanding
2 parents b21ca02 + 67c37d7 commit cb3901f

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

crates/kreuzberg/src/mcp/server.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ impl KreuzbergMcp {
229229
/// This tool extracts text, metadata, and tables from documents in various formats
230230
/// including PDFs, Word documents, Excel spreadsheets, images (with OCR), and more.
231231
#[tool(
232-
description = "Extract content from a file by path. Supports PDFs, Word, Excel, images (with OCR), HTML, and more."
232+
description = "Extract content from a file by path. Supports PDFs, Word, Excel, images (with OCR), HTML, and more.",
233+
annotations(title = "Extract File", read_only_hint = true, idempotent_hint = true)
233234
)]
234235
async fn extract_file(
235236
&self,
@@ -253,7 +254,8 @@ impl KreuzbergMcp {
253254
///
254255
/// This tool extracts text, metadata, and tables from base64-encoded document data.
255256
#[tool(
256-
description = "Extract content from base64-encoded file data. Returns extracted text, metadata, and tables."
257+
description = "Extract content from base64-encoded file data. Returns extracted text, metadata, and tables.",
258+
annotations(title = "Extract Bytes", read_only_hint = true, idempotent_hint = true)
257259
)]
258260
async fn extract_bytes(
259261
&self,
@@ -282,7 +284,10 @@ impl KreuzbergMcp {
282284
/// Extract content from multiple files in parallel.
283285
///
284286
/// This tool efficiently processes multiple documents simultaneously, useful for batch operations.
285-
#[tool(description = "Extract content from multiple files in parallel. Returns results for all files.")]
287+
#[tool(
288+
description = "Extract content from multiple files in parallel. Returns results for all files.",
289+
annotations(title = "Batch Extract Files", read_only_hint = true, idempotent_hint = true)
290+
)]
286291
async fn batch_extract_files(
287292
&self,
288293
Parameters(params): Parameters<BatchExtractFilesParams>,
@@ -310,7 +315,10 @@ impl KreuzbergMcp {
310315
/// Detect the MIME type of a file.
311316
///
312317
/// This tool identifies the file format, useful for determining which extractor to use.
313-
#[tool(description = "Detect the MIME type of a file. Returns the detected MIME type string.")]
318+
#[tool(
319+
description = "Detect the MIME type of a file. Returns the detected MIME type string.",
320+
annotations(title = "Detect MIME Type", read_only_hint = true, idempotent_hint = true)
321+
)]
314322
fn detect_mime_type(
315323
&self,
316324
Parameters(params): Parameters<DetectMimeTypeParams>,
@@ -323,7 +331,10 @@ impl KreuzbergMcp {
323331
/// Get cache statistics.
324332
///
325333
/// This tool returns statistics about the cache including total files, size, and disk space.
326-
#[tool(description = "Get cache statistics including total files, size, and available disk space.")]
334+
#[tool(
335+
description = "Get cache statistics including total files, size, and available disk space.",
336+
annotations(title = "Cache Stats", read_only_hint = true, idempotent_hint = true)
337+
)]
327338
fn cache_stats(&self, Parameters(_): Parameters<()>) -> Result<CallToolResult, McpError> {
328339
let cache_dir = std::env::current_dir()
329340
.unwrap_or_else(|_| std::path::PathBuf::from("."))
@@ -354,7 +365,10 @@ impl KreuzbergMcp {
354365
/// Clear the cache.
355366
///
356367
/// This tool removes all cached files and returns the number of files removed and space freed.
357-
#[tool(description = "Clear all cached files. Returns the number of files removed and space freed in MB.")]
368+
#[tool(
369+
description = "Clear all cached files. Returns the number of files removed and space freed in MB.",
370+
annotations(title = "Clear Cache", destructive_hint = true)
371+
)]
358372
fn cache_clear(&self, Parameters(_): Parameters<()>) -> Result<CallToolResult, McpError> {
359373
let cache_dir = std::env::current_dir()
360374
.unwrap_or_else(|_| std::path::PathBuf::from("."))

0 commit comments

Comments
 (0)