@@ -12,6 +12,7 @@ import {
1212 READ_ONLY_TOOLS ,
1313} from "../../src/tool-filter.js" ;
1414import { createAllTools } from "../../src/tools/index.js" ;
15+ import { createTestConfig } from "../utils/test-config.js" ;
1516
1617// Mock Iterable client for testing
1718const mockClient = { } as any ;
@@ -23,11 +24,11 @@ describe("Tool Filter", () => {
2324 describe ( "Safe tool lists validation" , ( ) => {
2425 it ( "should have all NON_PII_TOOLS in actual tool names" , ( ) => {
2526 // Get the safe non-PII tools by testing with restrictive config
26- const restrictiveConfig : McpServerConfig = {
27+ const restrictiveConfig : McpServerConfig = createTestConfig ( {
2728 allowUserPii : false ,
2829 allowWrites : true , // Allow writes to isolate PII filtering
2930 allowSends : true ,
30- } ;
31+ } ) ;
3132
3233 const nonPiiTools = filterTools ( allTools , restrictiveConfig ) ;
3334 const nonPiiToolNames = nonPiiTools . map ( ( tool ) => tool . name ) ;
@@ -40,11 +41,11 @@ describe("Tool Filter", () => {
4041
4142 it ( "should have all READ_ONLY_TOOLS in actual tool names" , ( ) => {
4243 // Get the read-only tools by testing with restrictive config
43- const restrictiveConfig : McpServerConfig = {
44+ const restrictiveConfig : McpServerConfig = createTestConfig ( {
4445 allowUserPii : true , // Allow PII to isolate write filtering
4546 allowWrites : false ,
4647 allowSends : true ,
47- } ;
48+ } ) ;
4849
4950 const readOnlyTools = filterTools ( allTools , restrictiveConfig ) ;
5051 const readOnlyToolNames = readOnlyTools . map ( ( tool ) => tool . name ) ;
@@ -70,23 +71,23 @@ describe("Tool Filter", () => {
7071 } ) ;
7172
7273 it ( "should filter tools when restrictions are applied" , ( ) => {
73- const permissiveConfig : McpServerConfig = {
74+ const permissiveConfig : McpServerConfig = createTestConfig ( {
7475 allowUserPii : true ,
7576 allowWrites : true ,
7677 allowSends : true ,
77- } ;
78+ } ) ;
7879
79- const restrictivePiiConfig : McpServerConfig = {
80+ const restrictivePiiConfig : McpServerConfig = createTestConfig ( {
8081 allowUserPii : false ,
8182 allowWrites : true ,
8283 allowSends : true ,
83- } ;
84+ } ) ;
8485
85- const restrictiveWriteConfig : McpServerConfig = {
86+ const restrictiveWriteConfig : McpServerConfig = createTestConfig ( {
8687 allowUserPii : true ,
8788 allowWrites : false ,
8889 allowSends : true ,
89- } ;
90+ } ) ;
9091
9192 const allToolsCount = filterTools ( allTools , permissiveConfig ) . length ;
9293 const nonPiiToolsCount = filterTools (
@@ -107,11 +108,11 @@ describe("Tool Filter", () => {
107108
108109 describe ( "Configuration filtering" , ( ) => {
109110 it ( "should filter PII tools when allowUserPii is false" , ( ) => {
110- const config : McpServerConfig = {
111+ const config : McpServerConfig = createTestConfig ( {
111112 allowUserPii : false ,
112113 allowWrites : true ,
113114 allowSends : true ,
114- } ;
115+ } ) ;
115116
116117 const filteredTools = filterTools ( allTools , config ) ;
117118 const filteredNames = filteredTools . map ( ( tool ) => tool . name ) ;
@@ -134,11 +135,11 @@ describe("Tool Filter", () => {
134135 } ) ;
135136
136137 it ( "should filter write tools when allowWrites is false" , ( ) => {
137- const config : McpServerConfig = {
138+ const config : McpServerConfig = createTestConfig ( {
138139 allowUserPii : true ,
139140 allowWrites : false ,
140141 allowSends : true ,
141- } ;
142+ } ) ;
142143
143144 const filteredTools = filterTools ( allTools , config ) ;
144145 const filteredNames = filteredTools . map ( ( tool ) => tool . name ) ;
@@ -163,22 +164,22 @@ describe("Tool Filter", () => {
163164 } ) ;
164165
165166 it ( "should allow all tools when both restrictions are disabled" , ( ) => {
166- const config : McpServerConfig = {
167+ const config : McpServerConfig = createTestConfig ( {
167168 allowUserPii : true ,
168169 allowWrites : true ,
169170 allowSends : true ,
170- } ;
171+ } ) ;
171172
172173 const filteredTools = filterTools ( allTools , config ) ;
173174 expect ( filteredTools ) . toHaveLength ( allTools . length ) ;
174175 } ) ;
175176
176177 it ( "should apply both restrictions when both are enabled" , ( ) => {
177- const config : McpServerConfig = {
178+ const config : McpServerConfig = createTestConfig ( {
178179 allowUserPii : false ,
179180 allowWrites : false ,
180181 allowSends : false ,
181- } ;
182+ } ) ;
182183
183184 const filteredTools = filterTools ( allTools , config ) ;
184185
0 commit comments