Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/tool-reference.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- AUTO GENERATED DO NOT EDIT - run 'npm run docs' to update-->

# Chrome DevTools MCP Tool Reference
# Chrome DevTools MCP Tool Reference (~6661 cl100k_base tokens)

- **[Input automation](#input-automation)** (8 tools)
- [`click`](#click)
Expand Down
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-license": "^3.6.0",
"sinon": "^21.0.0",
"tiktoken": "^1.0.22",
"typescript": "^5.9.2",
"typescript-eslint": "^8.43.0",
"yargs": "18.0.0"
Expand Down
41 changes: 40 additions & 1 deletion scripts/generate-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

import fs from 'node:fs';

import {Client} from '@modelcontextprotocol/sdk/client/index.js';
import {StdioClientTransport} from '@modelcontextprotocol/sdk/client/stdio.js';
import type {Tool} from '@modelcontextprotocol/sdk/types.js';
import {get_encoding} from 'tiktoken';

import {cliOptions} from '../build/src/cli.js';
import {ToolCategory, labels} from '../build/src/tools/categories.js';
Expand All @@ -15,6 +18,42 @@ import {tools} from '../build/src/tools/tools.js';
const OUTPUT_PATH = './docs/tool-reference.md';
const README_PATH = './README.md';

async function measureServer() {
// 1. Connect to your actual MCP server
const transport = new StdioClientTransport({
command: 'node',
args: ['./build/src/index.js'], // Point to your built MCP server
});

const client = new Client(
{name: 'measurer', version: '1.0.0'},
{capabilities: {}},
);
await client.connect(transport);

// 2. Fetch all tools
const toolsList = await client.listTools();

// 3. Serialize exactly how an LLM would see it (JSON)
const jsonString = JSON.stringify(toolsList.tools, null, 2);

// 4. Count tokens (using cl100k_base which is standard for GPT-4/Claude-3.5 approximation)
const enc = get_encoding('cl100k_base');
const tokenCount = enc.encode(jsonString).length;

console.log(`--- Measurement Results ---`);
console.log(`Total Tools: ${toolsList.tools.length}`);
console.log(`JSON Character Count: ${jsonString.length}`);
console.log(`Estimated Token Count: ~${tokenCount}`);

// Clean up
enc.free();
await client.close();
return {
tokenCount,
};
}

// Extend the MCP Tool type to include our annotations
interface ToolWithAnnotations extends Tool {
annotations?: {
Expand Down Expand Up @@ -316,7 +355,7 @@ async function generateToolDocumentation(): Promise<void> {
// Generate markdown documentation
let markdown = `<!-- AUTO GENERATED DO NOT EDIT - run 'npm run docs' to update-->

# Chrome DevTools MCP Tool Reference
# Chrome DevTools MCP Tool Reference (~${(await measureServer()).tokenCount} cl100k_base tokens)

`;

Expand Down