@@ -12,7 +12,11 @@ import {Client} from '@modelcontextprotocol/sdk/client/index.js';
1212import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js' ;
1313import { executablePath } from 'puppeteer' ;
1414
15- import type { ToolDefinition } from '../src/tools/ToolDefinition' ;
15+ import type { ToolDefinition } from '../src/tools/ToolDefinition.js' ;
16+ import {
17+ OFF_BY_DEFAULT_CATEGORIES ,
18+ ToolCategory ,
19+ } from '../src/tools/categories.js' ;
1620
1721describe ( 'e2e' , ( ) => {
1822 async function withClient (
@@ -71,6 +75,56 @@ describe('e2e', () => {
7175 } ) ;
7276 } ) ;
7377
78+ it ( 'has all tools with off by default categories' , async ( ) => {
79+ await withClient (
80+ async client => {
81+ const { tools} = await client . listTools ( ) ;
82+ const exposedNames = tools . map ( t => t . name ) . sort ( ) ;
83+ const files = fs . readdirSync ( 'build/src/tools' ) ;
84+ const definedNames = [ ] ;
85+ for ( const file of files ) {
86+ if (
87+ file === 'ToolDefinition.js' ||
88+ file === 'tools.js' ||
89+ file === 'slim'
90+ ) {
91+ continue ;
92+ }
93+ const fileTools = await import ( `../src/tools/${ file } ` ) ;
94+ for ( const maybeTool of Object . values < unknown > ( fileTools ) ) {
95+ if ( typeof maybeTool === 'function' ) {
96+ const tool = ( maybeTool as ( val : boolean ) => ToolDefinition ) (
97+ false ,
98+ ) ;
99+ if ( tool && typeof tool === 'object' && 'name' in tool ) {
100+ if ( tool . annotations ?. conditions ) {
101+ continue ;
102+ }
103+ definedNames . push ( tool . name ) ;
104+ }
105+ continue ;
106+ }
107+ if (
108+ typeof maybeTool === 'object' &&
109+ maybeTool !== null &&
110+ 'name' in maybeTool
111+ ) {
112+ const tool = maybeTool as ToolDefinition ;
113+ if ( tool . annotations ?. conditions ) {
114+ continue ;
115+ }
116+ definedNames . push ( tool . name ) ;
117+ }
118+ }
119+ }
120+
121+ definedNames . sort ( ) ;
122+ assert . deepStrictEqual ( exposedNames , definedNames ) ;
123+ } ,
124+ OFF_BY_DEFAULT_CATEGORIES . map ( category => `--category-${ category } ` ) ,
125+ ) ;
126+ } ) ;
127+
74128 it ( 'has all tools' , async ( ) => {
75129 await withClient ( async client => {
76130 const { tools} = await client . listTools ( ) ;
@@ -93,6 +147,12 @@ describe('e2e', () => {
93147 if ( tool . annotations ?. conditions ) {
94148 continue ;
95149 }
150+ if (
151+ tool . annotations ?. category &&
152+ tool . annotations ?. category === ToolCategory . EXTENSIONS
153+ ) {
154+ continue ;
155+ }
96156 definedNames . push ( tool . name ) ;
97157 }
98158 continue ;
@@ -106,10 +166,17 @@ describe('e2e', () => {
106166 if ( tool . annotations ?. conditions ) {
107167 continue ;
108168 }
169+ if (
170+ tool . annotations ?. category &&
171+ tool . annotations ?. category === ToolCategory . EXTENSIONS
172+ ) {
173+ continue ;
174+ }
109175 definedNames . push ( tool . name ) ;
110176 }
111177 }
112178 }
179+
113180 definedNames . sort ( ) ;
114181 assert . deepStrictEqual ( exposedNames , definedNames ) ;
115182 } ) ;
0 commit comments