tty-table 6.0.1 → 6.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/README.md +55 -0
- package/dist/mcp.d.mts +54 -0
- package/dist/mcp.d.ts +54 -0
- package/dist/mcp.js +1107 -0
- package/dist/mcp.js.map +1 -0
- package/dist/mcp.mjs +1099 -0
- package/dist/mcp.mjs.map +1 -0
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -33,6 +33,61 @@ $ node examples/data/fake-stream.js | tty-table --format json --header examples/
|
|
|
33
33
|
$ tty-table -h
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
### MCP server
|
|
37
|
+
|
|
38
|
+
Expose tty-table to MCP clients (Claude, IDE agents, Cursor, etc.) over stdio.
|
|
39
|
+
|
|
40
|
+
#### Client configuration
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"mcpServers": {
|
|
45
|
+
"tty-table": {
|
|
46
|
+
"command": "npx",
|
|
47
|
+
"args": ["-y", "--package=tty-table", "tty-table-mcp"]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### Tools
|
|
54
|
+
|
|
55
|
+
| Tool | Description |
|
|
56
|
+
|------|-------------|
|
|
57
|
+
| `render_table` | Render data as an ASCII/Unicode terminal table. Accepts `header`, `rows`, and any tty-table `options`; returns the rendered table as text. |
|
|
58
|
+
|
|
59
|
+
**Arguments for `render_table`:**
|
|
60
|
+
|
|
61
|
+
| Name | Type | Required | Description |
|
|
62
|
+
|------|------|----------|-------------|
|
|
63
|
+
| `header` | `(string \| {value, align?, width?})[]` | no | Column definitions |
|
|
64
|
+
| `rows` | `(unknown[] \| Record<string, unknown>)[]` | yes | Row data (arrays of cells, or objects keyed by column name) |
|
|
65
|
+
| `options` | `object` | no | Any tty-table option (e.g. `width`, `borderStyle`, `align`, `compact`) |
|
|
66
|
+
|
|
67
|
+
Example tool call:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"header": [{ "value": "name" }, { "value": "score", "align": "right" }],
|
|
72
|
+
"rows": [["Ada", 100], ["Grace", 98]],
|
|
73
|
+
"options": { "width": 40 }
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Rendered result:
|
|
78
|
+
|
|
79
|
+
```text
|
|
80
|
+
┌───────┬───────┐
|
|
81
|
+
│ name │ score │
|
|
82
|
+
├───────┼───────┤
|
|
83
|
+
│ Ada │ 100 │
|
|
84
|
+
├───────┼───────┤
|
|
85
|
+
│ Grace │ 98 │
|
|
86
|
+
└───────┴───────┘
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
> Additional tools may be added in future releases under the same MCP server.
|
|
90
|
+
|
|
36
91
|
### Browser & Browser Console
|
|
37
92
|
|
|
38
93
|
- View in Chrome or Chromium at [http://localhost:8070/examples/browser-example.html](http://localhost:8070/examples/browser-example.html) using a dockerized apache instance:
|
package/dist/mcp.d.mts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
declare const headerEntry: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
6
|
+
value: z.ZodString;
|
|
7
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
8
|
+
left: "left";
|
|
9
|
+
center: "center";
|
|
10
|
+
right: "right";
|
|
11
|
+
}>>;
|
|
12
|
+
width: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
13
|
+
}, z.core.$strip>]>;
|
|
14
|
+
/** Shared input schema for the render_table tool (used by server + tests). */
|
|
15
|
+
declare const renderTableInputSchema: {
|
|
16
|
+
header: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
17
|
+
value: z.ZodString;
|
|
18
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
19
|
+
left: "left";
|
|
20
|
+
center: "center";
|
|
21
|
+
right: "right";
|
|
22
|
+
}>>;
|
|
23
|
+
width: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
24
|
+
}, z.core.$strip>]>>>;
|
|
25
|
+
rows: z.ZodArray<z.ZodUnion<readonly [z.ZodArray<z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
26
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
27
|
+
};
|
|
28
|
+
type RenderTableArgs = {
|
|
29
|
+
header?: Array<z.infer<typeof headerEntry>> | undefined;
|
|
30
|
+
rows: Array<unknown[] | Record<string, unknown>>;
|
|
31
|
+
options?: Record<string, unknown> | undefined;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Core handler for the render_table MCP tool.
|
|
35
|
+
* Extracted so unit tests can exercise success and error paths without
|
|
36
|
+
* starting a stdio transport.
|
|
37
|
+
*/
|
|
38
|
+
declare function handleRenderTable({ header, rows, options }: RenderTableArgs): {
|
|
39
|
+
content: {
|
|
40
|
+
type: "text";
|
|
41
|
+
text: string;
|
|
42
|
+
}[];
|
|
43
|
+
isError?: never;
|
|
44
|
+
} | {
|
|
45
|
+
isError: true;
|
|
46
|
+
content: {
|
|
47
|
+
type: "text";
|
|
48
|
+
text: string;
|
|
49
|
+
}[];
|
|
50
|
+
};
|
|
51
|
+
/** Build a configured McpServer instance (does not connect a transport). */
|
|
52
|
+
declare function createMcpServer(): McpServer;
|
|
53
|
+
|
|
54
|
+
export { type RenderTableArgs, createMcpServer, handleRenderTable, renderTableInputSchema };
|
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
declare const headerEntry: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
6
|
+
value: z.ZodString;
|
|
7
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
8
|
+
left: "left";
|
|
9
|
+
center: "center";
|
|
10
|
+
right: "right";
|
|
11
|
+
}>>;
|
|
12
|
+
width: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
13
|
+
}, z.core.$strip>]>;
|
|
14
|
+
/** Shared input schema for the render_table tool (used by server + tests). */
|
|
15
|
+
declare const renderTableInputSchema: {
|
|
16
|
+
header: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
17
|
+
value: z.ZodString;
|
|
18
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
19
|
+
left: "left";
|
|
20
|
+
center: "center";
|
|
21
|
+
right: "right";
|
|
22
|
+
}>>;
|
|
23
|
+
width: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
24
|
+
}, z.core.$strip>]>>>;
|
|
25
|
+
rows: z.ZodArray<z.ZodUnion<readonly [z.ZodArray<z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
26
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
27
|
+
};
|
|
28
|
+
type RenderTableArgs = {
|
|
29
|
+
header?: Array<z.infer<typeof headerEntry>> | undefined;
|
|
30
|
+
rows: Array<unknown[] | Record<string, unknown>>;
|
|
31
|
+
options?: Record<string, unknown> | undefined;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Core handler for the render_table MCP tool.
|
|
35
|
+
* Extracted so unit tests can exercise success and error paths without
|
|
36
|
+
* starting a stdio transport.
|
|
37
|
+
*/
|
|
38
|
+
declare function handleRenderTable({ header, rows, options }: RenderTableArgs): {
|
|
39
|
+
content: {
|
|
40
|
+
type: "text";
|
|
41
|
+
text: string;
|
|
42
|
+
}[];
|
|
43
|
+
isError?: never;
|
|
44
|
+
} | {
|
|
45
|
+
isError: true;
|
|
46
|
+
content: {
|
|
47
|
+
type: "text";
|
|
48
|
+
text: string;
|
|
49
|
+
}[];
|
|
50
|
+
};
|
|
51
|
+
/** Build a configured McpServer instance (does not connect a transport). */
|
|
52
|
+
declare function createMcpServer(): McpServer;
|
|
53
|
+
|
|
54
|
+
export { type RenderTableArgs, createMcpServer, handleRenderTable, renderTableInputSchema };
|