@@ -15,6 +15,7 @@ export class CreateAccessListTool extends AtlasToolBase {
1515 . describe ( "IP addresses to allow access from" )
1616 . optional ( ) ,
1717 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 ) ,
1819 comment : z . string ( ) . describe ( "Comment for the access list entries" ) . default ( DEFAULT_COMMENT ) . optional ( ) ,
1920 } ;
2021
@@ -23,11 +24,12 @@ export class CreateAccessListTool extends AtlasToolBase {
2324 ipAddresses,
2425 cidrBlocks,
2526 comment,
27+ currentIpAddress,
2628 } : ToolArgs < typeof this . argsShape > ) : Promise < CallToolResult > {
2729 await this . ensureAuthenticated ( ) ;
2830
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." ) ;
3133 }
3234
3335 const ipInputs = ( ipAddresses || [ ] ) . map ( ( ipAddress ) => ( {
@@ -36,6 +38,16 @@ export class CreateAccessListTool extends AtlasToolBase {
3638 comment : comment || DEFAULT_COMMENT ,
3739 } ) ) ;
3840
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+
3951 const cidrInputs = ( cidrBlocks || [ ] ) . map ( ( cidrBlock ) => ( {
4052 groupId : projectId ,
4153 cidrBlock,
0 commit comments