mcp-fmt 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Tortuga
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,278 @@
1
+ # mcp-fmt
2
+
3
+ Format MCP tool results into markdown that renders in Claude Code's terminal.
4
+
5
+ > Built by [Tortuga](https://bytortuga.com)
6
+
7
+ ## Why
8
+
9
+ MCP tools return raw text. Without formatting, Claude Code displays unreadable walls of data. `mcp-fmt` gives you the markdown primitives that Claude Code's terminal actually renders — tables, lists, headers, code blocks, bold/italic — nothing more, nothing less.
10
+
11
+ ## Screenshots
12
+
13
+ | Claude Code | Cursor | Codex |
14
+ |---|---|---|
15
+ | Coming soon | Coming soon | Coming soon |
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ npm install mcp-fmt
21
+ # or
22
+ bun add mcp-fmt
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ### `table(headers, rows, totalRow?)`
28
+
29
+ Raw string arrays with an optional bold total row.
30
+
31
+ ```ts
32
+ import { table } from 'mcp-fmt'
33
+
34
+ table(
35
+ ['Task', 'Owner', 'Points'],
36
+ [
37
+ ['Init repo', 'alice', '3'],
38
+ ['Add formatter', 'bob', '5'],
39
+ ],
40
+ ['Total', '', '8']
41
+ )
42
+ ```
43
+
44
+ ### `table(rows)` — object overload
45
+
46
+ Pass an array of objects and headers are inferred from keys.
47
+
48
+ ```ts
49
+ table([
50
+ { id: 'QM-1', title: 'Init repo', status: 'done' },
51
+ { id: 'QM-2', title: 'Add formatter', status: 'in_progress' },
52
+ ])
53
+ ```
54
+
55
+ ### `section(title, ...content)`
56
+
57
+ Composes a titled block from a heading and content strings. The core building block for tool responses.
58
+
59
+ ```ts
60
+ import { section, table } from 'mcp-fmt'
61
+
62
+ section(
63
+ 'Sprint Summary',
64
+ 'By Owner:',
65
+ table(headers, rows, totals),
66
+ '',
67
+ '1 done · 2 in progress'
68
+ )
69
+ ```
70
+
71
+ ### `list(items, ordered?)`
72
+
73
+ ```ts
74
+ import { list } from 'mcp-fmt'
75
+
76
+ list(['Install mcp-fmt', 'Import formatters', 'Return formatted text'])
77
+ list(['First', 'Second', 'Third'], true)
78
+ ```
79
+
80
+ ### `keyValue(data)`
81
+
82
+ Renders an object as a two-column key/value table.
83
+
84
+ ```ts
85
+ import { keyValue } from 'mcp-fmt'
86
+
87
+ keyValue({ status: 'active', owner: 'alice', points: 8 })
88
+ ```
89
+
90
+ ### `statusBadge(status)`
91
+
92
+ ```ts
93
+ import { statusBadge } from 'mcp-fmt'
94
+
95
+ statusBadge('completed') // ✅
96
+ statusBadge('in_progress') // 🚀
97
+ statusBadge('blocked') // 🚫
98
+ statusBadge('on_hold') // ⏸️
99
+ statusBadge('reviewing') // 🔍
100
+ statusBadge('syncing') // 🔄
101
+ statusBadge('pending') // 📤
102
+ statusBadge('archived') // 🗑️
103
+ statusBadge('cancelled') // ❌
104
+ statusBadge('merged') // 🔀
105
+ ```
106
+
107
+ ### `priorityBadge(priority)`
108
+
109
+ ```ts
110
+ import { priorityBadge } from 'mcp-fmt'
111
+
112
+ priorityBadge('low') // 🟢
113
+ priorityBadge('medium') // 🟡
114
+ priorityBadge('high') // 🔴
115
+ priorityBadge('urgent') // 🔥
116
+ ```
117
+
118
+ ### `healthBadge(health)`
119
+
120
+ ```ts
121
+ import { healthBadge } from 'mcp-fmt'
122
+
123
+ healthBadge('healthy') // 🟢
124
+ healthBadge('degraded') // 🟡
125
+ healthBadge('warning') // 🟠
126
+ healthBadge('down') // 🔴
127
+ healthBadge('unknown') // ⬜
128
+ ```
129
+
130
+ ### `typeBadge(type)`
131
+
132
+ ```ts
133
+ import { typeBadge } from 'mcp-fmt'
134
+
135
+ typeBadge('bug') // 🐛
136
+ typeBadge('feature') // ✨
137
+ typeBadge('docs') // 📝
138
+ typeBadge('chore') // 🔧
139
+ typeBadge('security') // 🔒
140
+ typeBadge('performance') // ⚡
141
+ typeBadge('test') // 🧪
142
+ typeBadge('refactor') // ♻️
143
+ ```
144
+
145
+ ### `assignmentBadge(assignment)`
146
+
147
+ ```ts
148
+ import { assignmentBadge } from 'mcp-fmt'
149
+
150
+ assignmentBadge('unassigned') // 👤
151
+ assignmentBadge('team') // 👥
152
+ assignmentBadge('automated') // 🤖
153
+ assignmentBadge('owner') // 👑
154
+ ```
155
+
156
+ ### `codeBlock(code, lang?)`
157
+
158
+ ```ts
159
+ import { codeBlock } from 'mcp-fmt'
160
+
161
+ codeBlock(`const x = 1`, 'ts')
162
+ ```
163
+
164
+ ### `header(text, level?)`, `bold(text)`, `italic(text)`
165
+
166
+ ```ts
167
+ import { header, bold, italic } from 'mcp-fmt'
168
+
169
+ header('My Tool') // ## My Tool
170
+ header('My Tool', 1) // # My Tool
171
+ bold('Total: 42') // **Total: 42**
172
+ italic('optional') // _optional_
173
+ ```
174
+
175
+ ## Full MCP Tool Example
176
+
177
+ ```ts
178
+ import { table, section, bold } from 'mcp-fmt'
179
+
180
+ server.tool('summary', {}, async () => {
181
+ const headers = ['Task', 'Owner', 'Status', 'Points']
182
+ const rows = [
183
+ ['Init repo', 'alice', 'done', '3'],
184
+ ['Add formatter', 'bob', 'in_progress', '5'],
185
+ ['Write tests', 'alice', 'backlog', '2'],
186
+ ]
187
+ const totals = ['Total', '', '', '10']
188
+
189
+ return {
190
+ content: [{
191
+ type: 'text',
192
+ text: section(
193
+ 'Sprint Summary',
194
+ 'By Owner:',
195
+ table(headers, rows, totals),
196
+ '',
197
+ bold('Velocity: ') + '10 pts'
198
+ )
199
+ }]
200
+ }
201
+ })
202
+ ```
203
+
204
+ ## API Reference
205
+
206
+ | Export | Signature | Description |
207
+ | --- | --- | --- |
208
+ | `table` | `(headers, rows, totalRow?)` | Markdown table from string arrays; totalRow is bolded |
209
+ | `table` | `(rows: Row[])` | Convenience overload — infers headers from object keys |
210
+ | `section` | `(title, ...content)` | H2 title + content joined with newlines |
211
+ | `list` | `(items, ordered?)` | Unordered or ordered list |
212
+ | `nestedList` | `(items)` | Two-level nested list |
213
+ | `keyValue` | `(data: Row)` | Object rendered as a key/value table |
214
+ | `statusBadge` | `(status)` | Emoji for status values (backlog, in_progress, completed, blocked, on_hold, syncing, pending, reviewing, archived, cancelled, merged) |
215
+ | `priorityBadge` | `(priority)` | Emoji for priority values (low, medium, high, urgent) |
216
+ | `healthBadge` | `(health)` | Emoji for health/monitoring (healthy, degraded, warning, down, unknown) |
217
+ | `typeBadge` | `(type)` | Emoji for issue types (bug, feature, docs, chore, security, performance, test, refactor) |
218
+ | `assignmentBadge` | `(assignment)` | Emoji for assignment (unassigned, team, automated, owner) |
219
+ | `codeBlock` | `(code, lang?)` | Fenced code block with optional language |
220
+ | `inlineCode` | `(code)` | Backtick-wrapped inline code |
221
+ | `header` | `(text, level?)` | H1–H3 markdown header (default: H2) |
222
+ | `bold` | `(text)` | Bold text |
223
+ | `italic` | `(text)` | Italic text |
224
+
225
+ ## Previewing the output
226
+
227
+ Markdown only renders inside AI chat responses, not in terminal output. To see how your formatting looks, use the bundled preview MCP server.
228
+
229
+ **1. Clone the repo**
230
+
231
+ ```bash
232
+ git clone https://github.com/tortuga-ai/mcp-fmt.git
233
+ ```
234
+
235
+ **2. Add to your MCP config**
236
+
237
+ Claude Code (`~/.claude/mcp.json`):
238
+
239
+ ```json
240
+ {
241
+ "mcpServers": {
242
+ "mcp-fmt-preview": {
243
+ "type": "stdio",
244
+ "command": "bun",
245
+ "args": ["run", "./examples/preview-mcp.ts"]
246
+ }
247
+ }
248
+ }
249
+ ```
250
+
251
+ Cursor (`.cursor/mcp.json`):
252
+
253
+ ```json
254
+ {
255
+ "mcpServers": {
256
+ "mcp-fmt-preview": {
257
+ "command": "bun",
258
+ "args": ["run", "./examples/preview-mcp.ts"]
259
+ }
260
+ }
261
+ }
262
+ ```
263
+
264
+ **3. Restart your AI agent, then ask:** `call the preview tool`
265
+
266
+ It will render all primitives as markdown in the chat response.
267
+
268
+ ## License
269
+
270
+ MIT License - see LICENSE for details.
271
+
272
+ ## Author
273
+
274
+ [Josh Grenon](https://github.com/joshgrenon)
275
+
276
+ ---
277
+
278
+ ![](.github/tortuga.png)
package/dist/code.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function codeBlock(code: string, lang?: string): string;
2
+ export declare function inlineCode(code: string): string;
@@ -0,0 +1,9 @@
1
+ export { table } from './table';
2
+ export type { Row } from './table';
3
+ export { list, nestedList } from './list';
4
+ export { codeBlock, inlineCode } from './code';
5
+ export { header, bold, italic } from './text';
6
+ export { section } from './section';
7
+ export { keyValue } from './keyvalue';
8
+ export { statusBadge, priorityBadge, healthBadge, typeBadge, assignmentBadge } from './status';
9
+ export type { Status, Priority, Health, IssueType, Assignment } from './status';
package/dist/index.js ADDED
@@ -0,0 +1,139 @@
1
+ // src/table.ts
2
+ function table(headersOrRows, maybeRows, totalRow) {
3
+ if (maybeRows !== undefined) {
4
+ const headers2 = headersOrRows;
5
+ const lines = [
6
+ `| ${headers2.join(" | ")} |`,
7
+ `| ${headers2.map(() => "---").join(" | ")} |`,
8
+ ...maybeRows.map((r) => `| ${r.join(" | ")} |`),
9
+ ...totalRow ? [`| ${totalRow.map((v) => v ? `**${v}**` : "").join(" | ")} |`] : []
10
+ ];
11
+ return lines.join(`
12
+ `);
13
+ }
14
+ const objRows = headersOrRows;
15
+ if (objRows.length === 0)
16
+ return "";
17
+ const headers = Object.keys(objRows[0]);
18
+ const rows = objRows.map((r) => headers.map((h) => String(r[h] ?? "")));
19
+ return table(headers, rows);
20
+ }
21
+ // src/list.ts
22
+ function list(items, ordered = false) {
23
+ return items.map((item, i) => ordered ? `${i + 1}. ${item}` : `- ${item}`).join(`
24
+ `);
25
+ }
26
+ function nestedList(items) {
27
+ return items.map(({ text, children }) => {
28
+ const line = `- ${text}`;
29
+ if (!children?.length)
30
+ return line;
31
+ return [line, ...children.map((c) => ` - ${c}`)].join(`
32
+ `);
33
+ }).join(`
34
+ `);
35
+ }
36
+ // src/code.ts
37
+ function codeBlock(code, lang = "") {
38
+ return `\`\`\`${lang}
39
+ ${code}
40
+ \`\`\``;
41
+ }
42
+ function inlineCode(code) {
43
+ return `\`${code}\``;
44
+ }
45
+ // src/text.ts
46
+ function header(text, level = 2) {
47
+ return `${"#".repeat(level)} ${text}`;
48
+ }
49
+ function bold(text) {
50
+ return `**${text}**`;
51
+ }
52
+ function italic(text) {
53
+ return `_${text}_`;
54
+ }
55
+ // src/section.ts
56
+ function section(title, ...content) {
57
+ return [header(title, 2), ...content].join(`
58
+ `);
59
+ }
60
+ // src/keyvalue.ts
61
+ function keyValue(data) {
62
+ const rows = Object.entries(data).map(([k, v]) => [k, v == null ? "" : String(v)]);
63
+ return table(["Key", "Value"], rows);
64
+ }
65
+ // src/status.ts
66
+ var STATUS_EMOJI = {
67
+ backlog: "\uD83D\uDCCB",
68
+ in_progress: "\uD83D\uDE80",
69
+ completed: "✅",
70
+ blocked: "\uD83D\uDEAB",
71
+ on_hold: "⏸️",
72
+ syncing: "\uD83D\uDD04",
73
+ pending: "\uD83D\uDCE4",
74
+ reviewing: "\uD83D\uDD0D",
75
+ archived: "\uD83D\uDDD1️",
76
+ cancelled: "❌",
77
+ merged: "\uD83D\uDD00"
78
+ };
79
+ var PRIORITY_EMOJI = {
80
+ low: "\uD83D\uDFE2",
81
+ medium: "\uD83D\uDFE1",
82
+ high: "\uD83D\uDD34",
83
+ urgent: "\uD83D\uDD25"
84
+ };
85
+ var HEALTH_EMOJI = {
86
+ healthy: "\uD83D\uDFE2",
87
+ down: "\uD83D\uDD34",
88
+ degraded: "\uD83D\uDFE1",
89
+ warning: "\uD83D\uDFE0",
90
+ unknown: "⬜"
91
+ };
92
+ var TYPE_EMOJI = {
93
+ bug: "\uD83D\uDC1B",
94
+ feature: "✨",
95
+ docs: "\uD83D\uDCDD",
96
+ chore: "\uD83D\uDD27",
97
+ security: "\uD83D\uDD12",
98
+ performance: "⚡",
99
+ test: "\uD83E\uDDEA",
100
+ refactor: "♻️"
101
+ };
102
+ var ASSIGNMENT_EMOJI = {
103
+ unassigned: "\uD83D\uDC64",
104
+ team: "\uD83D\uDC65",
105
+ automated: "\uD83E\uDD16",
106
+ owner: "\uD83D\uDC51"
107
+ };
108
+ function statusBadge(status) {
109
+ return STATUS_EMOJI[status] ?? "\uD83D\uDCCB";
110
+ }
111
+ function priorityBadge(priority) {
112
+ return PRIORITY_EMOJI[priority] ?? "\uD83D\uDFE1";
113
+ }
114
+ function healthBadge(health) {
115
+ return HEALTH_EMOJI[health] ?? "⬜";
116
+ }
117
+ function typeBadge(type) {
118
+ return TYPE_EMOJI[type] ?? "\uD83D\uDCDD";
119
+ }
120
+ function assignmentBadge(assignment) {
121
+ return ASSIGNMENT_EMOJI[assignment] ?? "\uD83D\uDC64";
122
+ }
123
+ export {
124
+ typeBadge,
125
+ table,
126
+ statusBadge,
127
+ section,
128
+ priorityBadge,
129
+ nestedList,
130
+ list,
131
+ keyValue,
132
+ italic,
133
+ inlineCode,
134
+ healthBadge,
135
+ header,
136
+ codeBlock,
137
+ bold,
138
+ assignmentBadge
139
+ };
@@ -0,0 +1,2 @@
1
+ import type { Row } from './table';
2
+ export declare function keyValue(data: Row): string;
package/dist/list.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export declare function list(items: string[], ordered?: boolean): string;
2
+ export declare function nestedList(items: Array<{
3
+ text: string;
4
+ children?: string[];
5
+ }>): string;
@@ -0,0 +1 @@
1
+ export declare function section(title: string, ...content: string[]): string;
@@ -0,0 +1,10 @@
1
+ export type Status = 'backlog' | 'in_progress' | 'completed' | 'blocked' | 'on_hold' | 'syncing' | 'pending' | 'reviewing' | 'archived' | 'cancelled' | 'merged';
2
+ export type Priority = 'low' | 'medium' | 'high' | 'urgent';
3
+ export type Health = 'healthy' | 'down' | 'degraded' | 'warning' | 'unknown';
4
+ export type IssueType = 'bug' | 'feature' | 'docs' | 'chore' | 'security' | 'performance' | 'test' | 'refactor';
5
+ export type Assignment = 'unassigned' | 'team' | 'automated' | 'owner';
6
+ export declare function statusBadge(status: Status | string): string;
7
+ export declare function priorityBadge(priority: Priority | string): string;
8
+ export declare function healthBadge(health: Health | string): string;
9
+ export declare function typeBadge(type: IssueType | string): string;
10
+ export declare function assignmentBadge(assignment: Assignment | string): string;
@@ -0,0 +1,3 @@
1
+ export type Row = Record<string, string | number | boolean | null | undefined>;
2
+ export declare function table(headers: string[], rows: string[][], totalRow?: string[]): string;
3
+ export declare function table(rows: Row[]): string;
package/dist/text.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare function header(text: string, level?: 1 | 2 | 3): string;
2
+ export declare function bold(text: string): string;
3
+ export declare function italic(text: string): string;
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "mcp-fmt",
3
+ "version": "0.1.0",
4
+ "main": "./dist/index.js",
5
+ "module": "./dist/index.js",
6
+ "devDependencies": {
7
+ "@types/bun": "latest"
8
+ },
9
+ "peerDependencies": {
10
+ "typescript": "^5"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ }
17
+ },
18
+ "description": "Format MCP tool results into markdown that renders in Claude Code's terminal",
19
+ "keywords": [
20
+ "mcp",
21
+ "markdown",
22
+ "terminal",
23
+ "claude",
24
+ "formatting"
25
+ ],
26
+ "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/tortuga-ai/mcp-fmt.git"
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "scripts": {
35
+ "build": "bun build ./src/index.ts --outdir ./dist --target node && tsc -p tsconfig.build.json",
36
+ "test": "bun test",
37
+ "example": "bun run examples/basic.ts"
38
+ },
39
+ "type": "module",
40
+ "types": "./dist/index.d.ts"
41
+ }