Logo Forgemax

Forgemax

Cộng đồng
postrv

Code Mode inspired local sandboxed MCP Gateway - collapses N servers x M tools into 2 tools (~1,000 tokens)

Nhà phát hànhpostrv
Kho mãforgemax
Ngôn ngữRust
Bản fork
11
Sao
155
Công cụ có sẵn
0
Phương thức truyền tảistdio
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    Forgemax cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    155 sao và 11 bản fork từ kho mã được liên kết.

Forgemax

Code Mode MCP Gateway — collapses N servers x M tools into 2 tools (~1,000 tokens).

Instead of dumping every tool schema into the LLM's context window, Forgemax exposes exactly two MCP tools:

  • search — query a capability manifest to discover tools (read-only, sandboxed)
  • execute — run JavaScript against the tool API in a sandboxed V8 isolate

Additional sandbox APIs (the MCP surface stays at exactly 2 tools):

  • forge.readResource(server, uri) — read MCP resources from downstream servers
  • forge.stash — session-scoped key-value store for sharing data across executions
  • forge.parallel(calls, opts) — bounded concurrent execution of tool/resource calls

The LLM writes JavaScript that calls through typed proxy objects. Credentials, file paths, and internal state never leave the host — the sandbox only sees opaque bindings. TypeScript definitions (forge.d.ts) are compiled into the binary and served in MCP server instructions, giving LLMs full type awareness.

Forgemax's Code Mode approach draws inspiration from Cloudflare's sandbox tool-calling pattern — their implementation of sandboxed code execution for MCP tool orchestration is excellent and well worth studying. We encourage supporting their work.

Why

Traditional MCPForgemax Code Mode
76 tools = ~15,000 tokens of schema2 tools = ~1,000 tokens
5-10 sequential round-trips1 execute() call with chaining
Every new tool widens the contextTool count is invisible to the LLM

LLMs are trained on billions of lines of code. They're better at writing narsil.symbols.find({pattern: "handle_*"}) than picking the right tool from a 76-item JSON schema list.

Performance

ScenarioRaw MCP (tokens)Forgemax (tokens)Savings
10 tools~4,200~1,10073%
50 tools~20,700~1,10094%
76 tools~33,100~1,10096%
150 tools~61,800~1,10098%

Forgemax schema size is constant (~1,100 tokens) regardless of how many tools are connected. Run the benchmark yourself: cargo run -p forge-manifest --example token_savings

Architecture

forgemax                 Binary entry point (stdio MCP transport)
  forge-config           TOML config loading, env var expansion, file watching
  forge-client           MCP client connections (stdio + HTTP/SSE), routing
  forge-server           MCP server handler (search + execute via rmcp)
    forge-sandbox        V8 sandbox (deno_core, AST validator, worker pool)
      forgemax-worker    Isolated child process for V8 execution
    forge-manifest       Capability manifest, LiveManifest, TypeScript defs
  forge-error            Typed DispatchError enum, structured errors, fuzzy matching
  forge-audit            Audit event types and structured logging
  forge-test-server      Mock MCP server for integration tests

forge-sandbox

The core innovation. Uses deno_core to run LLM-generated JavaScript in a locked-down V8 isolate:

  • No filesystem, network, environment, or child process access
  • Fresh runtime per execution (no state leakage)
  • AST-based code validation via oxc — static analysis catches dangerous patterns before V8 runs (28 bypass tests)
  • Multi-hop alias detection — tracks const e = eval; e("code") and destructured globalThis through multiple assignment hops
  • Timeout + heap limit enforcement with typed errors (Timeout, HeapLimit, JsError) preserved across the IPC boundary
  • Output size caps and tool call rate limiting
  • Opaque bindings — credentials never exposed to sandbox code
  • Dual-mode execution: in-process (tests) or isolated child process (production)
  • Worker pool with warm process reuse, pre-warming, background reaping, and health checks (optional worker-pool feature)
  • Resource reading with URI scheme blocklist, path traversal prevention, and rate limiting
  • Session stash with TTL, group isolation, size limits, and per-execution rate limiting
  • Bounded parallel execution (forge.parallel()) with concurrency caps
  • Prometheus metrics for execution counters, duration histograms, and pool gauges (optional metrics feature)

