Integrate LessToken's compression capabilities into your AI workflows using the Model Context Protocol (MCP). Use compression tools directly in Claude Desktop, Cursor IDE, Continue.dev, and other MCP-compatible clients.
The Model Context Protocol (MCP) is an open protocol that standardizes how AI applications provide context and tools to language models. It enables seamless integration between AI assistants and external services.
Our MCP server exposes LessToken's compression engine as a standardized tool that can be used by any MCP-compatible client, including:
Install the MCP server in Cursor with one click. You'll need your API key ready.
Don't have an API key? Get one here
Note: After clicking the install button, you'll need to replace YOUR_API_KEY_HERE with your actual API key in the Cursor configuration.
First, you need an API key from LessToken. If you don't have one yet, follow our guide to create your first API key.
Configure your MCP client (Claude Desktop, Cursor IDE, VS Code, Windsurf, etc.) to connect to our MCP server. See the integration guides below for platform-specific instructions.
Once configured, you can use the compress_text tool directly in your AI conversations to compress prompts and reduce token usage.
/api/mcpThe MCP server endpoint accepts JSON-RPC 2.0 requests following the MCP protocol specification. All requests must include authentication via API key.
Base URL
https://lesstokens.hive-hub.ai
Content-Type
application/json
Authentication
X-API-Key or Authorization header
All MCP requests must include your API key. You can provide it in one of two ways:
Authorization: Bearer YOUR_API_KEYX-API-Key: YOUR_API_KEYCompress text prompts to reduce token usage while preserving semantic meaning. This tool uses LessToken's intelligent compression engine with automatic optimization. Only the prompt field is required.
{
"prompt": "string (required, 1-100000 chars)"
}The tool uses automatic optimization - no options needed. Just provide your text prompt.
{
"compressed": "string",
"originalTokens": "number",
"compressedTokens": "number",
"tokensSaved": "number",
"compressionRatio": "number",
"processingTimeMs": "number"
}{
"compressed": "Compressed text here...",
"originalTokens": 150,
"compressedTokens": 95,
"tokensSaved": 55,
"compressionRatio": 0.633,
"processingTimeMs": 234
}Use compression directly in Claude conversations. Configure Claude Desktop to connect to our MCP server.
Setup GuideIntegrate compression into your development workflow. Access compression tools while coding.
Setup GuideUse compression in VS Code with MCP-compatible extensions. Configure VS Code to connect to our MCP server.
Setup GuideIntegrate compression into Windsurf AI coding assistant. Configure Windsurf to use our MCP server.
Setup GuideUse compression in your AI-assisted coding sessions. Configure Continue.dev to use our MCP server.
Setup GuideUse compression in Claude Code editor. Configure Claude Code to connect to our MCP server.
Setup Guideimport { Client } from '@modelcontextprotocol/sdk/client/index.js';
const client = new Client({
name: 'less-token-client',
version: '1.0.0',
}, {
capabilities: {},
});
// Connect to MCP server
await client.connect({
type: 'http',
url: 'https://lesstokens.hive-hub.ai/api/mcp',
headers: {
'X-API-Key': 'YOUR_API_KEY',
},
});
// Call compress_text tool (only prompt field required)
const result = await client.callTool({
name: 'compress_text',
arguments: {
prompt: 'Your long text prompt here...',
},
});
console.log('Compressed:', result.content[0].text);
console.log('Tokens saved:', result.structuredContent?.tokensSaved);import requests
import json
# MCP server endpoint
url = "https://lesstokens.hive-hub.ai/api/mcp"
# Prepare JSON-RPC request (only prompt field required)
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "compress_text",
"arguments": {
"prompt": "Your long text prompt here..."
}
}
}
headers = {
"Content-Type": "application/json",
"X-API-Key": "YOUR_API_KEY"
}
# Make request
response = requests.post(url, json=payload, headers=headers)
result = response.json()
# Parse result
if "result" in result:
compressed_data = json.loads(result["result"]["content"][0]["text"])
print(f"Compressed: {compressed_data['compressed']}")
print(f"Tokens saved: {compressed_data['tokensSaved']}")curl -X POST https://lesstokens.hive-hub.ai/api/mcp \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "compress_text",
"arguments": {
"prompt": "Your long text prompt here..."
}
}
}'The MCP server follows the JSON-RPC 2.0 error specification. All errors include an error code, message, and optional data field with additional context.
-32001Authentication Error - Invalid or missing API key
-32601Method Not Found - Invalid method name
-32603Internal Error - Server-side error during processing
-32000Rate Limit Exceeded - Too many requests
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32001,
"message": "Authentication required",
"data": {
"type": "AUTHENTICATION_ERROR",
"docs": "https://docs.lesstoken.com/api-reference/authentication"
}
}
}Store your API key in environment variables or secure credential storage. Never commit API keys to version control.
Always check for errors in responses and implement proper error handling. Use the error codes to provide meaningful feedback to users.
Monitor your rate limit usage and implement exponential backoff for retries. Check rate limit headers in responses.
The compression engine automatically selects the best optimization strategies based on your content. No configuration needed - just provide your prompt and get optimized results.