cxpak 标志

cxpak

组织
Barnett-Studios

Spends CPU cycles so you don't spend tokens. The LLM gets a briefing packet instead of a flashlight in a dark room.

发布者Barnett-Studios
代码仓库cxpak
语言Rust
复刻数
2
星标数
27
可用工具
0
传输类型stdio
分类
许可协议Apache-2.0
链接
  • 将工具接入 AI 工作流

    cxpak 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 27 个 Star 和 2 个 Fork。

cxpak

Rust CI Crates.io Downloads License

Context plane · Active — under development; the surface still moves. See the component map for how this fits the rest.

Spends CPU cycles so you don't spend tokens.

cxpak indexes your codebase using tree-sitter across 43 languages, builds a typed dependency graph, and produces token-budgeted context bundles that give LLMs a briefing packet instead of a flashlight in a dark room. It understands your code's architecture, conventions, risk profile, and data layer -- then packs exactly what the LLM needs, nothing more.

What it looks like

cxpak visual renders a self-contained single-page dashboard -- three modes, inlined D3, zero external assets, works offline. Nineteen built-in colour palettes and a Cmd+K command palette over every file, symbol, and view. Every number on the page traces to a real computation; click any risk to see its exact derivation.

Install

bash
brew tap Barnett-Studios/tap && brew install cxpak   # macOS/Linux
cargo install cxpak                                   # any platform, incl. Windows

On Windows, cargo install cxpak works, or download the prebuilt cxpak-x86_64-pc-windows-msvc.zip from the latest release.

Docker

Docker is a first-class deployment option — useful anywhere you want a reproducible, isolated install without managing a Rust toolchain: CI pipelines, sandboxed servers, Windows machines, or air-gapped environments.

Official image (recommended)

Multi-arch (amd64 / arm64) images are published to GitHub Container Registry on every release — no build, no Rust toolchain, no source checkout:

bash
docker run --rm -v "$(pwd):/repo" ghcr.io/barnett-studios/cxpak overview .

Pin a tag or an immutable digest for reproducible deploys:

bash
docker run --rm -v "$(pwd):/repo" ghcr.io/barnett-studios/cxpak:3.1.0 overview .
docker run --rm -v "$(pwd):/repo" ghcr.io/barnett-studios/cxpak@sha256:<digest> overview .

Images are signed with cosign (keyless) and carry SBOM + build-provenance attestations. Verify before deploying:

bash
cosign verify ghcr.io/barnett-studios/cxpak:3.1.0 \
  --certificate-identity-regexp '^https://github.com/Barnett-Studios/cxpak/' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com

From source

bash
docker build -t cxpak .

Builds the full default feature set from your local checkout. First build is slow (candle ML deps); subsequent builds reuse a cached dependency layer.

Self-hosted / air-gapped

Dockerfile.standalone fetches the pre-built release binary, verifies its SHA-256 checksum, and packages it into an ubuntu:24.04 runtime — no source checkout or Rust toolchain required. All base images and the downloaded binary are digest-pinned for reproducible builds.

All three build-args are required — the build fails immediately if any is omitted, so you can never accidentally produce a stale or mismatched image. Checksums are available on the releases page.

bash
# SHA-256 values are per-release — copy the two for VERSION from the releases page.
docker build -f Dockerfile.standalone \
  --build-arg VERSION=3.1.0 \
  --build-arg SHA256_AMD64=<cxpak-x86_64-unknown-linux-gnu checksum> \
  --build-arg SHA256_ARM64=<cxpak-aarch64-unknown-linux-gnu checksum> \
  -t cxpak:3.1.0 .

Usage

The container runs as a non-root user; the embedding model weights (~30 MB, downloaded on first use) live under /home/cxpak/.cxpak — mount a named volume there to persist them across runs.

macOS / Linux:

bash
# One-shot command
docker run --rm -v "$(pwd):/repo" ghcr.io/barnett-studios/cxpak overview .