forgemax-worker

Separate child process binary for production execution. Communicates with the parent via length-delimited JSON IPC over stdin/stdout and starts with a cleared environment. Process separation limits crash and memory-corruption impact on the gateway; it does not provide an operating-system filesystem or network sandbox if V8 itself is compromised.

forge-manifest

Queryable index of all tools across all connected MCP servers. Supports progressive discovery:

  • Layer 0: Server names + descriptions (~50 tokens)
  • Layer 1: Categories per server (~200 tokens)
  • Layer 2: Tool list per category (~500 tokens)
  • Layer 3: Full schema per tool (~200 tokens each)

Built dynamically from live tools/list responses when downstream servers connect. LiveManifest provides lock-free reads via arc-swap with atomic swap for background refresh — periodic re-discovery on a configurable interval, plus SIGHUP-triggered refresh on Unix. TypeScript definitions (forge.d.ts) are compiled into the binary at build time and served in MCP server instructions.

forge-client

MCP client connections to downstream servers. Supports stdio and HTTP/SSE transports. RouterDispatcher routes callTool(server, tool, args) to the correct downstream connection with pre-dispatch tool name validation — misspelled tools return TOOL_NOT_FOUND with Levenshtein-based suggestions before ever hitting the upstream server. ReconnectingClient decorator auto-reconnects on permanent transport failures (broken pipe, channel overflow) with exponential backoff — default enabled for stdio transports.

forge-server

Implements ServerHandler from rmcp. Exposes search and execute as MCP tools, wires them to the sandbox executor, and serves over stdio. Key operations are instrumented with tracing spans for structured observability.

forge-error

Typed DispatchError enum replacing anyhow::Error across all dispatchers. Variants: ServerNotFound, ToolNotFound, Timeout, CircuitOpen, GroupPolicyDenied, Upstream, TransportDead, RateLimit, Internal. TransportDead distinguishes permanent transport failures (broken pipe, channel closed) from transient upstream errors — triggers circuit breaker but is not retryable without reconnection. Includes fuzzy matching — find_symbls suggests find_symbols via Levenshtein distance. Errors serialize to structured JSON with {error, code, message, retryable, suggested_fix}.

forge-audit

Audit event types for structured logging. Every sandbox execution is logged with code hash, tool calls, duration, outcome, worker reuse status, and pool size at acquisition. Code previews are redacted before logging.

forge-config

TOML configuration with environment variable expansion (${GITHUB_TOKEN}). Configures downstream servers, explicit stdio env entries, transports, sandbox limits, and execution mode. Per-server reconnect and max_reconnect_backoff_secs fields control auto-reconnection on transport death (default: enabled for stdio). Optional config file watching via notify crate with debounced reload (requires config-watch feature). Startup concurrency is configurable (startup_concurrency, default 8) for parallel server connections.

Install

npm (recommended):

bash
npm install -g forgemax

Homebrew (macOS/Linux):

bash
brew tap postrv/forgemax && brew install forgemax

Shell installer (macOS/Linux):

bash
curl -fsSL https://raw.githubusercontent.com/postrv/forgemax/main/install.sh | bash

PowerShell (Windows):

powershell
irm https://raw.githubusercontent.com/postrv/forgemax/main/install.ps1 | iex

Scoop (Windows):

powershell
scoop bucket add forgemax https://github.com/postrv/scoop-forgemax
scoop install forgemax

Cargo (from source):

bash
cargo install --locked forgemax forge-sandbox-worker

From source:

bash
cargo build --release --locked --workspace
# Binaries: target/release/forgemax + target/release/forgemax-worker

Quick Start

bash
# 1. Generate a config file
forgemax init

# 2. Edit forge.toml to add your servers and tokens
# 3. Validate your setup
forgemax doctor

# 4. Run (serves MCP over stdio)
RUST_LOG=info forgemax

# Run tests (development)
cargo test --workspace

CLI Commands

