Token-Optimized MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Token-Optimized MCP ServerFetch and distill the content at https://example.com"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Token-Optimized MCP Server
A high-performance Model Context Protocol (MCP) server built with Node.js and TypeScript. This server is purpose-built to minimize LLM token consumption through YAML serialization, structural HTML-to-Markdown distillation, and pre-flight token counting via the BPE tokenizer.
Table of Contents
Overview
Modern AI agents connected via MCP suffer from context window exhaustion when tool responses contain verbose JSON payloads or raw HTML. This server addresses the problem at the architecture layer:
Optimization Strategy | Token Reduction |
YAML serialization over JSON | ~40–48% |
HTML → structured Markdown | ~60–80% |
Pre-flight token gating | Prevents overflow |
All diagnostic logging is routed to stderr to preserve the JSON-RPC protocol integrity on stdout.
Available Tools
extract_web_content
Fetches a web page, strips HTML noise, and returns clean, semantically structured Markdown optimized for LLM consumption.
Parameter | Type | Required | Description |
|
| Yes | A valid URL to fetch and convert. |
Example input:
{
"url": "https://example.com"
}Returns: Token-efficient Markdown with preserved heading hierarchy, links, and tables. Token count is logged to stderr.
query_metrics_database
Queries an internal metrics database and returns the results serialized in YAML format to reduce token overhead by approximately 45% compared to equivalent JSON.
Parameter | Type | Required | Description |
|
| Yes | A natural-language or structured query string. |
Example input:
{
"query": "Show CPU and memory usage for the last hour"
}Returns: YAML-formatted metrics payload. If the response exceeds 8,000 tokens, a warning is emitted to stderr recommending semantic chunking.
Prerequisites
Node.js v18.0.0 or higher
npm v9+ (bundled with Node.js 18+)
Verify your installation:
node --version # Must be >= 18.0.0
npm --versionInstallation
# Clone or navigate to the project directory
cd optimized-mcp-server
# Install all dependencies
npm installDependencies at a Glance
Package | Purpose |
| Official MCP server SDK |
| Runtime input schema validation |
| BPE token counting (OpenAI compatible) |
| High-fidelity HTML → Markdown conversion |
| Native Rust-binding Markdown converter |
| JSON → YAML serialization |
Building
Compile the TypeScript source to JavaScript:
npm run buildThe compiled output is written to the build/ directory.
Configuration
To connect this server to an MCP-compatible AI host, register it in the host's configuration file. Below are copy-pasteable templates for common hosts.
Claude Desktop
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"token-optimized-server": {
"command": "node",
"args": [
"/absolute/path/to/optimized-mcp-server/build/index.js"
]
}
}
}Important: Replace
/absolute/path/to/with the actual absolute path on your system. On Windows, use double backslashes (\\) or forward slashes (/) in JSON strings.
After saving, fully quit and restart Claude Desktop to re-initialize the JSON-RPC handshake.
VS Code / Antigravity IDE
Add the following to your MCP configuration file (typically mcp_config.json in your editor's settings directory):
{
"mcpServers": {
"token-optimized-server": {
"command": "node",
"args": [
"/absolute/path/to/optimized-mcp-server/build/index.js"
]
}
}
}Windows example:
"args": [ "C:\\Users\\YourName\\projects\\optimized-mcp-server\\build\\index.js" ]
Usage
Development Mode
Run the server directly from TypeScript source using tsx (no build step required):
npm run devProduction Mode
Build first, then start the compiled server:
npm run build
npm startMCP Inspector
The MCP Inspector provides a browser-based UI for testing tools, simulating LLM requests, and inspecting JSON-RPC messages — no API keys required.
npx @modelcontextprotocol/inspector node build/index.jsThis launches a local proxy and opens the Inspector UI in your default browser. Use it to:
Verify the protocol handshake completes successfully.
Execute
extract_web_contentwith a test URL.Execute
query_metrics_databaseand confirm YAML output.Monitor
stderrlogs for token counts and threshold warnings.
Project Structure
optimized-mcp-server/
├── src/
│ └── index.ts # Core server implementation
├── build/ # Compiled JavaScript output (generated)
├── node_modules/ # Dependencies (generated)
├── package.json # Project metadata and scripts
├── tsconfig.json # TypeScript compiler configuration
├── .gitignore # Git exclusion rules
├── README.md # This file
└── SECURITY.md # Security guidelines and best practicesLicense
ISC
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/satyamkumar68/optimized-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server