# HTTP server (--bind 0.0.0.0 required to reach the container from the host;
# --token is mandatory when binding to a non-loopback address)
docker run -d -p 3000:3000 \
  -v "$(pwd):/repo" \
  -v cxpak-models:/home/cxpak/.cxpak \
  ghcr.io/barnett-studios/cxpak serve --bind 0.0.0.0 --token mysecret .

# MCP — stdio only, one repo per instance (see note below)
docker run --rm -i -v "$(pwd):/repo" ghcr.io/barnett-studios/cxpak serve --mcp .

Windows (PowerShell):

powershell
# One-shot command
docker run --rm -v ${PWD}:/repo ghcr.io/barnett-studios/cxpak overview .

# HTTP server
docker run -d -p 3000:3000 `
  -v ${PWD}:/repo `
  -v cxpak-models:/home/cxpak/.cxpak `
  ghcr.io/barnett-studios/cxpak serve --bind 0.0.0.0 --token mysecret .

# Verify (use curl.exe — PowerShell's curl alias does not work here)
curl.exe http://localhost:3000/health

# MCP — stdio only, one repo per instance (see note below)
docker run --rm -i -v ${PWD}:/repo ghcr.io/barnett-studios/cxpak serve --mcp .

Replace mysecret with any non-empty secret of your choice. /health is open (GET) as a liveness probe; every other endpoint requires the bearer token when one is set (with no --token, on a loopback bind, all routes are open):

bash
curl http://localhost:3000/health                                        # no auth required
curl -X POST -H "Authorization: Bearer mysecret" http://localhost:3000/v1/conventions

HTTP vs MCP: These are two separate transports — you cannot use the HTTP server as an MCP endpoint.

MCP scope: Each MCP instance indexes exactly one repository — the path passed at startup (. in the examples above, which maps to the mounted /repo). To serve multiple repos simultaneously, run one container per repo and register each in your MCP client config. The HTTP server has the same single-repo scope.

Quick start

bash
# See your codebase the way an LLM should
cxpak overview .

# Trace a symbol through the dependency graph
cxpak trace "handle_request" .

# Generate an interactive dashboard
cxpak visual --visual-type dashboard .

# Get a guided reading order for onboarding
cxpak onboard .

Use with AI tools

Claude Code / Cursor (MCP)

Add to .mcp.json in your project root:

json
{
  "mcpServers": {
    "cxpak": {
      "command": "cxpak",
      "args": ["serve", "--mcp", "."]
    }
  }
}

Your AI tool gets five intent-parameterized tools; each selects a capability via a required op argument. cxpak_context (op: "context") is the main entry point -- one call, optimal context:

Intent toolCapabilities (via op)
cxpak_contextcontext, retrieval, search, overview, stats, briefing, pack_context, context_for_task
cxpak_graphgraph (nodes/node/neighbors/path/subgraph), trace, blast_radius, call_graph, dead_code, api_surface, data_flow, cross_lang, predict
cxpak_datadata (indexed / live schema)
cxpak_reviewreview, diff, verify
cxpak_insighthealth, risks, architecture, conventions, security_surface, drift, visual, onboard

The v2.x per-tool names (cxpak_auto_context, cxpak_health, ...) remain callable as deprecated aliases; tools/list does not advertise them, so a client that builds its callable set from the advertised surface will not find them. No removal release is set. See docs/MIGRATION-3.0.md.

On large repositories, cxpak serve --mcp answers the MCP initialize handshake immediately and builds the index in the background -- fixing the startup timeout. Tool calls that arrive before the index is ready get a graceful retry status, then byte-identical results once it is built.

Claude Code Plugin

/plugin install cxpak

Auto-triggers on architecture questions and change reviews. Slash commands: /cxpak:overview, /cxpak:trace, /cxpak:diff, /cxpak:clean.

HTTP Server

bash
cxpak serve .                          # port 3000
cxpak serve --token my-secret .        # with Bearer auth on /v1/ endpoints
cxpak watch .                          # file watcher with hot index

LSP

bash
cxpak lsp .                            # stdio, works with any LSP client

CodeLens, hover, diagnostics, workspace symbols, plus 16 custom cxpak/* methods. Supports didOpen/didChange/didClose for in-editor reactivity.

Core capabilities

Auto Context

cxpak_context (op: "context") is the primary entry point. Give it a task and token budget; it returns exactly what the LLM needs.

The pipeline: query expansion with domain-specific synonyms, relevance scoring over 6 deterministic signals (keyword, symbol, path, domain, import proximity, PageRank) fused with Reciprocal Rank Fusion (RRF) -- the default ranking as of 3.0.0, measured +164% recall over the prior weighted-sum on a 31-PR benchmark and deterministic across processes -- then seed selection, noise filtering, test/schema/blast-radius enrichment, progressive degradation (Full > Trimmed > Documented > Signature > Stub), and per-file annotations explaining why each file was included. Embeddings are an optional 7th signal (see Embeddings).

Every response starts with a Repository DNA section -- a ~1000 token convention summary so the LLM knows how your team writes code before it sees any.

Intelligence

FeatureWhat it does
Health ScoreComposite metric across conventions, test coverage, churn stability, coupling, cycles, dead code
Risk RankingFiles ranked by churn x blast radius x test gap -- the ones most likely to cause problems
ArchitecturePer-module coupling, cohesion, circular dependencies, boundary violations, god files
Blast RadiusChange impact: direct dependents, transitive dependents, test files, schema dependents, each with risk scores
Change PredictionStructural + historical (180-day co-change) + call-graph signals, confidence 0.3--0.9
Architecture DriftCompare against stored baselines; auto-saves snapshots for trend tracking
Dead CodeSymbols with zero callers, ranked by importance (PageRank x visibility)
Call GraphCross-file call edges with Exact/Approximate confidence levels
Security SurfaceUnprotected endpoints, secrets, SQL injection, validation gaps, exposure scores across 12 frameworks
Data FlowTrace values source-to-sink through the call graph; reports module/language/security boundary crossings
Cross-LanguageHTTP, FFI, gRPC, GraphQL, shared schema, and exec bridges between languages

Visual Intelligence

Six interactive views, self-contained HTML with D3.js. No build step, no CDN.

bash
cxpak visual --visual-type dashboard .
cxpak visual --visual-type architecture .
cxpak visual --visual-type risk .
cxpak visual --visual-type flow --symbol handle_request .
cxpak visual --visual-type timeline .
cxpak visual --visual-type diff --files "src/api.rs,src/db.rs" .

Export formats: HTML, Mermaid, SVG, PNG, C4 DSL, JSON.

Layout engine: Sugiyama method with SCC condensation, barycenter crossing minimization, Brandes-Kopf coordinate assignment, and 7+/-2 cognitive clustering.

Conventions

Extracts a quantified convention profile from what your team actually does: naming, imports, error handling, dependencies, testing, visibility, function length, git health. Each pattern has counts, percentages, and strength labels (Convention >= 90%, Trend >= 70%, Mixed).

cxpak_review (op: "verify") checks code changes against observed conventions -- only flags violations in changed lines. cxpak conventions export/diff enables CI drift detection with SHA256 checksums.

Onboarding

bash
cxpak onboard .

Generates a dependency-ordered reading guide: files topologically sorted, grouped into phases by module, ordered by PageRank. Each file lists key symbols to focus on and an estimated reading time.

Language support (43)

Full extraction (functions, classes, methods, imports, exports): Rust, TypeScript, JavaScript, Python, Java, Go, C, C++, Ruby, C#, Swift, Kotlin, Bash, PHP, Dart, Scala, Lua, Elixir, Zig, Haskell, Groovy, Objective-C, R, Julia, OCaml, MATLAB, Clojure

Structural extraction (selectors, keys, blocks): CSS, SCSS, Markdown, JSON, YAML, TOML, Dockerfile, HCL/Terraform, Protobuf, Svelte, Makefile, HTML, GraphQL, XML

Database DSLs: SQL, Prisma

Data layer awareness

cxpak understands your data layer and uses it to build a richer dependency graph:

  • Schema detection -- SQL DDL, Prisma, Django, SQLAlchemy, TypeORM, ActiveRecord
  • Migration sequences -- Rails, Alembic, Flyway, Django, Knex, Prisma, Drizzle
  • Embedded SQL linking -- inline SQL in application code creates edges to table definitions
  • Column-level lineage -- impact traced at column granularity: "alter users.email" resolves to the specific queries, ORM models, endpoints, and tests that reference that column, and a different column's blast excludes the email-only files
  • Live database introspection -- connect to a running Postgres or MySQL and index the live schema, then compute drift against the schema the code declares. Pure-Rust rustls drivers (no OpenSSL), read-only, and the DSN is never logged or persisted. Off by default; enabled with the data-introspect build feature
  • Typed edge types -- Import, ForeignKey, ViewReference, EmbeddedSql, OrmModel, MigrationSequence, ColumnReference, CrossLanguage, and more. Each edge carries a confidence marker; heuristic (inferred) edges are labeled so a regex guess is never mistaken for a structurally proven dependency

Graph query and export

Query the typed dependency graph directly -- five primitives (nodes, node, neighbors, path, subgraph), identical across MCP, HTTP, LSP, and CLI. Edges carry a typed edge_type and a confidence marker; inferred (heuristic) edges are surfaced as such. nodes enumerates every valid id with no arguments -- the way to discover ids (they're repo-relative file paths) before calling the others; subgraph reports any seed that isn't a real node in unknown_seeds rather than echoing it back as one.

bash
cxpak graph nodes .
cxpak graph neighbors --id src/index/graph.rs .
cxpak graph path --from src/main.rs --to src/output/mod.rs .
cxpak graph subgraph --seeds src/scanner/mod.rs,src/parser/mod.rs --depth 2 .

Export the graph to Cypher (Neo4j) or GraphML (Gephi, yEd, NetworkX) with the same honest typed edges and per-edge confidence:

bash
cxpak visual --format cypher .
cxpak visual --format graphml .

Embeddings

Semantic similarity is an optional 7th scoring signal, opt-in via .cxpak.json. Without that config the default 6 deterministic signals are used and no model is downloaded. When configured, cxpak uses either local inference with all-MiniLM-L6-v2 (~30 MB, downloaded on first use) or a remote provider -- OpenAI, Voyage AI, or Cohere with your own key. On cxpak serve --mcp the embedding index is built in the background, off the startup path, so it never delays the MCP handshake; if it fails, cxpak falls back to the 6 deterministic signals.

Minimal local config:

json
{ "embeddings": { "provider": "local" } }

WASM plugin loader — a skeleton, not a working SDK

You cannot extend cxpak with a WASM plugin today. PluginLoader::load() verifies the module's checksum, compiles it, instantiates it, and then returns guest function binding not yet implemented. The WIT bridge that would make a guest function callable does not exist, so no plugin code has ever run.

The plugins feature is therefore excluded from default — a stock cargo install cxpak does not build it, and the plugin management commands are behind the same gate. What is built out is the loading path: a manifest with SHA-256 verification before compilation, a 10 MiB module cap, a 64 MiB memory limiter, and a 10 s epoch deadline. Treat none of it as a security boundary until the bridge lands and the gaps in SECURITY.md are closed — #42.

Workspace support

For monorepos: --workspace packages/api scopes scanning to a subdirectory while keeping the full repo as the git root.

Caching

Parse results cached in .cxpak/cache/ keyed on file mtime and size. Cache invalidates automatically when tree-sitter grammar versions change. Atomic writes with advisory locking for concurrent process safety. cxpak clean . to reset.

Rust client (non-default client feature)

Rust callers can talk to a cxpak MCP server through the official client rather than hand-rolling an rmcp session. It is off by default, so cargo install cxpak still builds an indexer and pulls no rmcp:

toml
[dependencies]
cxpak = { version = "3.1", features = ["client"] }

If you want the client without the 43 bundled grammars, default-features = false, features = ["client", "daemon"] builds the library — daemon is currently the floor, not client alone.

CxpakClient is one method, and its return type is the contract:

rust
use cxpak::client::{CxpakClient, RmcpCxpakClient};
use serde_json::json;

let client = RmcpCxpakClient::new(std::env::current_dir()?);
match client.call("cxpak_context", json!({"op": "overview"})).await {
    Some(bundle) => use_it(bundle),
    // NOT "the server looked and found nothing" — the tool was unavailable, errored,
    // or degraded. Map it to a skipped observation, never to a verdict.
    None => skip(),
}

RmcpCxpakClient is lazy: no child process is spawned until the first call, spawns are backed off after repeated failures, and the child's stderr is nulled so a server banner can never contaminate a caller that must not write to stderr (a hook, for instance).

For your own tests, RecordedCxpakClient replays a name → response map with no I/O, and from_dir loads a directory of committed <tool>.json recordings. A missing directory is an error, not an empty client — a mis-pathed fixture set reporting a clean run over nothing is the failure this constructor refuses to have.

rust
use cxpak::client::RecordedCxpakClient;
let client = RecordedCxpakClient::from_dir(std::path::Path::new("recordings/cxpak"))?;

The feature adds rmcp, and only rmcp, to what gets built (async-trait is already in the default tree transitively). CI asserts both directions — that the client compiles and its tests run, and that rmcp stays out of the default dependency tree.

Stable API

v2.0.0 establishes semver for the MCP API. Tool names, parameters, and response structures are stable across 2.x.

3.0.0 consolidates the 26 MCP tools into 5 intent-parameterized tools (cxpak_context, cxpak_graph, cxpak_data, cxpak_review, cxpak_insight), each selecting a capability via a required op argument. This is the one breaking change in 3.0.0 and affects MCP clients only -- the CLI, the HTTP /v1/* API, and the LSP cxpak/* methods are unchanged. The 26 old tool names remain callable as deprecated, undiscoverable aliases for one release. See docs/MIGRATION-3.0.md.

Architecture decisions

Every architecturally significant decision is recorded as an ADR in docs/adrs/ -- what was chosen, the options considered, and the conditions under which to revisit it. The records span parsing, the typed dependency graph, relevance scoring, token budgeting, the MCP/HTTP/LSP surfaces, and distribution. Records 0001-0162 were reconstructed across v0.1.0 -> v2.2.1; 0163 onward are written at decision time, now through 0199 (v3.1.0). Start with the index.

License

Licensed under either of MIT or Apache-2.0 at your option. Unless you explicitly state otherwise, any contribution you intentionally submit for inclusion in the work shall be dual-licensed as above, without any additional terms.


Built by Barnett Studios -- building products, teams, and systems that last.

将 cxpak MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 cxpak 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请保持终端窗口及其中的进程运行。
3

将 cxpak 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 cxpak MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "cxpak": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 cxpak MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 cxpak MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 cxpak 帮我完成这项任务吗?
cxpak
当然。我已阅读。
以下是我使用 cxpak 得到的结果。

常见问题

cxpak MCP 服务器有什么用途?

cxpak 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 cxpak MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您可以让 Claude、ChatGPT、Gemini 等不同 AI 模型,或您在 TypingMind 中配置的其他模型使用 cxpak,而无需为每个模型单独配置 MCP 服务器。

为什么在 TypingMind 中使用 cxpak MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是优秀的大语言模型聊天前端之一。连接 cxpak 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 cxpak MCP 连接到 TypingMind?

cxpak 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

cxpak MCP 在 TypingMind 中提供哪些工具?

cxpak 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 cxpak MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行掌控模型提供商、API 密钥、提示词和 MCP 配置。如果 cxpak 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