CommandDescription
forgemaxStart the MCP gateway server (default)
forgemax serveExplicit alias for server mode
forgemax doctorValidate configuration and connectivity
forgemax manifestInspect the capability manifest
forgemax run <file>Execute a JavaScript file against servers
forgemax initGenerate a starter config file

Configuration

Copy the example config and add your tokens:

bash
cp forge.toml.example forge.toml

The example includes pre-configured connections for 11 reputable MCP servers:

ServerCompanyTransportAuth
narsil—stdioNone
githubGitHubstdio (Docker)Personal access token
playwrightMicrosoftstdio (npx)None
sentrySentrystdio (npx)Auth token
cloudflareCloudflareSSEOAuth
supabaseSupabasestdio (npx)Access token
notionNotionstdio (npx)Integration token
figmaFigmaSSEOAuth
stripeStripestdio (npx)Secret key
linearLinearSSEOAuth
atlassianAtlassianSSEOAuth

Uncomment only the servers you need. Environment variables are expanded (${GITHUB_TOKEN}).

toml
[servers.narsil]
command = "narsil-mcp"
args = ["--repos", "."]
transport = "stdio"

[sandbox]
timeout_secs = 5
max_heap_mb = 64
execution_mode = "child_process"
toml
# Per-server resilience
[servers.narsil]
command = "narsil-mcp"
args = ["--repos", "."]
transport = "stdio"
timeout_secs = 30
circuit_breaker = true
failure_threshold = 3
recovery_timeout_secs = 60
reconnect = true                   # Auto-reconnect on transport death (default: true for stdio)
max_reconnect_backoff_secs = 30    # Max backoff between retries

# Cross-server data flow isolation
[groups.internal]
servers = ["supabase"]
isolation = "strict"

[groups.external]
servers = ["notion", "linear", "atlassian"]
isolation = "strict"

[groups.tools]
servers = ["narsil", "playwright", "github"]
isolation = "open"

How It Works

1. Agent discovers tools via search():

javascript
async () => {
  return manifest.servers.map(s => ({
    name: s.name,
    categories: Object.keys(s.categories)
  }));
}

2. Agent calls tools via execute():

javascript
async () => {
  const symbols = await forge.callTool("narsil", "symbols.find", {
    pattern: "handle_*"
  });
  const refs = await forge.callTool("narsil", "symbols.references", {
    symbol: symbols[0].name
  });
  return { symbols, refs };
}

3. Or using the proxy API:

javascript
async () => {
  const result = await forge.server("narsil").ast.parse({ file: "main.rs" });
  return result;
}

4. Reading resources and using the stash:

javascript
async () => {
  // Read a resource from a downstream server
  const schema = await forge.readResource("db", "postgres://mydb/tables");

  // Store it in the session stash for later executions
  await forge.stash.put("db_schema", schema, { ttl: 3600 });

  // Make parallel calls
  const { results } = await forge.parallel([
    () => forge.callTool("narsil", "ast.parse", { file: "a.rs" }),
    () => forge.callTool("narsil", "ast.parse", { file: "b.rs" }),
  ]);
  return results;
}

5. Structured errors with fuzzy matching:

Typos in server or tool names return helpful suggestions instead of opaque errors:

json
{
  "error": true,
  "code": "TOOL_NOT_FOUND",
  "message": "Tool 'find_symbls' not found on server 'narsil'",
  "retryable": true,
  "suggested_fix": "Did you mean 'find_symbols'?"
}

The sandbox executes JavaScript, routes forge.callTool() to real MCP servers via the ToolDispatcher trait, and returns JSON. The LLM never sees credentials, connection details, or raw API surfaces.

Security Model

  AST Validator         oxc-powered static analysis — import/require/eval/Deno/process
                        blocked before V8 runs, multi-hop alias tracking, 28 bypass tests
        |
  V8 Bootstrap          eval/Function constructor removal at runtime
        |
   V8 Isolate           No fs/net/env, fresh per call, memory-isolated
        |
  API Boundary          Opaque bindings, arg validation, rate limits
        |
