@@ -6,6 +6,7 @@ Describe 'Tests for MCP server' {
66 $processStartInfo = [System.Diagnostics.ProcessStartInfo ]::new()
77 $processStartInfo.FileName = " dsc"
88 $processStartInfo.Arguments = " --trace-format plaintext mcp"
9+ $processStartInfo.UseShellExecute = $false
910 $processStartInfo.RedirectStandardError = $true
1011 $processStartInfo.RedirectStandardOutput = $true
1112 $processStartInfo.RedirectStandardInput = $true
@@ -70,6 +71,7 @@ Describe 'Tests for MCP server' {
7071 }
7172
7273 $tools = @ {
74+ ' list_dsc_functions' = $false
7375 ' list_dsc_resources' = $false
7476 ' show_dsc_resource' = $false
7577 }
@@ -207,4 +209,93 @@ Describe 'Tests for MCP server' {
207209 $response.error.code | Should - Be -32602
208210 $response.error.message | Should -Not - BeNullOrEmpty
209211 }
212+
213+ It ' Calling list_dsc_functions works' {
214+ $mcpRequest = @ {
215+ jsonrpc = " 2.0"
216+ id = 8
217+ method = " tools/call"
218+ params = @ {
219+ name = " list_dsc_functions"
220+ arguments = @ {}
221+ }
222+ }
223+
224+ $response = Send-McpRequest - request $mcpRequest
225+ $response.id | Should - Be 8
226+ $functions = dsc function list -- output- format json | ConvertFrom-Json
227+ $response.result.structuredContent.functions.Count | Should - Be $functions.Count
228+
229+ $mcpFunctions = $response.result.structuredContent.functions | Sort-Object name
230+ $dscFunctions = $functions | Sort-Object name
231+
232+ for ($i = 0 ; $i -lt $dscFunctions.Count ; $i ++ ) {
233+ ($mcpFunctions [$i ].psobject.properties | Measure-Object ).Count | Should - BeGreaterOrEqual 8
234+ $mcpFunctions [$i ].name | Should - BeExactly $dscFunctions [$i ].name - Because ($response.result.structuredContent | ConvertTo-Json - Depth 10 | Out-String )
235+ $mcpFunctions [$i ].category | Should - BeExactly $dscFunctions [$i ].category - Because ($response.result.structuredContent | ConvertTo-Json - Depth 10 | Out-String )
236+ $mcpFunctions [$i ].description | Should - BeExactly $dscFunctions [$i ].description - Because ($response.result.structuredContent | ConvertTo-Json - Depth 10 | Out-String )
237+ }
238+ }
239+
240+ It ' Calling list_dsc_functions with function_filter filter works' {
241+ $mcpRequest = @ {
242+ jsonrpc = " 2.0"
243+ id = 9
244+ method = " tools/call"
245+ params = @ {
246+ name = " list_dsc_functions"
247+ arguments = @ {
248+ function_filter = " array"
249+ }
250+ }
251+ }
252+
253+ $response = Send-McpRequest - request $mcpRequest
254+ $response.id | Should - Be 9
255+ $response.result.structuredContent.functions.Count | Should - Be 1
256+ $response.result.structuredContent.functions [0 ].name | Should - BeExactly " array"
257+ $response.result.structuredContent.functions [0 ].category | Should - BeExactly " Array"
258+ }
259+
260+ It ' Calling list_dsc_functions with wildcard pattern works' {
261+ $mcpRequest = @ {
262+ jsonrpc = " 2.0"
263+ id = 10
264+ method = " tools/call"
265+ params = @ {
266+ name = " list_dsc_functions"
267+ arguments = @ {
268+ function_filter = " *Array*"
269+ }
270+ }
271+ }
272+
273+ $response = Send-McpRequest - request $mcpRequest
274+ $response.id | Should - Be 10
275+ $arrayFunctions = dsc function list -- output- format json | ConvertFrom-Json - Depth 20 | Where-Object { $_.name -like " *Array*" }
276+ $response.result.structuredContent.functions.Count | Should - Be $arrayFunctions.Count
277+ foreach ($func in $response.result.structuredContent.functions ) {
278+ $func.name | Should -Match " Array" - Because " Function name should contain 'Array'"
279+ }
280+ }
281+
282+ # dont check for error as dsc function list returns empty list for invalid patterns
283+ It ' Calling list_dsc_functions with invalid pattern returns empty result' {
284+ $mcpRequest = @ {
285+ jsonrpc = " 2.0"
286+ id = 11
287+ method = " tools/call"
288+ params = @ {
289+ name = " list_dsc_functions"
290+ arguments = @ {
291+ function_filter = " [invalid]"
292+ }
293+ }
294+ }
295+
296+ $response = Send-McpRequest - request $mcpRequest
297+ $response.id | Should - Be 11
298+ $response.result.structuredContent.functions.Count | Should - Be 0
299+ $response.result.structuredContent.functions | Should - BeNullOrEmpty
300+ }
210301}
0 commit comments