Skip to content

Commit c8b894e

Browse files
committed
Add missing delete for MCP server invoke
1 parent e5868f3 commit c8b894e

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

dsc/src/mcp/invoke_dsc_resource.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use dsc_lib::{
77
dscresources::{
88
dscresource::Invoke,
99
invoke_result::{
10+
DeleteResult,
1011
ExportResult,
1112
GetResult,
1213
SetResult,
@@ -28,6 +29,7 @@ pub enum DscOperation {
2829
Set,
2930
Test,
3031
Export,
32+
Delete,
3133
}
3234

3335
#[derive(Serialize, JsonSchema)]
@@ -37,6 +39,7 @@ pub enum ResourceOperationResult {
3739
SetResult(SetResult),
3840
TestResult(TestResult),
3941
ExportResult(ExportResult),
42+
DeleteResult(DeleteResult),
4043
}
4144

4245
#[derive(Serialize, JsonSchema)]
@@ -57,9 +60,9 @@ pub struct InvokeDscResourceRequest {
5760
#[tool_router(router = invoke_dsc_resource_router, vis = "pub")]
5861
impl McpServer {
5962
#[tool(
60-
description = "Invoke a DSC resource operation (Get, Set, Test, Export) with specified properties in JSON format",
63+
description = "Invoke a DSC resource operation (Get, Set, Test, Export, Delete) with specified properties in JSON format",
6164
annotations(
62-
title = "Invoke a DSC resource operation (Get, Set, Test, Export) with specified properties in JSON format",
65+
title = "Invoke a DSC resource operation (Get, Set, Test, Export, Delete) with specified properties in JSON format",
6366
read_only_hint = false,
6467
destructive_hint = true,
6568
idempotent_hint = true,
@@ -94,6 +97,13 @@ impl McpServer {
9497
};
9598
Ok(ResourceOperationResult::TestResult(result))
9699
},
100+
DscOperation::Delete => {
101+
let result = match resource.delete(&properties_json, &ExecutionKind::Actual) {
102+
Ok(res) => res,
103+
Err(e) => return Err(McpError::internal_error(e.to_string(), None)),
104+
};
105+
Ok(ResourceOperationResult::DeleteResult(result))
106+
},
97107
DscOperation::Export => {
98108
let result = match resource.export(&properties_json) {
99109
Ok(res) => res,

dsc/tests/dsc_mcp.tests.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ Describe 'Tests for MCP server' {
304304
@{ operation = 'get'; property = 'actualState' }
305305
@{ operation = 'set'; property = 'beforeState' }
306306
@{ operation = 'test'; property = 'desiredState' }
307+
@{ operation = 'delete'; property = 'beforeState' }
307308
@{ operation = 'export'; property = 'actualState' }
308309
) {
309310
param($operation)

tools/dsctest/dscoperation.dsc.resource.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@
3535
}
3636
]
3737
},
38+
"delete": {
39+
"executable": "dsctest",
40+
"args": [
41+
"operation",
42+
"--operation",
43+
"delete",
44+
{
45+
"jsonInputArg": "--input"
46+
}
47+
]
48+
},
3849
"export": {
3950
"executable": "dsctest",
4051
"args": [

0 commit comments

Comments
 (0)