@atlassian/mcp-compressor

中文文档
0.40.0发布于 2026/10/31Apache-2.0TypeScriptES Module近 30 天下载 2660

TypeScript MCP server wrapper for reducing tokens consumed by MCP tools.

原始使用文档
文档目录25 节
  1. How it works
  2. Compression levels
  3. Three modes
  4. Installation
  5. STDIO MCP proxy
  6. Compressed mode (default)
  7. CLI mode
  8. Bash mode
  9. OAuth
  10. In-process usage (CompressorClient)
  11. Compressed mode
  12. CLI mode
  13. Bash mode
  14. Bash mode with a pre-existing Bash instance
  15. Server configuration formats
  16. Escape hatches
  17. Rust-backed native client
  18. Development
  19. Setup
  20. Commands
  21. Packaging smoke test
  22. Toolchain
  23. Publishing
  24. Sub-path exports
  25. Summary-only CLI discovery

@atlassian/mcp-compressor (TypeScript)

A TypeScript MCP proxy that wraps one or more MCP servers and reduces the token footprint exposed to LLMs.

How it works

mcp-compressor connects to upstream MCP servers (via stdio, HTTP, or SSE) and replaces their full tool catalogs with a compressed interface. Instead of exposing every tool individually, it provides:

  • get_tool_schema(tool_name) — returns the full schema for a specific tool on demand
  • invoke_tool(tool_name, tool_input) — calls an upstream tool
  • list_tools() — lists available tool names (only at max compression)

This dramatically reduces the token cost of tool descriptions in LLM context windows while preserving full tool functionality.

Compression levels

LevelWhat the LLM sees
lowTool name, parameters, and full description
medium (default)Tool name, parameters, and first sentence of description
highTool name and parameters only
maxTool names only (requires list_tools call to discover)

Three modes

ModeTools exposedHow the LLM invokes tools
Compressed (default)get_tool_schema + invoke_toolVia MCP tool calls
CLIPer-server _help toolsVia bash CLI commands (bridge + generated scripts)
BashPer-server _help tools + bash toolVia a sandboxed just-bash shell

Installation

npm install @atlassian/mcp-compressor

# Optional: for bash mode
npm install just-bash

STDIO MCP proxy

The simplest way to use mcp-compressor is as a CLI that wraps another MCP server and exposes a compressed proxy over stdio.

Compressed mode (default)

# Wrap a remote MCP server
bun cli -- https://mcp.atlassian.com/v1/mcp

# Wrap a local stdio server
bun cli --server-name filesystem -- npx -y @modelcontextprotocol/server-filesystem .

# With options
bun cli -c high --server-name atlassian --toonify -- https://mcp.atlassian.com/v1/mcp

# Multi-server via MCP config JSON
bun cli -- '{"mcpServers":{"jira":{"url":"https://jira-mcp.example.com"},"confluence":{"command":"node","args":["confluence-server.js"]}}}'

CLI mode

CLI mode generates shell scripts for each backend server so the LLM (or user) can invoke tools directly from bash. The MCP proxy exposes per-server help tools that describe the available commands.

# Start CLI mode
bun cli --cli-mode --server-name atlassian -- https://mcp.atlassian.com/v1/mcp

# In another terminal, use the generated CLI:
atlassian --help
atlassian search-confluence --query oauth
atlassian get-jira-issue --issue-url https://jira.example.com/browse/PROJ-123

Tool output is returned verbatim in CLI mode. Pass --toonify to opt in to TOON conversion of JSON, CSV and YAML results.

Bash mode

Bash mode registers all backend tools as custom commands in a sandboxed just-bash shell, then exposes a single bash MCP tool plus per-server help tools. The LLM can run MCP tools alongside standard Unix utilities, including pipes and composition.

bun cli --just-bash --server-name atlassian -- https://mcp.atlassian.com/v1/mcp

The LLM then sees:

  • bash — execute commands in the sandboxed shell
  • atlassian_help — lists available atlassian subcommands

Example commands the LLM can run via the bash tool:

atlassian search-issues --jql "project=PROJ" | jq '.issues[].key'
atlassian get-page --page-id 12345 | grep "summary"
echo "hello" | grep hello

OAuth

For remote OAuth backends, the CLI handles the authorization flow automatically — it opens the browser, completes the code exchange, and persists tokens for future sessions.

# Clear cached OAuth state
bun cli clear-oauth https://mcp.atlassian.com/v1/mcp

In-process usage (CompressorClient)

For TypeScript applications and agent frameworks, CompressorClient provides a single unified interface for all modes — no subprocess needed.

Compressed mode

import { CompressorClient } from '@atlassian/mcp-compressor';

const client = new CompressorClient({
  servers: {
    jira: { url: 'https://jira-mcp.example.com' },
    confluence: { command: 'node', args: ['confluence-server.js'] },
  },
  compressionLevel: 'medium',
});

await client.connect();
const tools = await client.getTools();
// → { jira_get_tool_schema, jira_invoke_tool, confluence_get_tool_schema, confluence_invoke_tool }

// Use with any AI SDK-compatible framework
const schema = await tools.jira_get_tool_schema.execute({ tool_name: 'search_issues' });
const result = await tools.jira_invoke_tool.execute({
  tool_name: 'search_issues',
  tool_input: { query: 'oauth' },
});

await client.close();

CLI mode

const client = new CompressorClient({
  servers: { atlassian: { url: 'https://mcp.atlassian.com/v1/mcp' } },
  mode: 'cli',
});

await client.connect();
const tools = await client.getTools();
// → { atlassian_help }
// Side effect: HTTP bridge started, shell script generated

// client.scripts has info about generated scripts
for (const script of client.scripts) {
  console.log(`Run '${script.cliName} --help' for usage`);
}

await client.close();

Bash mode

const client = new CompressorClient({
  servers: {
    jira: { url: 'https://jira-mcp.example.com' },
    confluence: { command: 'node', args: ['confluence-server.js'] },
  },
  mode: 'bash',
});

await client.connect();
const tools = await client.getTools();
// → { bash, jira_help, confluence_help }

// Execute commands via the bash tool
const result = await tools.bash.execute({ command: 'jira search-issues --query oauth' });

// Access the Bash instance directly
const execResult = await client.bash!.exec('jira search-issues --query test | jq .issues');

await client.close();

Bash mode with a pre-existing Bash instance

If your application already has a Bash instance (e.g. with its own custom commands), you can inject it:

import { Bash } from 'just-bash';

const existingBash = new Bash({ customCommands: [myCustomCommand] });

const client = new CompressorClient({
  servers: { atlassian: { url: 'https://mcp.atlassian.com/v1/mcp' } },
  mode: 'bash',
  bash: { bash: existingBash },
});

await client.connect();
const tools = await client.getTools();
// → { bash, atlassian_help }
// MCP commands are registered into existingBash via registerCommand()

Server configuration formats

CompressorClient accepts several formats for the servers option:

// Named servers map (recommended for multi-server)
new CompressorClient({
  servers: {
    jira: { url: 'https://jira-mcp.example.com' },
    filesystem: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem', '.'] },
  },
});

// Single BackendConfig
new CompressorClient({
  servers: { type: 'http', url: 'https://mcp.example.com' },
});

// URL string
new CompressorClient({
  servers: 'https://mcp.example.com',
});

// MCP config JSON string
new CompressorClient({
  servers: '{"mcpServers":{"jira":{"url":"https://jira-mcp.example.com"}}}',
});

Escape hatches

// Access individual runtimes
const jiraRuntime = client.getRuntime('jira');
await jiraRuntime.invokeTool('search_issues', { query: 'bug' });

// List all server names
console.log(client.serverNames); // ['jira', 'confluence']

// Access all runtimes
for (const runtime of client.runtimes) {
  console.log(runtime.serverName, await runtime.listToolNames());
}

Rust-backed native client

The Rust-core migration exposes a high-level native client for applications that want to start compressed MCP proxy sessions in-process, without spawning the mcp-compressor CLI as a stdio subprocess.

import { CompressorClient } from "@atlassian/mcp-compressor";

const client = new CompressorClient({
  servers: {
    atlassian: {
      url: "https://mcp.atlassian.com/v1/mcp",
      headers: {
        Authorization: `Basic ${token}`,
      },
    },
  },
  compressionLevel: "medium",
  includeTools: ["getConfluencePage", "updateConfluencePage"],
  toonify: true,
});

const proxy = await client.connect();
try {
  console.log(proxy.tools.map((tool) => tool.name));
  const output = await proxy.invoke("getAccessibleAtlassianResources", {}, { server: "atlassian" });
  console.log(output);
} finally {
  await client.close();
}

The package root now exposes the Rust-backed CompressorClient as the primary SDK surface on the migration trunk.

Just Bash mode lets language hosts register backend MCP tools as Just Bash commands:

const proxy = await new CompressorClient({ servers, mode: "bash" }).connect();
try {
  for (const provider of proxy.justBashProviders) {
    console.log(provider.providerName, provider.helpToolName);
    for (const command of provider.tools) {
      console.log(command.commandName, command.backendToolName, command.invokeToolName);
    }
  }
} finally {
  proxy.close();
}

Connected proxies can also write shell, Python, or TypeScript clients that call the live Rust proxy:

const proxy = await client.connect();
try {
  proxy.writeClient("cli", "./bin", { name: "atlassian" });
  proxy.writeClient("python", "./generated-py", { name: "atlassian" });
  proxy.writeClient("typescript", "./generated-ts", { name: "atlassian" });
} finally {
  proxy.close();
}

Development

Setup

cd typescript
bun install

Commands

bun run test          # run tests with vitest
bun run check         # lint + format + typecheck + test
bun run lint          # lint with oxlint
bun run format        # format with oxfmt
bun run format:check  # check formatting
bun run build         # compile to dist/
bun cli               # run the CLI directly from source

Packaging smoke test

