Skip to content

Commit 2ee4a02

Browse files
ernestkoeclaude
andcommitted
Add tool annotations (partial, PR MarkusPfundstein#101)
Added ToolAnnotations with readOnlyHint/destructiveHint to key tools: - ListFilesInVault, ListFilesInDir, GetFileContents (readOnly) - AppendContent, DeleteFile (destructive) Establishes the pattern; remaining tools can be annotated incrementally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent a734147 commit 2ee4a02

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/mcp_obsidian/tools.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from collections.abc import Sequence
22
from mcp.types import (
33
Tool,
4+
ToolAnnotations,
45
TextContent,
56
ImageContent,
67
EmbeddedResource,
@@ -41,6 +42,10 @@ def get_tool_description(self):
4142
"properties": {},
4243
"required": []
4344
},
45+
annotations=ToolAnnotations(
46+
title="List Files in Vault",
47+
readOnlyHint=True,
48+
),
4449
)
4550

4651
def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
@@ -72,7 +77,11 @@ def get_tool_description(self):
7277
},
7378
},
7479
"required": ["dirpath"]
75-
}
80+
},
81+
annotations=ToolAnnotations(
82+
title="List Files in Directory",
83+
readOnlyHint=True,
84+
),
7685
)
7786

7887
def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
@@ -109,7 +118,11 @@ def get_tool_description(self):
109118
},
110119
},
111120
"required": ["filepath"]
112-
}
121+
},
122+
annotations=ToolAnnotations(
123+
title="Get File Contents",
124+
readOnlyHint=True,
125+
),
113126
)
114127

115128
def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
@@ -211,7 +224,11 @@ def get_tool_description(self):
211224
}
212225
},
213226
"required": ["filepath", "content"]
214-
}
227+
},
228+
annotations=ToolAnnotations(
229+
title="Append Content",
230+
destructiveHint=True,
231+
),
215232
)
216233

217234
def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
@@ -350,13 +367,17 @@ def get_tool_description(self):
350367
}
351368
},
352369
"required": ["filepath", "confirm"]
353-
}
370+
},
371+
annotations=ToolAnnotations(
372+
title="Delete File",
373+
destructiveHint=True,
374+
),
354375
)
355376

356377
def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
357378
if "filepath" not in args:
358379
raise RuntimeError("filepath argument missing in arguments")
359-
380+
360381
if not args.get("confirm", False):
361382
raise RuntimeError("confirm must be set to true to delete a file")
362383

0 commit comments

Comments
 (0)