Skip to content

Commit 6926c3a

Browse files
authored
feat: add experimental TOON output format for token-efficient responses (#149)
- Introduced `--toon` CLI flag and `MS365_MCP_OUTPUT_FORMAT` environment variable to enable TOON format. - Added `@toon-format/toon` dependency for serialization. - Updated `GraphClient` to support TOON output with fallback to JSON. - Documented TOON format benefits and usage in README.
1 parent def73e4 commit 6926c3a

File tree

7 files changed

+2596
-1580
lines changed

7 files changed

+2596
-1580
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jobs:
2222
node-version: ${{ matrix.node-version }}
2323
cache: 'npm'
2424

25+
- name: Install patch-package (if needed)
26+
run: npm i -D patch-package
27+
2528
- name: Install dependencies
2629
run: npm ci
2730

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,70 @@ API.
1919
- Read-only mode support for safe operations
2020
- Tool filtering for granular access control
2121

22+
## Output Format: JSON vs TOON
23+
24+
The server supports two output formats that can be configured globally:
25+
26+
### JSON Format (Default)
27+
28+
Standard JSON output with pretty-printing:
29+
30+
```json
31+
{
32+
"value": [
33+
{
34+
"id": "1",
35+
"displayName": "Alice Johnson",
36+
"mail": "[email protected]",
37+
"jobTitle": "Software Engineer"
38+
}
39+
]
40+
}
41+
```
42+
43+
### (experimental) TOON Format
44+
45+
[Token-Oriented Object Notation](https://github.com/toon-format/toon) for efficient LLM token usage:
46+
47+
```
48+
value[1]{id,displayName,mail,jobTitle}:
49+
"1",Alice Johnson,[email protected],Software Engineer
50+
```
51+
52+
**Benefits:**
53+
54+
- 30-60% fewer tokens vs JSON
55+
- Best for uniform array data (lists of emails, calendar events, files, etc.)
56+
- Ideal for cost-sensitive applications at scale
57+
58+
**Usage:**
59+
(experimental) Enable TOON format globally:
60+
61+
Via CLI flag:
62+
63+
```bash
64+
npx @softeria/ms-365-mcp-server --toon
65+
```
66+
67+
Via Claude Desktop configuration:
68+
69+
```json
70+
{
71+
"mcpServers": {
72+
"ms365": {
73+
"command": "npx",
74+
"args": ["-y", "@softeria/ms-365-mcp-server", "--toon"]
75+
}
76+
}
77+
}
78+
```
79+
80+
Via environment variable:
81+
82+
```bash
83+
MS365_MCP_OUTPUT_FORMAT=toon npx @softeria/ms-365-mcp-server
84+
```
85+
2286
## Supported Services & Tools
2387

2488
### Personal Account Tools (Available by default)
@@ -289,6 +353,7 @@ When running as an MCP server, the following options can be used:
289353
Starts Express.js server with MCP endpoint at /mcp
290354
--enable-auth-tools Enable login/logout tools when using HTTP mode (disabled by default in HTTP mode)
291355
--enabled-tools <pattern> Filter tools using regex pattern (e.g., "excel|contact" to enable Excel and Contact tools)
356+
--toon (experimental) Enable TOON output format for 30-60% token reduction
292357
```
293358

294359
Environment variables:
@@ -297,6 +362,7 @@ Environment variables:
297362
- `ENABLED_TOOLS`: Filter tools using a regex pattern (alternative to --enabled-tools flag)
298363
- `MS365_MCP_ORG_MODE=true|1`: Enable organization/work mode (alternative to --org-mode flag)
299364
- `MS365_MCP_FORCE_WORK_SCOPES=true|1`: Backwards compatibility for MS365_MCP_ORG_MODE
365+
- `MS365_MCP_OUTPUT_FORMAT=toon`: Enable TOON output format (alternative to --toon flag)
300366
- `LOG_LEVEL`: Set logging level (default: 'info')
301367
- `SILENT=true|1`: Disable console output
302368
- `MS365_MCP_CLIENT_ID`: Custom Azure app client ID (defaults to built-in app)

0 commit comments

Comments
 (0)