Build and test the npm package from a clean temporary project:

bun install
bun run build
bun run build:native
bun pm pack --filename /tmp/mcp-compressor-ts-package.tgz
mkdir -p /tmp/mcp-compressor-ts-package-test
cd /tmp/mcp-compressor-ts-package-test
bun init -y
bun add --registry https://registry.npmjs.org /tmp/mcp-compressor-ts-package.tgz
bun --eval 'import { CompressorClient, compressToolListing } from "@atlassian/mcp-compressor"; console.log(typeof CompressorClient, compressToolListing("high", [{ name: "echo", inputSchema: { type: "object", properties: {} } }]))'

CI runs the same package smoke test and uploads the packed tarball as an artifact.

Toolchain

ToolPurpose
BunPackage manager and runtime
TypeScriptType checking
VitestTest runner
oxlintLinter
oxfmtFormatter
CommanderCLI argument parsing

Publishing

To publish from source, ensure you have active credentials for Artifactory, then run:

bun run build
npm version <PUBLISH_VERSION> --no-git-tag-version
npm publish

Published as @atlassian/mcp-compressor via Atlassian Artifactory → npmJS.

npm install @atlassian/mcp-compressor

Sub-path exports

@atlassian/mcp-compressor ships a small set of sub-path exports for consumers that only need the lightweight pieces. Importing from these sub-paths avoids loading fastmcp, the MCP SDK, and the rest of the runtime, which can add hundreds of ms of cold-import cost.

Sub-pathContentsWhen to use
@atlassian/mcp-compressorFull runtime (CompressorRuntime, CompressorServer, BackendClient, FastMCP, ...)Building / hosting a compressor proxy.
@atlassian/mcp-compressor/bashThe just-bash transform helpersBash-tool transformation.
@atlassian/mcp-compressor/configinterpolateString, interpolateRecord, parseServerConfigJsonPure config parsing / ${ENV} interpolation in tooling.
@atlassian/mcp-compressor/errorsInvalidConfigurationError and friendsError type checks without the runtime.
@atlassian/mcp-compressor/typesBackendConfig, CompressionLevel, CommonProxyOptions, ...Type-only consumers.
// heavy: pulls fastmcp + MCP SDK
import { CompressorRuntime } from "@atlassian/mcp-compressor";

// light: ~zero runtime deps
import { interpolateString } from "@atlassian/mcp-compressor/config";

Summary-only CLI discovery

Host-owned CLI and Just Bash transforms can retain their complete command surface while advertising only a short toolset description to the model:

const transformed = await transformToolsForCliMode(tools, {
  serverName: "records",
  helpMode: "summary",
  helpSummary: "Search, read and manage enterprise records.",
});

helpMode defaults to "full" (the existing subcommand catalog). With "summary", the model-visible records_help description omits that catalog. helpSummary is optional caller-authored capability text, not an inferred or permission-checked capability promise. Missing/blank summaries fall back to a generic CLI description. Both records --help and calling records_help still return full discovery; records <subcommand> --help and all invocations are unchanged. The same options are available on planToolsForJustBash / transformToolsForJustBash.

Hosts using buildHostTransformPlan directly can pass the same options. Use plan.helpDescription for the model-visible description and plan.helpText for the help tool's execution result. Do not use the shortened description as the on-demand help response. Artifacts, command registrations, auth and schemas do not change. Python/TypeScript code-generation transforms do not support summary mode. This is independent of MCP proxy compressionLevel; it does not add a new standalone CLI flag or change the high-level CompressorClient session modes.

版本与发布记录

@atlassian/mcp-compressor 共发布 58 个版本,首次发布于 2026/05/13;过去 12 个月发布了 58 个版本。

版本发布日期距今
0.40.0latest2026/10/317 天前
0.39.02026/10/308 天前
0.38.22026/10/2612 天前
0.38.12026/10/2513 天前
0.38.02026/10/1524 天前
0.37.02026/10/1424 天前

其他发布通道:next → 0.31.0-alpha.1。

关于 @atlassian/mcp-compressor 的常见问题

@atlassian/mcp-compressor 是什么?

TypeScript MCP server wrapper for reducing tokens consumed by MCP tools.

如何安装 @atlassian/mcp-compressor?

在项目目录运行 npm install @atlassian/mcp-compressor,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 mcp-compressor、atlassian-mcp-compressor,可以用 npx mcp-compressor 直接运行。

@atlassian/mcp-compressor 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@atlassian/mcp-compressor 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@atlassian/mcp-compressor 可以商用吗?

@atlassian/mcp-compressor 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@atlassian/mcp-compressor 的下载量有多少?

根据 npm 官方下载统计,@atlassian/mcp-compressor 在 2026/10/07 – 2026/11/05 这 30 天内被下载 2,660 次,日均约 89 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@atlassian/mcp-compressor 还在维护吗?

最新版本 0.40.0 发布于 2026/10/31(7 天前);至今共发布 58 个版本,其中过去 12 个月发布了 58 个;首次发布于 2026/05/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。