MCPcopy Create free account
hub / github.com/PowerShell/DSC / list_dsc_functions

Method list_dsc_functions

dsc/src/mcp/list_dsc_functions.rs:37–61  ·  view source on GitHub ↗
(&self, Parameters(ListFunctionsRequest { function_filter }): Parameters<ListFunctionsRequest>)

Source from the content-addressed store, hash-verified

35 )
36 )]
37 pub async fn list_dsc_functions(&self, Parameters(ListFunctionsRequest { function_filter }): Parameters<ListFunctionsRequest>) -> Result<Json<FunctionListResult>, McpError> {
38 let result = task::spawn_blocking(move || {
39 let function_dispatcher = FunctionDispatcher::new();
40 let mut functions = function_dispatcher.list();
41
42 // apply filtering if function_filter is provided
43 if let Some(name_pattern) = function_filter {
44 let regex_str = convert_wildcard_to_regex(&name_pattern);
45 let mut regex_builder = RegexBuilder::new(&regex_str);
46 regex_builder.case_insensitive(true);
47
48 let regex = regex_builder.build()
49 .map_err(|_| McpError::invalid_params(
50 t!("mcp.list_dsc_functions.invalidNamePattern", pattern = name_pattern),
51 None
52 ))?;
53
54 functions.retain(|func| regex.is_match(&func.name));
55 }
56
57 Ok(FunctionListResult { functions })
58 }).await.map_err(|e| McpError::internal_error(e.to_string(), None))??;
59
60 Ok(Json(result))
61 }
62}

Callers

nothing calls this directly

Calls 5

JsonClass · 0.85
listMethod · 0.80
newFunction · 0.50
is_matchMethod · 0.45

Tested by

no test coverage detected