@@ -15,6 +15,7 @@ export class CreateAccessListTool extends AtlasToolBase {
15
15
. describe ( "IP addresses to allow access from" )
16
16
. optional ( ) ,
17
17
cidrBlocks : z . array ( z . string ( ) . cidr ( ) ) . describe ( "CIDR blocks to allow access from" ) . optional ( ) ,
18
+ currentIpAddress : z . boolean ( ) . describe ( "Add the current IP address" ) . default ( false ) ,
18
19
comment : z . string ( ) . describe ( "Comment for the access list entries" ) . default ( DEFAULT_COMMENT ) . optional ( ) ,
19
20
} ;
20
21
@@ -23,11 +24,12 @@ export class CreateAccessListTool extends AtlasToolBase {
23
24
ipAddresses,
24
25
cidrBlocks,
25
26
comment,
27
+ currentIpAddress,
26
28
} : ToolArgs < typeof this . argsShape > ) : Promise < CallToolResult > {
27
29
await this . ensureAuthenticated ( ) ;
28
30
29
- if ( ! ipAddresses ?. length && ! cidrBlocks ?. length ) {
30
- throw new Error ( "Either ipAddresses or cidrBlocks must be provided." ) ;
31
+ if ( ! ipAddresses ?. length && ! cidrBlocks ?. length && ! currentIpAddress ) {
32
+ throw new Error ( "One of ipAddresses, cidrBlocks, currentIpAddress must be provided." ) ;
31
33
}
32
34
33
35
const ipInputs = ( ipAddresses || [ ] ) . map ( ( ipAddress ) => ( {
@@ -36,6 +38,16 @@ export class CreateAccessListTool extends AtlasToolBase {
36
38
comment : comment || DEFAULT_COMMENT ,
37
39
} ) ) ;
38
40
41
+ if ( currentIpAddress ) {
42
+ const currentIp = await this . apiClient . getIpInfo ( ) ;
43
+ const input = {
44
+ groupId : projectId ,
45
+ ipAddress : currentIp . currentIpv4Address ,
46
+ comment : comment || DEFAULT_COMMENT ,
47
+ } ;
48
+ ipInputs . push ( input ) ;
49
+ }
50
+
39
51
const cidrInputs = ( cidrBlocks || [ ] ) . map ( ( cidrBlock ) => ( {
40
52
groupId : projectId ,
41
53
cidrBlock,
0 commit comments