Manifest Sanitization   Tool metadata sanitized to prevent prompt injection
        |
  Typed Errors          Structured {code, message, retryable, suggested_fix} JSON —
                        fuzzy matching suggests corrections for typos
        |
 Content Size Limits    OOM prevention for text (10MB), binary (1MB) responses
        |
  Resource Validation   URI scheme blocklist (data/javascript/ftp/gopher/telnet/ldap),
                        path traversal, null bytes, control chars
        |
  Session Stash         Key validation, value/total size limits, TTL enforcement,
                        group isolation, per-execution rate limiting
        |
  Parallel Execution    Bounded concurrency, shared rate limit counter
        |
  Error Redaction       URLs, IPs, paths, credentials, stack traces stripped
                        before reaching the LLM — validation errors preserved
        |
 Resource Limits        Timeout, heap cap, output size cap, concurrency cap
        |
 Header Security        Sensitive headers (auth, token, key, cookie, secret,
                        credential, password) stripped on plain HTTP
        |
 Per-Server Timeouts    Individual timeout per downstream server
        |
  Circuit Breakers      Closed → Open → HalfOpen state machine per server,
                        prevents cascade failures from flaky downstreams
        |
Transport Resilience    TransportDead detection (broken pipe, channel overflow),
                        auto-reconnection with exponential backoff (1s → max),
                        CAS-guarded concurrent reconnection prevention
        |
  Server Groups         Opt-in strict/open isolation policies controlling
                        cross-server data flow within a single execution
        |
Process Isolation       Child process, clean env, kill-on-timeout (production mode)
        |
  Worker Pool           Warm process reuse with health checks, idle reaping,
                        typed error preservation across IPC boundary
        |
 Binary Security        Absolute paths only, permission checks, no PATH fallback
        |
  IPC Protocol          Length-delimited JSON, configurable message size limits,
                        protocol desync prevention, typed ErrorKind across boundary
        |
  Audit Logging         Every execution logged — code hash, tool calls, duration,
                        outcome, worker reuse, pool size, redacted code preview

See SECURITY.md for the full threat model, defense-in-depth table, and hardening checklist. See ARCHITECTURE.md for detailed design.

Examples

The examples/ directory contains runnable JavaScript files demonstrating all sandbox APIs:

FileFeatures
basic-tool-chaining.jsforge.callTool chaining
multi-server-pipeline.jsforge.server() fluent API
stash-workflow.jsforge.stash put/get/keys
parallel-fan-out.jsforge.parallel() concurrency
resource-reading.jsforge.readResource()
error-handling.jsStructured errors + fuzzy matching
parallel-stash-pipeline.jsHero: parallel + stash pipeline

Run an example: forgemax run examples/basic-tool-chaining.js

Tests

~790 tests across the workspace:

bash
cargo test --workspace

Dependencies

CrateVersionPurpose
deno_core0.391V8 sandbox runtime
rmcp1.2MCP protocol (server + client)
tokio1.xAsync runtime
serde1.xSerialization
schemars1.0JSON Schema (matches rmcp)
oxc_parser / oxc_ast0.115AST-based code validation
arc-swap1.xLock-free LiveManifest reads
strsim0.11Levenshtein fuzzy matching
sha20.10Code hashing for audit log
chrono0.4Audit timestamps
notify7.xConfig file watching (optional)
prometheus-client0.22Metrics export (optional)

License

FSL-1.1-ALv2 — Functional Source License, Version 1.1, with Apache License 2.0 future grant.

You can use, modify, and redistribute Forgemax for any purpose except offering a competing commercial product or service. After two years from each release, that version converts to Apache 2.0.

Dùng MCP Forgemax với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối Forgemax, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm Forgemax làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của Forgemax.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "forgemax": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của Forgemax, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của Forgemax.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng Forgemax giúp tôi làm việc này không?
Forgemax
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng Forgemax.

Câu hỏi thường gặp

Máy chủ MCP Forgemax dùng để làm gì?

Forgemax là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP Forgemax với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng Forgemax với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP Forgemax với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối Forgemax, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP Forgemax với TypingMind?

Forgemax hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP Forgemax cung cấp những công cụ nào trong TypingMind?

Forgemax cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP Forgemax không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu Forgemax yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