@@ -216,27 +216,24 @@ fn to_json_result<T: serde::Serialize>(value: &T) -> Result<CallToolResult, McpE
216216
217217/// Record a recently-written file path + mtime so the watcher can skip re-indexing it.
218218async fn record_write ( recent_writes : & RecentWrites , path : & Path ) {
219- if let Ok ( meta) = std:: fs:: metadata ( path) {
220- if let Ok ( mtime) = meta. modified ( ) {
221- recent_writes . lock ( ) . await . insert ( path . to_path_buf ( ) , mtime ) ;
222- }
219+ if let Ok ( meta) = std:: fs:: metadata ( path)
220+ && let Ok ( mtime) = meta. modified ( )
221+ {
222+ recent_writes . lock ( ) . await . insert ( path . to_path_buf ( ) , mtime ) ;
223223 }
224224}
225225
226226/// Parse a JSON operations array into `Vec<FrontmatterOp>`.
227227fn parse_frontmatter_ops ( operations : & [ serde_json:: Value ] ) -> Result < Vec < FrontmatterOp > , McpError > {
228228 let mut ops = Vec :: with_capacity ( operations. len ( ) ) ;
229229 for op_val in operations {
230- let op_str = op_val
231- . get ( "op" )
232- . and_then ( |v| v. as_str ( ) )
233- . ok_or_else ( || {
234- McpError :: new (
235- rmcp:: model:: ErrorCode :: INVALID_PARAMS ,
236- "each operation must have an \" op\" string field" ,
237- None :: < serde_json:: Value > ,
238- )
239- } ) ?;
230+ let op_str = op_val. get ( "op" ) . and_then ( |v| v. as_str ( ) ) . ok_or_else ( || {
231+ McpError :: new (
232+ rmcp:: model:: ErrorCode :: INVALID_PARAMS ,
233+ "each operation must have an \" op\" string field" ,
234+ None :: < serde_json:: Value > ,
235+ )
236+ } ) ?;
240237 match op_str {
241238 "set" => {
242239 let key = op_val. get ( "key" ) . and_then ( |v| v. as_str ( ) ) . ok_or_else ( || {
@@ -246,13 +243,16 @@ fn parse_frontmatter_ops(operations: &[serde_json::Value]) -> Result<Vec<Frontma
246243 None :: < serde_json:: Value > ,
247244 )
248245 } ) ?;
249- let value = op_val. get ( "value" ) . and_then ( |v| v. as_str ( ) ) . ok_or_else ( || {
250- McpError :: new (
251- rmcp:: model:: ErrorCode :: INVALID_PARAMS ,
252- "\" set\" operation requires a \" value\" field" ,
253- None :: < serde_json:: Value > ,
254- )
255- } ) ?;
246+ let value = op_val
247+ . get ( "value" )
248+ . and_then ( |v| v. as_str ( ) )
249+ . ok_or_else ( || {
250+ McpError :: new (
251+ rmcp:: model:: ErrorCode :: INVALID_PARAMS ,
252+ "\" set\" operation requires a \" value\" field" ,
253+ None :: < serde_json:: Value > ,
254+ )
255+ } ) ?;
256256 ops. push ( FrontmatterOp :: Set ( key. to_string ( ) , value. to_string ( ) ) ) ;
257257 }
258258 "remove" => {
@@ -266,43 +266,55 @@ fn parse_frontmatter_ops(operations: &[serde_json::Value]) -> Result<Vec<Frontma
266266 ops. push ( FrontmatterOp :: Remove ( key. to_string ( ) ) ) ;
267267 }
268268 "add_tag" => {
269- let value = op_val. get ( "value" ) . and_then ( |v| v. as_str ( ) ) . ok_or_else ( || {
270- McpError :: new (
271- rmcp:: model:: ErrorCode :: INVALID_PARAMS ,
272- "\" add_tag\" operation requires a \" value\" field" ,
273- None :: < serde_json:: Value > ,
274- )
275- } ) ?;
269+ let value = op_val
270+ . get ( "value" )
271+ . and_then ( |v| v. as_str ( ) )
272+ . ok_or_else ( || {
273+ McpError :: new (
274+ rmcp:: model:: ErrorCode :: INVALID_PARAMS ,
275+ "\" add_tag\" operation requires a \" value\" field" ,
276+ None :: < serde_json:: Value > ,
277+ )
278+ } ) ?;
276279 ops. push ( FrontmatterOp :: AddTag ( value. to_string ( ) ) ) ;
277280 }
278281 "remove_tag" => {
279- let value = op_val. get ( "value" ) . and_then ( |v| v. as_str ( ) ) . ok_or_else ( || {
280- McpError :: new (
281- rmcp:: model:: ErrorCode :: INVALID_PARAMS ,
282- "\" remove_tag\" operation requires a \" value\" field" ,
283- None :: < serde_json:: Value > ,
284- )
285- } ) ?;
282+ let value = op_val
283+ . get ( "value" )
284+ . and_then ( |v| v. as_str ( ) )
285+ . ok_or_else ( || {
286+ McpError :: new (
287+ rmcp:: model:: ErrorCode :: INVALID_PARAMS ,
288+ "\" remove_tag\" operation requires a \" value\" field" ,
289+ None :: < serde_json:: Value > ,
290+ )
291+ } ) ?;
286292 ops. push ( FrontmatterOp :: RemoveTag ( value. to_string ( ) ) ) ;
287293 }
288294 "add_alias" => {
289- let value = op_val. get ( "value" ) . and_then ( |v| v. as_str ( ) ) . ok_or_else ( || {
290- McpError :: new (
291- rmcp:: model:: ErrorCode :: INVALID_PARAMS ,
292- "\" add_alias\" operation requires a \" value\" field" ,
293- None :: < serde_json:: Value > ,
294- )
295- } ) ?;
295+ let value = op_val
296+ . get ( "value" )
297+ . and_then ( |v| v. as_str ( ) )
298+ . ok_or_else ( || {
299+ McpError :: new (
300+ rmcp:: model:: ErrorCode :: INVALID_PARAMS ,
301+ "\" add_alias\" operation requires a \" value\" field" ,
302+ None :: < serde_json:: Value > ,
303+ )
304+ } ) ?;
296305 ops. push ( FrontmatterOp :: AddAlias ( value. to_string ( ) ) ) ;
297306 }
298307 "remove_alias" => {
299- let value = op_val. get ( "value" ) . and_then ( |v| v. as_str ( ) ) . ok_or_else ( || {
300- McpError :: new (
301- rmcp:: model:: ErrorCode :: INVALID_PARAMS ,
302- "\" remove_alias\" operation requires a \" value\" field" ,
303- None :: < serde_json:: Value > ,
304- )
305- } ) ?;
308+ let value = op_val
309+ . get ( "value" )
310+ . and_then ( |v| v. as_str ( ) )
311+ . ok_or_else ( || {
312+ McpError :: new (
313+ rmcp:: model:: ErrorCode :: INVALID_PARAMS ,
314+ "\" remove_alias\" operation requires a \" value\" field" ,
315+ None :: < serde_json:: Value > ,
316+ )
317+ } ) ?;
306318 ops. push ( FrontmatterOp :: RemoveAlias ( value. to_string ( ) ) ) ;
307319 }
308320 unknown => {
@@ -594,10 +606,7 @@ impl EngraphServer {
594606 name = "health" ,
595607 description = "Vault health report: orphans, broken links, stale notes, tag hygiene, index freshness."
596608 ) ]
597- async fn health (
598- & self ,
599- _params : Parameters < HealthParams > ,
600- ) -> Result < CallToolResult , McpError > {
609+ async fn health ( & self , _params : Parameters < HealthParams > ) -> Result < CallToolResult , McpError > {
601610 let store = self . store . lock ( ) . await ;
602611 let profile_ref = self . profile . as_ref ( ) . as_ref ( ) ;
603612 let config = crate :: health:: HealthConfig {
@@ -692,8 +701,14 @@ impl EngraphServer {
692701 . as_ref ( )
693702 . and_then ( |p| p. structure . folders . archive . as_deref ( ) )
694703 . unwrap_or ( "04-Archive" ) ;
695- crate :: writer:: delete_note ( & store, & self . vault_path , & params. 0 . file , mode, archive_folder)
696- . map_err ( |e| mcp_err ( & e) ) ?;
704+ crate :: writer:: delete_note (
705+ & store,
706+ & self . vault_path ,
707+ & params. 0 . file ,
708+ mode,
709+ archive_folder,
710+ )
711+ . map_err ( |e| mcp_err ( & e) ) ?;
697712 let result = serde_json:: json!( {
698713 "deleted" : params. 0 . file,
699714 "mode" : params. 0 . mode. as_deref( ) . unwrap_or( "soft" ) ,
0 commit comments