@teamnetwork-nz/ninjaone-mcp-server 0.5.3 → 0.6.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 +2 -0
- package/dist/index.js +22 -7
- package/dist/tools/index.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -183,6 +183,8 @@ inherit it from their organisation.
|
|
|
183
183
|
### Output format: Markdown or JSON
|
|
184
184
|
Every tool accepts `format="markdown" | "json"`, so the caller picks per request:
|
|
185
185
|
|
|
186
|
+
For compatibility, every tool also accepts `outputFormat="json"` to force JSON. It takes precedence when both arguments are supplied.
|
|
187
|
+
|
|
186
188
|
- **`markdown`** (default) — readable tables for presenting to a person. Totals and cursors
|
|
187
189
|
are in the footer line.
|
|
188
190
|
- **`json`** — the same data as typed JSON, returned as MCP `structuredContent` (and
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,17 @@ function camelCaseKeys(args) {
|
|
|
19
19
|
}
|
|
20
20
|
const config = loadConfig();
|
|
21
21
|
const client = new NinjaClient(config);
|
|
22
|
+
function publicInputSchema(schema) {
|
|
23
|
+
const publicShape = {};
|
|
24
|
+
for (const [key, value] of Object.entries(schema.shape)) {
|
|
25
|
+
publicShape[key] = value.optional();
|
|
26
|
+
const snake = key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
27
|
+
if (snake !== key)
|
|
28
|
+
publicShape[snake] = value.optional();
|
|
29
|
+
}
|
|
30
|
+
publicShape.outputFormat = z.enum(['json']).optional().describe('Force valid JSON output for this call.');
|
|
31
|
+
return z.object(publicShape).strict();
|
|
32
|
+
}
|
|
22
33
|
const createConfiguredServer = () => {
|
|
23
34
|
const server = new McpServer({ name: packageName, version: packageVersion }, {
|
|
24
35
|
instructions: `
|
|
@@ -66,22 +77,26 @@ ninja_list_devices with organizationId (and optionally deviceClass or online).
|
|
|
66
77
|
- Tool arguments are camelCase (deviceId); snake_case (device_id) is also accepted.
|
|
67
78
|
|
|
68
79
|
## Output format
|
|
69
|
-
- Every tool takes
|
|
80
|
+
- Every tool takes optional outputFormat="json" to force valid JSON. The legacy format="markdown" | "json" remains supported; when both are supplied, outputFormat takes precedence. Omit both to use NINJAONE_FORMAT.
|
|
70
81
|
|
|
71
82
|
## Datetime
|
|
72
83
|
- All NinjaOne timestamps are UTC (ISO or epoch). The server renders them in NINJAONE_DATETIMEFORMAT (default: system local). Present values as-is.
|
|
73
84
|
`.trim(),
|
|
74
85
|
});
|
|
75
86
|
for (const tool of allTools) {
|
|
76
|
-
|
|
77
|
-
? camelCaseKeys(value)
|
|
78
|
-
: value, tool.inputSchema.strict());
|
|
79
|
-
server.registerTool(tool.name, { description: tool.description, inputSchema }, async ({ format: requested, ...args }) => {
|
|
87
|
+
server.registerTool(tool.name, { description: tool.description, inputSchema: publicInputSchema(tool.inputSchema) }, async (rawArgs) => {
|
|
80
88
|
try {
|
|
81
|
-
const
|
|
89
|
+
const normalized = camelCaseKeys(rawArgs);
|
|
90
|
+
const { format: requested, outputFormat, ...unvalidatedArgs } = normalized;
|
|
91
|
+
const args = tool.inputSchema.strict().parse(unvalidatedArgs);
|
|
92
|
+
const format = outputFormat === 'json'
|
|
93
|
+
? 'json'
|
|
94
|
+
: requested === 'json' || requested === 'markdown'
|
|
95
|
+
? requested
|
|
96
|
+
: config.format;
|
|
82
97
|
const result = await tool.handler(client, args);
|
|
83
98
|
if (typeof result === 'string')
|
|
84
|
-
return { content: [{ type: 'text', text: result }] };
|
|
99
|
+
return { content: [{ type: 'text', text: format === 'json' ? JSON.stringify(result) : result }] };
|
|
85
100
|
if (format === 'json') {
|
|
86
101
|
return { content: [{ type: 'text', text: JSON.stringify(result.data) }], structuredContent: result.data };
|
|
87
102
|
}
|
package/dist/tools/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export const formatArg = z
|
|
|
12
12
|
.enum(['markdown', 'json'])
|
|
13
13
|
.optional()
|
|
14
14
|
.describe('Output format. "markdown" = readable tables for presenting to a person. "json" = the same data as typed JSON (structuredContent) — raw numbers/booleans, ISO-8601 UTC timestamps, and totals/cursors as fields (total, nextCursor / nextAfter, hasMore); best for paging through results or computing over them. Defaults to the server setting NINJAONE_FORMAT (markdown unless configured).');
|
|
15
|
+
const outputFormatArg = z.enum(['json']).optional().describe('Return valid JSON text. This is an alias for format="json".');
|
|
15
16
|
const base = [
|
|
16
17
|
...authTools,
|
|
17
18
|
...organizationTools,
|
|
@@ -23,6 +24,6 @@ const base = [
|
|
|
23
24
|
];
|
|
24
25
|
export const allTools = base.map((t) => ({
|
|
25
26
|
...t,
|
|
26
|
-
inputSchema: t.inputSchema.extend({ format: formatArg }),
|
|
27
|
+
inputSchema: t.inputSchema.extend({ format: formatArg, outputFormat: outputFormatArg }),
|
|
27
28
|
}));
|
|
28
29
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED