LessTokens Logo
Mcp Server
Claude Code

Documentation

Getting Started

  • Overview
  • Account Setup
  • First API Key
  • First Request
  • Understanding Metrics

API Reference

  • Overview
  • Authentication
  • Compressionnew
  • MCP Servernew
  • Errors

Integrations

  • Node.js / TypeScript
  • Python
  • cURL

Resources

  • Best Practices

Need help?

Join our community or contact support for assistance.

Contact Support →

Claude Code Integration

Integrate LessToken's compression capabilities into Claude Code editor. Use compression tools directly in your Claude Code workflow.

Overview

Claude Code is Anthropic's code editor that integrates with Claude AI and supports MCP servers. By configuring Claude Code to use our MCP server, you can access compression tools directly in your coding workflow.

This integration allows you to compress code, documentation, and prompts before sending them to Claude, reducing token usage and improving efficiency.

Prerequisites

  • Claude Code installed on your system
  • A LessToken API key (get one here)
  • Access to Claude Code configuration files

Configuration Steps

1

Locate Claude Code Config

Claude Code stores its configuration in a JSON file. The location depends on your operating system:

macOS
~/Library/Application Support/Claude Code/config.json
Windows
%APPDATA%\Claude Code\config.json
Linux
~/.config/Claude Code/config.json
2

Configure MCP Server

Open the configuration file and add the MCP server configuration. If the file doesn't exist, create it with the following structure:

config.json
{
  "mcpServers": {
    "less-token-compression": {
      "url": "https://lesstokens.hive-hub.ai/api/mcp",
      "headers": {
        "X-API-Key": "YOUR_API_KEY_HERE"
      }
    }
  }
}
Important: Replace YOUR_API_KEY_HERE with your actual LessToken API key. Keep this file secure.
3

Add Auto-Invoke Rule (Optional)

To automatically use compression, add a rule to your CLAUDE.md file:

CLAUDE.md
Always use the compress_text tool from less-token-compression MCP server when I need
to compress code, documentation, or prompts before sending them to Claude. This means you
should automatically use the compression tool to optimize content for token efficiency.
4

Restart Claude Code

After saving the configuration, restart Claude Code completely. The MCP server will be connected when Claude Code starts.

5

Verify Integration

In Claude Code, you should now see the compress_text tool available. You can verify this by checking available tools or using compression in your conversations.

Usage Examples

Example 1: Compress Code Context

Compress large code contexts before sending to Claude:

Claude Code Chat
You: I have a large codebase context I want to send to Claude.
Can you compress it first using compress_text?

Claude: I'll compress the code context for you to reduce token usage.

[Claude uses compress_text tool]

Compressed context ready. Original: 5000 tokens, Compressed: 3200 tokens (36% reduction)

Example 2: Automatic Compression

With the auto-invoke rule configured, Claude will automatically compress content:

Claude Code Chat
You: This prompt is too verbose. Can you optimize it?

Claude: I'll optimize the prompt using compress_text automatically.

[Claude uses compress_text tool]

Here's the compressed version optimized for efficiency...

Troubleshooting

MCP Server Not Connecting

  • Verify your API key is correct in the configuration file
  • Ensure Claude Code has been restarted after configuration changes
  • Check Claude Code logs for connection errors
  • Verify the MCP server URL is accessible

Tool Not Available

  • Confirm the configuration file syntax is correct (valid JSON)
  • Check that the MCP server name matches: less-token-compression
  • Try removing and re-adding the MCP server configuration
  • Check Claude Code's MCP server status in settings

Additional Resources

MCP Server Docs

Return to the main MCP server documentation.

Claude Docs

Official Claude documentation.