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
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.0.0-preview] - 2025-01-14

### Changed
- **BREAKING: ASON 2.0 Support** - Updated to support ASON 2.0 format
- **Configuration Options Updated**:
- ❌ Removed `useDictionary` (no longer exists in ASON 2.0)
- ✅ Added `useSections` - Enable `@section` organization for objects (default: true)
- ✅ Added `useTabular` - Enable `key:[N]{fields}` tabular arrays (default: true)
- ✅ Added `minFieldsForSection` - Min fields to create @section (default: 3)
- ✅ Added `minRowsForTabular` - Min rows for tabular format (default: 2)
- ✅ Added `minReferenceOccurrences` - Min occurrences for $var reference (default: 2)
- Changed default `delimiter` from `","` to `"|"` (pipe is more token-efficient)
- **Syntax Updates**:
- Arrays now use `key:[N]{fields}` instead of `key:[N]@fields`
- Tabular data uses pipe delimiter `|` by default instead of comma `,`
- References now use `$var` semantic names (already supported)
- Sections use `@section` for objects (already supported)
- **Updated Documentation**:
- All examples in README.md updated to ASON 2.0 syntax
- Tool descriptions updated to reflect new format

### Dependencies
- Updated `@ason-format/ason` to `^2.0.0-preview` (from `^1.1.3`)

### Migration Notes
- If you have existing MCP server configurations, update:
- `useDictionary: true` → Remove (or replace with `useSections: true, useTabular: true`)
- `delimiter: ","` → `delimiter: "|"` (recommended)
- ASON output format has changed - see ASON 2.0 documentation

## [1.1.3] - 2025-11-13

### Changed
Expand Down
62 changes: 38 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,29 @@ Compress JSON data to ASON format.
"json": {"users": [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]},
"config": {
"indent": 1,
"delimiter": ",",
"delimiter": "|",
"useReferences": true,
"useDictionary": true
"useSections": true,
"useTabular": true
}
}
```

**Output:**
```
ASON Output:
ASON 2.0 Output:

users:[2]@id,name
1,Alice
2,Bob
users:[2]{id,name}
1|Alice
2|Bob

Configuration used:
{
"indent": 1,
"delimiter": ",",
"delimiter": "|",
"useReferences": true,
"useDictionary": true
"useSections": true,
"useTabular": true
}
```

Expand All @@ -104,7 +106,7 @@ Decompress ASON back to JSON.
**Input:**
```json
{
"ason": "users:[2]@id,name\n1,Alice\n2,Bob"
"ason": "users:[2]{id,name}\n1|Alice\n2|Bob"
}
```

Expand All @@ -128,7 +130,7 @@ Analyze compression statistics.
"json": {"users": [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]},
"config": {
"indent": 1,
"delimiter": ","
"delimiter": "|"
}
}
```
Expand All @@ -148,9 +150,10 @@ Savings: 37 bytes
Configuration:
{
"indent": 1,
"delimiter": ",",
"delimiter": "|",
"useReferences": true,
"useDictionary": true
"useSections": true,
"useTabular": true
}
```

Expand All @@ -163,7 +166,7 @@ Update global compression settings.
{
"config": {
"indent": 2,
"delimiter": "|",
"delimiter": ",",
"useReferences": false
}
}
Expand All @@ -175,9 +178,10 @@ Global configuration updated:

{
"indent": 2,
"delimiter": "|",
"delimiter": ",",
"useReferences": false,
"useDictionary": true
"useSections": true,
"useTabular": true
}
```

Expand All @@ -186,9 +190,13 @@ Global configuration updated:
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `indent` | number | `1` | Indentation level for nested structures |
| `delimiter` | string | `","` | Field delimiter for uniform arrays |
| `useReferences` | boolean | `true` | Enable object reference aliasing (`&obj0`) |
| `useDictionary` | boolean | `true` | Enable inline-first value dictionary (`value #0`) |
| `delimiter` | string | `"|"` | Field delimiter for tabular arrays (pipe, comma, or tab) |
| `useReferences` | boolean | `true` | Enable `$var` reference deduplication |
| `useSections` | boolean | `true` | Enable `@section` organization for objects |
| `useTabular` | boolean | `true` | Enable `[N]{fields}` tabular format for arrays |
| `minFieldsForSection` | number | `3` | Minimum fields to create a `@section` |
| `minRowsForTabular` | number | `2` | Minimum rows for tabular array format |
| `minReferenceOccurrences` | number | `2` | Minimum occurrences to create a `$var` reference |

## Development

Expand Down Expand Up @@ -218,9 +226,9 @@ Claude: I'll use the compress_json tool to compress this JSON.
[Uses MCP tool compress_json]

Result:
products:[2]@id,name,price
1,Laptop,999
2,Mouse,25
products:[2]{id,name,price}
1|Laptop|999
2|Mouse|25

This compressed version uses 45% fewer tokens!
```
Expand Down Expand Up @@ -250,11 +258,17 @@ To release a new version:
- ✅ **Continue** (VS Code extension)
- ✅ **Any MCP client** with stdio transport

## 📚 What is ASON?
## 📚 What is ASON 2.0?

ASON (Aliased Serialization Object Notation) 2.0 is a token-optimized JSON compression format designed for LLMs. It reduces token usage by 20-60% while maintaining 100% lossless round-trip fidelity.

ASON (Aliased Serialization Object Notation) is a token-optimized JSON compression format designed for LLMs. It reduces token usage by 20-60% while maintaining 100% lossless round-trip fidelity.
**Key features:**
- **Sections** (`@section`) - Organize related objects
- **Tabular Arrays** (`key:[N]{fields}`) - CSV-like format for uniform arrays
- **References** (`$var`) - Deduplicate repeated values
- **Pipe Delimiter** (`|`) - More token-efficient than commas

**Learn more**: [github.com/ason-format/ason](https://github.com/ason-format/ason)
**Learn more**: [ason-format.github.io/ason](https://ason-format.github.io/ason/)

## 📖 Documentation

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ason-format/mcp-server",
"version": "1.1.3",
"version": "2.0.0-preview",
"description": "Model Context Protocol server for ASON compression/decompression. Compatible with Claude Desktop, Cline, Continue, and other MCP clients.",
"type": "module",
"main": "./dist/index.js",
Expand Down Expand Up @@ -56,7 +56,7 @@
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.21.1",
"@ason-format/ason": "^1.1.3"
"@ason-format/ason": "^2.0.0-preview"
},
"devDependencies": {
"@types/node": "^22.0.0",
Expand Down
91 changes: 72 additions & 19 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ import type { CompressorConfig } from "./types.js";
*/
let globalConfig: CompressorConfig = {
indent: 1,
delimiter: ",",
delimiter: "|",
useReferences: true,
useDictionary: true,
useSections: true,
useTabular: true,
minFieldsForSection: 3,
minRowsForTabular: 2,
minReferenceOccurrences: 2,
};

/**
Expand Down Expand Up @@ -53,15 +57,31 @@ class AsonMCPServer {
delimiter: z
.string()
.optional()
.describe('Field delimiter (default: ",")'),
.describe('Field delimiter (default: "|")'),
useReferences: z
.boolean()
.optional()
.describe("Enable object references (default: true)"),
useDictionary: z
.describe("Enable $var references (default: true)"),
useSections: z
.boolean()
.optional()
.describe("Enable value dictionary (default: true)"),
.describe("Enable @section organization (default: true)"),
useTabular: z
.boolean()
.optional()
.describe("Enable [N]{fields} tabular arrays (default: true)"),
minFieldsForSection: z
.number()
.optional()
.describe("Min fields to create @section (default: 3)"),
minRowsForTabular: z
.number()
.optional()
.describe("Min rows for tabular format (default: 2)"),
minReferenceOccurrences: z
.number()
.optional()
.describe("Min occurrences for $var reference (default: 2)"),
})
.optional()
.describe("Optional compression configuration"),
Expand All @@ -84,11 +104,12 @@ class AsonMCPServer {
{
type: "text",
text:
`Here's your compressed ASON format! The compression achieved:\n\n` +
`Here's your compressed ASON 2.0 format! The compression achieved:\n\n` +
`**Key optimizations:**\n` +
`• Value deduplication: Repeated values are stored once as references\n` +
`• Compact syntax: Removed JSON's braces, brackets, and quotes where possible\n` +
`• Dot notation: Nested objects use concise dot notation\n\n` +
`• Sections (@section): Organize related data\n` +
`• Tabular Arrays ([N]{fields}): CSV-like format for uniform arrays\n` +
`• References ($var): Deduplicate repeated values\n` +
`• Pipe Delimiter (|): More token-efficient than commas\n\n` +
`The ASON format is **fully reversible** back to the original JSON - it's lossless compression optimized for reducing token usage when working with LLMs!\n\n` +
`\`\`\`ason\n` +
result.ason +
Expand Down Expand Up @@ -141,15 +162,31 @@ class AsonMCPServer {
delimiter: z
.string()
.optional()
.describe('Field delimiter (default: ",")'),
.describe('Field delimiter (default: "|")'),
useReferences: z
.boolean()
.optional()
.describe("Enable object references (default: true)"),
useDictionary: z
.describe("Enable $var references (default: true)"),
useSections: z
.boolean()
.optional()
.describe("Enable @section organization (default: true)"),
useTabular: z
.boolean()
.optional()
.describe("Enable value dictionary (default: true)"),
.describe("Enable [N]{fields} tabular arrays (default: true)"),
minFieldsForSection: z
.number()
.optional()
.describe("Min fields to create @section (default: 3)"),
minRowsForTabular: z
.number()
.optional()
.describe("Min rows for tabular format (default: 2)"),
minReferenceOccurrences: z
.number()
.optional()
.describe("Min occurrences for $var reference (default: 2)"),
})
.optional()
.describe("Optional compression configuration for analysis"),
Expand All @@ -168,7 +205,7 @@ class AsonMCPServer {
`📊 **Compression Statistics**\n\n` +
`**Tokens**: ${stats.original_tokens} → ${stats.compressed_tokens} (${stats.reduction_percent.toFixed(1)}% reduction)\n` +
`**Size**: ${stats.original_size} → ${stats.compressed_size} bytes (saved ${stats.savings_bytes} bytes)\n\n` +
`*Config: indent=${stats.config.indent}, delimiter="${stats.config.delimiter}", refs=${stats.config.useReferences}, dict=${stats.config.useDictionary}*`,
`*Config: indent=${stats.config.indent}, delimiter="${stats.config.delimiter}", refs=${stats.config.useReferences}, sections=${stats.config.useSections}, tabular=${stats.config.useTabular}*`,
},
],
};
Expand All @@ -189,11 +226,27 @@ class AsonMCPServer {
useReferences: z
.boolean()
.optional()
.describe("Enable object references"),
useDictionary: z
.describe("Enable $var references"),
useSections: z
.boolean()
.optional()
.describe("Enable @section organization"),
useTabular: z
.boolean()
.optional()
.describe("Enable value dictionary"),
.describe("Enable [N]{fields} tabular arrays"),
minFieldsForSection: z
.number()
.optional()
.describe("Min fields for @section"),
minRowsForTabular: z
.number()
.optional()
.describe("Min rows for tabular"),
minReferenceOccurrences: z
.number()
.optional()
.describe("Min occurrences for $var"),
})
.describe("New global configuration"),
},
Expand All @@ -207,7 +260,7 @@ class AsonMCPServer {
content: [
{
type: "text",
text: `✓ Global configuration updated:\n\n**indent**: ${globalConfig.indent}\n**delimiter**: "${globalConfig.delimiter}"\n**useReferences**: ${globalConfig.useReferences}\n**useDictionary**: ${globalConfig.useDictionary}`,
text: `✓ Global configuration updated:\n\n**indent**: ${globalConfig.indent}\n**delimiter**: "${globalConfig.delimiter}"\n**useReferences**: ${globalConfig.useReferences}\n**useSections**: ${globalConfig.useSections}\n**useTabular**: ${globalConfig.useTabular}\n**minFieldsForSection**: ${globalConfig.minFieldsForSection}\n**minRowsForTabular**: ${globalConfig.minRowsForTabular}\n**minReferenceOccurrences**: ${globalConfig.minReferenceOccurrences}`,
},
],
};
Expand Down
8 changes: 6 additions & 2 deletions src/tools/compress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ export function compressJson(input: CompressJsonInput): { ason: string; config:
ason,
config: {
indent: config.indent ?? 1,
delimiter: config.delimiter ?? ',',
delimiter: config.delimiter ?? '|',
useReferences: config.useReferences ?? true,
useDictionary: config.useDictionary ?? true
useSections: config.useSections ?? true,
useTabular: config.useTabular ?? true,
minFieldsForSection: config.minFieldsForSection ?? 3,
minRowsForTabular: config.minRowsForTabular ?? 2,
minReferenceOccurrences: config.minReferenceOccurrences ?? 2
}
};
}
8 changes: 6 additions & 2 deletions src/tools/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ export function getCompressionStats(input: GetStatsInput): CompressionStats & {
savings_bytes: stats.original_size - stats.compressed_size,
config: {
indent: config.indent ?? 1,
delimiter: config.delimiter ?? ',',
delimiter: config.delimiter ?? '|',
useReferences: config.useReferences ?? true,
useDictionary: config.useDictionary ?? true
useSections: config.useSections ?? true,
useTabular: config.useTabular ?? true,
minFieldsForSection: config.minFieldsForSection ?? 3,
minRowsForTabular: config.minRowsForTabular ?? 2,
minReferenceOccurrences: config.minReferenceOccurrences ?? 2
}
};
}
6 changes: 5 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ export interface CompressorConfig {
indent?: number;
delimiter?: string;
useReferences?: boolean;
useDictionary?: boolean;
useSections?: boolean;
useTabular?: boolean;
minFieldsForSection?: number;
minRowsForTabular?: number;
minReferenceOccurrences?: number;
}

/**
Expand Down
Loading