Skip to content

Commit 61770a5

Browse files
committed
If allowedApis is provided respect that always
1 parent 5487456 commit 61770a5

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

aws/aws-mcp-cli-commands/src/main/java/software/amazon/smithy/java/aws/mcp/cli/commands/AddAwsServiceBundle.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,28 @@ public class AddAwsServiceBundle extends AbstractAddBundle {
3535
protected Set<String> blockedApis;
3636

3737
@Option(names = "--read-only-apis",
38-
description = "Include read only APIs in the MCP server",
39-
defaultValue = "true")
40-
protected boolean readOnlyApis;
38+
description = "Include read only APIs in the MCP server")
39+
protected Boolean readOnlyApis;
4140

4241
@Override
4342
protected CliBundle getNewToolConfig() {
4443
var bundleBuilder = AwsServiceBundler.builder()
4544
.serviceName(awsServiceName);
46-
if (readOnlyApis) {
47-
// Include read-only apis unless disabled
48-
bundleBuilder.readOnlyOperations();
49-
}
5045
if (allowedApis != null) {
51-
// User explicitly specified allowed APIs - use only those
46+
// User explicitly specified allowed APIs
5247
bundleBuilder.exposedOperations(allowedApis);
48+
// If readOnlyApis is also requested, include those as well
49+
if (Boolean.TRUE.equals(readOnlyApis)) {
50+
bundleBuilder.readOnlyOperations();
51+
}
52+
} else if (Boolean.FALSE.equals(readOnlyApis)) {
53+
//If nothing is specified then default to only readOnlyOperations.
54+
bundleBuilder.readOnlyOperations();
55+
} else {
56+
throw new IllegalArgumentException("You have turned off readOnlyApis and also not specified any " +
57+
"allowedApis so there are no operations to create a bundle for.");
5358
}
59+
5460
if (blockedApis != null) {
5561
// Always apply blocked operations if specified
5662
bundleBuilder.blockedOperations(blockedApis);

0 commit comments

Comments
 (0)