@@ -2,8 +2,7 @@ import { z } from "zod";
2
2
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" ;
3
3
import { AtlasToolBase } from "../atlasTool.js" ;
4
4
import { 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" ;
7
6
8
7
export class CreateAccessListTool extends AtlasToolBase {
9
8
public name = "atlas-create-access-list" ;
@@ -17,7 +16,11 @@ export class CreateAccessListTool extends AtlasToolBase {
17
16
. optional ( ) ,
18
17
cidrBlocks : z . array ( z . string ( ) . cidr ( ) ) . describe ( "CIDR blocks to allow access from" ) . optional ( ) ,
19
18
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 ( ) ,
21
24
} ;
22
25
23
26
protected async execute ( {
@@ -34,23 +37,22 @@ export class CreateAccessListTool extends AtlasToolBase {
34
37
const ipInputs = ( ipAddresses || [ ] ) . map ( ( ipAddress ) => ( {
35
38
groupId : projectId ,
36
39
ipAddress,
37
- comment : comment || DEFAULT_COMMENT ,
40
+ comment : comment || DEFAULT_ACCESS_LIST_COMMENT ,
38
41
} ) ) ;
39
42
40
43
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
+ ) ;
47
49
ipInputs . push ( input ) ;
48
50
}
49
51
50
52
const cidrInputs = ( cidrBlocks || [ ] ) . map ( ( cidrBlock ) => ( {
51
53
groupId : projectId ,
52
54
cidrBlock,
53
- comment : comment || DEFAULT_COMMENT ,
55
+ comment : comment || DEFAULT_ACCESS_LIST_COMMENT ,
54
56
} ) ) ;
55
57
56
58
const inputs = [ ...ipInputs , ...cidrInputs ] ;
0 commit comments