@@ -2,8 +2,7 @@ import { z } from "zod";
22import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" ;
33import { AtlasToolBase } from "../atlasTool.js" ;
44import { ToolArgs , OperationType } from "../../tool.js" ;
5-
6- const DEFAULT_COMMENT = "Added by Atlas MCP" ;
5+ import { makeCurrentIpAccessListEntry , DEFAULT_ACCESS_LIST_COMMENT } from "../../../common/atlas/accessListUtils.js" ;
76
87export class CreateAccessListTool extends AtlasToolBase {
98 public name = "atlas-create-access-list" ;
@@ -17,7 +16,11 @@ export class CreateAccessListTool extends AtlasToolBase {
1716 . optional ( ) ,
1817 cidrBlocks : z . array ( z . string ( ) . cidr ( ) ) . describe ( "CIDR blocks to allow access from" ) . optional ( ) ,
1918 currentIpAddress : z . boolean ( ) . describe ( "Add the current IP address" ) . default ( false ) ,
20- comment : z . string ( ) . describe ( "Comment for the access list entries" ) . default ( DEFAULT_COMMENT ) . optional ( ) ,
19+ comment : z
20+ . string ( )
21+ . describe ( "Comment for the access list entries" )
22+ . default ( DEFAULT_ACCESS_LIST_COMMENT )
23+ . optional ( ) ,
2124 } ;
2225
2326 protected async execute ( {
@@ -34,23 +37,22 @@ export class CreateAccessListTool extends AtlasToolBase {
3437 const ipInputs = ( ipAddresses || [ ] ) . map ( ( ipAddress ) => ( {
3538 groupId : projectId ,
3639 ipAddress,
37- comment : comment || DEFAULT_COMMENT ,
40+ comment : comment || DEFAULT_ACCESS_LIST_COMMENT ,
3841 } ) ) ;
3942
4043 if ( currentIpAddress ) {
41- const currentIp = await this . session . apiClient . getIpInfo ( ) ;
42- const input = {
43- groupId : projectId ,
44- ipAddress : currentIp . currentIpv4Address ,
45- comment : comment || DEFAULT_COMMENT ,
46- } ;
44+ const input = await makeCurrentIpAccessListEntry (
45+ this . session . apiClient ,
46+ projectId ,
47+ comment || DEFAULT_ACCESS_LIST_COMMENT
48+ ) ;
4749 ipInputs . push ( input ) ;
4850 }
4951
5052 const cidrInputs = ( cidrBlocks || [ ] ) . map ( ( cidrBlock ) => ( {
5153 groupId : projectId ,
5254 cidrBlock,
53- comment : comment || DEFAULT_COMMENT ,
55+ comment : comment || DEFAULT_ACCESS_LIST_COMMENT ,
5456 } ) ) ;
5557
5658 const inputs = [ ...ipInputs , ...cidrInputs ] ;
0 commit comments