@atlassian/mcp-compressor 0.19.8 → 0.20.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.
@@ -4,4 +4,4 @@ export interface LocalToolBridge {
4
4
  token: string;
5
5
  close(): void;
6
6
  }
7
- export declare function startLocalToolBridge(tools: Record<string, ExecutableTool>): Promise<LocalToolBridge>;
7
+ export declare function startLocalToolBridge(tools: Record<string, ExecutableTool<unknown>>): Promise<LocalToolBridge>;
package/dist/native.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface NativeToolSpec {
6
6
  export interface NativeCore {
7
7
  compressToolListingJson(level: string, toolsJson: string): string;
8
8
  formatToolSchemaResponseJson(toolJson: string): string;
9
+ maybeToonifyOutputJson(output: string): string;
9
10
  parseToolArgvJson(toolJson: string, argvJson: string): string;
10
11
  generateClientArtifactsJson(kind: string, configJson: string): string;
11
12
  generateClientArtifactFilesJson(kind: string, configJson: string): string;
@@ -6,6 +6,7 @@ export interface ToolSpec {
6
6
  }
7
7
  export declare function compressToolListing(level: string, tools: ToolSpec[]): string;
8
8
  export declare function formatToolSchemaResponse(tool: ToolSpec): string;
9
+ export declare function maybeToonifyOutput(output: string): string;
9
10
  export declare function parseToolArgv(tool: ToolSpec, argv: string[]): Record<string, unknown>;
10
11
  export type ClientArtifactKind = "cli" | "python" | "typescript";
11
12
  export interface ClientGeneratorConfig {
package/dist/rust_core.js CHANGED
@@ -15,6 +15,9 @@ export function compressToolListing(level, tools) {
15
15
  export function formatToolSchemaResponse(tool) {
16
16
  return loadNativeCore().formatToolSchemaResponseJson(stringify(toNativeTool(tool)));
17
17
  }
18
+ export function maybeToonifyOutput(output) {
19
+ return loadNativeCore().maybeToonifyOutputJson(output);
20
+ }
18
21
  export function parseToolArgv(tool, argv) {
19
22
  return JSON.parse(loadNativeCore().parseToolArgvJson(stringify(toNativeTool(tool)), stringify(argv)));
20
23
  }
@@ -1,7 +1,7 @@
1
1
  import type { ExecutableTool } from "./adapters.js";
2
2
  import type { ToolSpec } from "./rust_core.js";
3
- export declare function executableToolToSpec(name: string, tool: ExecutableTool): ToolSpec;
4
- export declare function executableToolsToSpecs(tools: Record<string, ExecutableTool>): ToolSpec[];
3
+ export declare function executableToolToSpec(name: string, tool: ExecutableTool<unknown>): ToolSpec;
4
+ export declare function executableToolsToSpecs(tools: Record<string, ExecutableTool<unknown>>): ToolSpec[];
5
5
  export declare function normalizeServerName(name: string | undefined): string;
6
6
  export declare function stringifyToolResult(value: unknown): string;
7
7
  export declare function normalizeStructuredArgValues(schema: Record<string, unknown>, input: Record<string, unknown>): Record<string, unknown>;
@@ -23,6 +23,6 @@ export interface GeneratedToolTransformResult extends GeneratedClientArtifactsRe
23
23
  tools: Record<string, ExecutableTool>;
24
24
  close(): void;
25
25
  }
26
- export declare function transformToolsForJustBash(tools: Record<string, ExecutableTool>, options: TransformToolsForJustBashOptions): JustBashTransformResult;
27
- export declare function transformToolsForCodeMode(tools: Record<string, ExecutableTool>, options: TransformToolsForCodeModeOptions): Promise<GeneratedToolTransformResult>;
28
- export declare function transformToolsForCliMode(tools: Record<string, ExecutableTool>, options?: TransformToolsForCliModeOptions): Promise<GeneratedToolTransformResult>;
26
+ export declare function transformToolsForJustBash(tools: Record<string, ExecutableTool<unknown>>, options: TransformToolsForJustBashOptions): JustBashTransformResult;
27
+ export declare function transformToolsForCodeMode(tools: Record<string, ExecutableTool<unknown>>, options: TransformToolsForCodeModeOptions): Promise<GeneratedToolTransformResult>;
28
+ export declare function transformToolsForCliMode(tools: Record<string, ExecutableTool<unknown>>, options?: TransformToolsForCliModeOptions): Promise<GeneratedToolTransformResult>;
@@ -1,18 +1,19 @@
1
1
  import { generateClientFromBridge, } from "./generated_clients.js";
2
2
  import { createJustBashCommandRegistrations, installJustBashRegistrations, } from "./just_bash_commands.js";
3
3
  import { startLocalToolBridge } from "./local_tool_bridge.js";
4
+ import { maybeToonifyOutput } from "./rust_core.js";
4
5
  import { executableToolToSpec, executableToolsToSpecs, normalizeServerName, stringifyToolResult, } from "./tool_specs.js";
5
6
  export function transformToolsForJustBash(tools, options) {
6
7
  const serverName = normalizeServerName(options.serverName);
7
8
  const registrations = createJustBashCommandRegistrations(Object.entries(tools).map(([name, tool]) => justBashSource(serverName, name, tool)));
8
9
  installJustBashRegistrations(options.bash, registrations);
10
+ const helpDescription = justBashHelpDescription(serverName, registrations);
9
11
  return {
10
12
  registrations,
11
13
  tools: helpTools({
12
14
  serverName,
13
- mode: "Just Bash",
14
- summary: `Backend tools have been installed as Just Bash commands for ${serverName}.`,
15
- lines: registrations.map((registration) => `- ${registration.commandName}`),
15
+ description: helpDescription,
16
+ output: helpDescription,
16
17
  }),
17
18
  };
18
19
  }
@@ -22,16 +23,16 @@ export async function transformToolsForCodeMode(tools, options) {
22
23
  kind: options.language,
23
24
  serverName,
24
25
  outputDir: options.outputDir ?? "./dist",
25
- modeLabel: options.language === "python" ? "Python Code Mode" : "TypeScript Code Mode",
26
26
  });
27
27
  }
28
28
  export async function transformToolsForCliMode(tools, options = {}) {
29
29
  const serverName = normalizeServerName(options.serverName);
30
+ const output = options.outputDir === undefined ? defaultCliOutputDir() : { outputDir: options.outputDir };
30
31
  return generatedTransform(tools, {
31
32
  kind: "cli",
32
33
  serverName,
33
- outputDir: options.outputDir ?? "./dist",
34
- modeLabel: "CLI Mode",
34
+ outputDir: output.outputDir,
35
+ commandName: serverName,
35
36
  });
36
37
  }
37
38
  function justBashSource(serverName, name, tool) {
@@ -41,7 +42,7 @@ function justBashSource(serverName, name, tool) {
41
42
  backendToolName: name,
42
43
  helpToolName: `${serverName}_help`,
43
44
  tool: executableToolToSpec(name, tool),
44
- invoke: async (input) => stringifyToolResult(await tool.execute(input)),
45
+ invoke: async (input) => maybeToonifyOutput(stringifyToolResult(await tool.execute(input))),
45
46
  };
46
47
  }
47
48
  async function generatedTransform(tools, options) {
@@ -54,13 +55,19 @@ async function generatedTransform(tools, options) {
54
55
  tools: executableToolsToSpecs(tools),
55
56
  outputDir: options.outputDir,
56
57
  });
58
+ const helpDescription = generatedHelpDescription({
59
+ kind: options.kind,
60
+ serverName: options.serverName,
61
+ outputDir: options.outputDir,
62
+ files: Object.keys(generated.files),
63
+ commandName: options.commandName,
64
+ });
57
65
  return {
58
66
  ...generated,
59
67
  tools: helpTools({
60
68
  serverName: options.serverName,
61
- mode: options.modeLabel,
62
- summary: `${options.modeLabel} generated client files for ${options.serverName}.`,
63
- lines: Object.keys(generated.files).map((file) => `- ${options.outputDir}/${file}`),
69
+ description: helpDescription,
70
+ output: helpDescription,
64
71
  }),
65
72
  close: () => bridge.close(),
66
73
  };
@@ -70,9 +77,71 @@ function helpTools(options) {
70
77
  return {
71
78
  [name]: {
72
79
  name,
73
- description: `Show help for ${options.mode} tools generated from ${options.serverName}.`,
80
+ description: options.description,
74
81
  inputSchema: { type: "object", properties: {} },
75
- execute: async () => [options.summary, "", ...options.lines].join("\n"),
82
+ execute: async () => options.output,
76
83
  },
77
84
  };
78
85
  }
86
+ function generatedHelpDescription(options) {
87
+ if (options.kind === "cli") {
88
+ const command = options.commandName ?? `${options.outputDir}/${options.serverName}`;
89
+ return cliHelpDescription(command, options.serverName);
90
+ }
91
+ const language = options.kind === "python" ? "Python" : "TypeScript";
92
+ const moduleName = options.kind === "python" ? `${options.serverName}.py` : `${options.serverName}.ts`;
93
+ return [
94
+ `Functionality associated with the ${options.serverName} toolset is provided via generated ${language} code. Do not call this tool - import and use the generated code instead.`,
95
+ `${options.serverName} - the ${options.serverName} toolset`,
96
+ "",
97
+ `Generated files are available in ${options.outputDir}.`,
98
+ `Primary module: ${options.outputDir}/${moduleName}`,
99
+ "",
100
+ "When relevant, outputs from generated clients will prefer using the TOON format for more efficient representation of data.",
101
+ "",
102
+ "Available generated files:",
103
+ ...options.files.map((file) => ` - ${options.outputDir}/${file}`),
104
+ ].join("\n");
105
+ }
106
+ function cliHelpDescription(command, cliName) {
107
+ return [
108
+ `Functionality associated with the ${cliName} toolset is provided via the \`${command}\` CLI. Do not call this tool - use the CLI instead.`,
109
+ `${cliName} - the ${cliName} toolset`,
110
+ "",
111
+ "When relevant, outputs from this CLI will prefer using the TOON format for more efficient representation of data.",
112
+ "",
113
+ "USAGE:",
114
+ ` ${command} <subcommand> [options]`,
115
+ "",
116
+ "SUBCOMMANDS:",
117
+ ` Run '${command} --help' in the shell for available subcommands.`,
118
+ "",
119
+ `Run '${command} --help' in the shell for usage.`,
120
+ `Run '${command} <subcommand> --help' for per-command help.`,
121
+ `Run '${command} <subcommand> [options]' to invoke a tool.`,
122
+ ].join("\n");
123
+ }
124
+ function justBashHelpDescription(serverName, registrations) {
125
+ return [
126
+ `Functionality associated with the ${serverName} toolset is provided via bash commands. Do not call this tool - use the bash commands instead.`,
127
+ `${serverName} - the ${serverName} toolset`,
128
+ "",
129
+ "When relevant, outputs from these commands will prefer using the TOON format for more efficient representation of data.",
130
+ "",
131
+ "COMMANDS:",
132
+ ...registrations.map((registration) => ` ${registration.commandName}`),
133
+ "",
134
+ "Run these commands with the bash tool.",
135
+ ].join("\n");
136
+ }
137
+ function defaultCliOutputDir() {
138
+ const envDir = process.env.MCP_COMPRESSOR_CLI_OUTPUT_DIR;
139
+ if (envDir !== undefined && envDir.length > 0) {
140
+ return { outputDir: envDir };
141
+ }
142
+ const home = process.env.HOME;
143
+ if (home !== undefined && home.length > 0) {
144
+ return { outputDir: `${home}/.local/bin` };
145
+ }
146
+ return { outputDir: "./dist" };
147
+ }
package/native/index.d.ts CHANGED
@@ -18,6 +18,8 @@ export declare function generateClientArtifactsJson(kind: string, configJson: st
18
18
 
19
19
  export declare function listOauthCredentialsJson(): string
20
20
 
21
+ export declare function maybeToonifyOutputJson(output: string): string
22
+
21
23
  export declare function normalizeServersJson(serversJson: string): string
22
24
 
23
25
  export declare function parseMcpConfigJson(configJson: string): string
Binary file
Binary file
package/native/index.js CHANGED
@@ -583,6 +583,7 @@ module.exports.formatToolSchemaResponseJson = nativeBinding.formatToolSchemaResp
583
583
  module.exports.generateClientArtifactFilesJson = nativeBinding.generateClientArtifactFilesJson
584
584
  module.exports.generateClientArtifactsJson = nativeBinding.generateClientArtifactsJson
585
585
  module.exports.listOauthCredentialsJson = nativeBinding.listOauthCredentialsJson
586
+ module.exports.maybeToonifyOutputJson = nativeBinding.maybeToonifyOutputJson
586
587
  module.exports.normalizeServersJson = nativeBinding.normalizeServersJson
587
588
  module.exports.parseMcpConfigJson = nativeBinding.parseMcpConfigJson
588
589
  module.exports.parseToolArgvJson = nativeBinding.parseToolArgvJson
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlassian/mcp-compressor",
3
- "version": "0.19.8",
3
+ "version": "0.20.0",
4
4
  "description": "TypeScript MCP server wrapper for reducing tokens consumed by MCP tools.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/atlassian-labs/mcp-compressor",