You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add TOON output format for token-efficient LLM responses (#145)
- Add @toon-format/toon package for Token-Oriented Object Notation
- TOON is now the default output format (30-60% fewer tokens than JSON)
- Add outputFormat parameter to switch between 'toon' (default) and 'json'
- Update tool descriptions with cost optimization guidance
- Add schema discovery pattern guidance for AI to explore fields first
- Fallback to JSON automatically if TOON conversion fails
TOON format example:
[2]{id,name,key}:
"327682",Codashop,SHOP
"16711683",Codapay,PAY
vs JSON:
[{"id":"327682","name":"Codashop","key":"SHOP"},...]
Copy file name to clipboardExpand all lines: src/tools/atlassian.api.types.ts
+21-2Lines changed: 21 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,20 @@
1
1
import{z}from'zod';
2
2
3
+
/**
4
+
* Output format options for API responses
5
+
* - toon: Token-Oriented Object Notation (default, more token-efficient for LLMs)
6
+
* - json: Standard JSON format
7
+
*/
8
+
exportconstOutputFormat=z
9
+
.enum(['toon','json'])
10
+
.optional()
11
+
.describe(
12
+
'Output format: "toon" (default, 30-60% fewer tokens) or "json". TOON is optimized for LLMs with tabular arrays and minimal syntax.',
13
+
);
14
+
3
15
/**
4
16
* Base schema fields shared by all API tool arguments
5
-
* Contains path, queryParams, and jq filter
17
+
* Contains path, queryParams, jq filter, and outputFormat
6
18
*/
7
19
constBaseApiToolArgs={
8
20
/**
@@ -33,13 +45,20 @@ const BaseApiToolArgs = {
33
45
34
46
/**
35
47
* Optional JMESPath expression to filter/transform the response
48
+
* IMPORTANT: Always use this to reduce response size and token costs
36
49
*/
37
50
jq: z
38
51
.string()
39
52
.optional()
40
53
.describe(
41
-
'JMESPath expression to filter/transform the JSON response. Examples: "results[*].id" (extract IDs), "results[0]" (first result), "{id: id, title: title}" (reshape object). See https://jmespath.org for syntax.',
54
+
'JMESPath expression to filter/transform the response. IMPORTANT: Always use this to extract only needed fields and reduce token costs. Examples: "results[*].{id: id, title: title}" (extract specific fields), "results[0]" (first result), "results[*].id" (IDs only). See https://jmespath.org',
42
55
),
56
+
57
+
/**
58
+
* Output format for the response
59
+
* Defaults to TOON (token-efficient), can be set to JSON if needed
0 commit comments