66
77import fs from 'node:fs' ;
88
9- import { Client } from '@modelcontextprotocol/sdk/client/index.js' ;
10- import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js' ;
119import type { Tool } from '@modelcontextprotocol/sdk/types.js' ;
12- import { get_encoding } from 'tiktoken' ;
1310
1411import { cliOptions } from '../build/src/bin/chrome-devtools-mcp-cli-options.js' ;
1512import type { ParsedArguments } from '../build/src/bin/chrome-devtools-mcp-cli-options.js' ;
@@ -25,42 +22,6 @@ const OUTPUT_PATH = './docs/tool-reference.md';
2522const SLIM_OUTPUT_PATH = './docs/slim-tool-reference.md' ;
2623const README_PATH = './README.md' ;
2724
28- async function measureServer ( args : string [ ] ) {
29- // 1. Connect to your actual MCP server
30- const transport = new StdioClientTransport ( {
31- command : 'node' ,
32- args : [ './build/src/bin/chrome-devtools-mcp.js' , ...args ] , // Point to your built MCP server
33- } ) ;
34-
35- const client = new Client (
36- { name : 'measurer' , version : '1.0.0' } ,
37- { capabilities : { } } ,
38- ) ;
39- await client . connect ( transport ) ;
40-
41- // 2. Fetch all tools
42- const toolsList = await client . listTools ( ) ;
43-
44- // 3. Serialize exactly how an LLM would see it (JSON)
45- const jsonString = JSON . stringify ( toolsList . tools , null , 2 ) ;
46-
47- // 4. Count tokens (using cl100k_base which is standard for GPT-4/Claude-3.5 approximation)
48- const enc = get_encoding ( 'cl100k_base' ) ;
49- const tokenCount = enc . encode ( jsonString ) . length ;
50-
51- console . log ( `--- Measurement Results ---` ) ;
52- console . log ( `Total Tools: ${ toolsList . tools . length } ` ) ;
53- console . log ( `JSON Character Count: ${ jsonString . length } ` ) ;
54- console . log ( `Estimated Token Count: ~${ tokenCount } ` ) ;
55-
56- // Clean up
57- enc . free ( ) ;
58- await client . close ( ) ;
59- return {
60- tokenCount,
61- } ;
62- }
63-
6425// Extend the MCP Tool type to include our annotations
6526interface ToolWithAnnotations extends Tool {
6627 annotations ?: {
@@ -337,14 +298,13 @@ async function generateReference(
337298 toolsWithAnnotations : ToolWithAnnotations [ ] ,
338299 categories : Record < string , ToolWithAnnotations [ ] > ,
339300 sortedCategories : string [ ] ,
340- serverArgs : string [ ] ,
341301) {
342302 console . log ( `Found ${ toolsWithAnnotations . length } tools` ) ;
343303
344304 // Generate markdown documentation
345305 let markdown = `<!-- AUTO GENERATED DO NOT EDIT - run 'npm run gen' to update-->
346306
347- # ${ title } (~ ${ ( await measureServer ( serverArgs ) ) . tokenCount } cl100k_base tokens)
307+ # ${ title }
348308
349309` ;
350310 // Generate table of contents
@@ -567,7 +527,6 @@ async function generateToolDocumentation(): Promise<void> {
567527 toolsWithAnnotations ,
568528 categories ,
569529 sortedCategories ,
570- [ ] ,
571530 ) ;
572531
573532 // Generate tools TOC and update README
@@ -584,7 +543,6 @@ async function generateToolDocumentation(): Promise<void> {
584543 toolsWithAnnotations ,
585544 categories ,
586545 sortedCategories ,
587- [ '--slim' ] ,
588546 ) ;
589547 }
590548
0 commit comments