fp-conv

io.github.sw23由 GitHub 帳號 sw23 發布v1.5.1更新於 Nov 7, 2026

Encode, decode, and convert numbers across FP32, FP16, BF16, TF32, FP8/6/4, and integer formats.

已驗證STDIO僅桌面開發者工具資料與分析

概覽

AI 產生的概覽

本機 MCP 伺服器,讓助理在 FP32、FP16、BF16、FP8 及整數等格式之間編碼、解碼與轉換數值。

可以做什麼
  • 列出與檢視格式:列出預設格式,並取得某格式的偏壓、數值範圍與特殊值支援
  • 編碼數值:把十進位數值或 Infinity/NaN 編碼為二進位、十六進位及分量拆解
  • 解碼位元樣式:把二進位或十六進位位元樣式還原為十進位數值及分量
  • 格式間轉換:在兩種格式間轉換數值或位元樣式,支援捨入與溢位模式並提供精度損失分析
適用情境
適合處理底層數值表示的情境:查看某個值在 bf16 或 fp8 中的樣子、排查位元樣式,或評估在 ML 與 IEEE 格式之間轉換時的精度損失。
執行需求
透過 npx 以 stdio 在本機執行(需要 Node.js);不需帳號、API 金鑰或環境變數。可選在 127.0.0.1 上啟動本機 Streamable HTTP 端點。
安裝前請注意
可選的 HTTP 傳輸沒有身分驗證,預設只綁定 127.0.0.1;除非自行加上身分驗證,否則不要綁定到非回送介面。各工具皆為唯讀計算,不需要任何憑證。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 fp-conv,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

fp-conv-mcp

[npm]

A Model Context Protocol (MCP) server that gives AI agents direct, local tools for floating-point conversions. It is the server-side companion to the fp-conv web app and reuses the same conversion library.

Encode, decode, and convert numbers across FP32, FP64, FP16, BF16, TF32, FP8, FP6, FP4, MX scale/element types, signed/unsigned ints, and custom formats. Supports rounding modes, overflow (saturation) behavior, and calculates precision loss.

Tools

ToolDescription
list_formatsList all available format presets (keys, names, categories, parameters).
get_format_infoGet detailed information about a format (bias, range, special-value support).
encode_numberEncode a decimal value (or Infinity/NaN) into a format. Returns binary, hex, and components.
decode_bitsDecode a binary or hex bit-pattern into a format. Returns the decimal value and components.
convert_formatConvert a value from one format to another.

For convert_format, the source is either a value, constructed using the input format's standard defaults, or bits, a binary or hex bit pattern in the input format used exactly as given; exactly one of the two is required. Its roundingMode and overflowMode parameters apply only when encoding the output format. encode_number applies those parameters to its sole format.

convert_format also takes nanMode, which decides what a NaN source becomes: canonical (default) gives the output format's canonical quiet NaN, and preserve keeps the sign and as many high-order payload bits as fit, quieted (IEEE 754-2019 §6.2.3). A NaN's sign and payload exist only in its bit pattern, so give it as bits: { "bits": "0xFFC00000", "inputFormat": "fp32", "outputFormat": "fp16", "nanMode": "preserve" } returns 0xFE00, where canonical returns 0x7E00. See NaN behavior.

Formats

All tools accept either a preset key (string) or a custom format object.

Preset keys

CategoryKeys
IEEE 754"fp64", "fp32", "fp16"
ML"bf16", "tf32"
OCP"fp8_e5m2", "fp8_e4m3", "fp6_e3m2", "fp6_e2m3", "fp4_e2m1", "e8m0", "mxint8"
Integer"int32", "uint32", "int16", "uint16", "int8", "uint8", "int4", "uint4"

Custom formats

For floating-point:

json
{ "signBits": 1, "exponentBits": 5, "mantissaBits": 10, "bias": 15, "hasInfinity": true, "hasNaN": true }
FieldRequiredDescription
signBitsnoNumber of sign bits, 0 or 1 (default 1)
exponentBitsyesNumber of exponent bits
mantissaBitsyesNumber of mantissa (fraction) bits
biasnoExponent bias; defaults to 2^(exponentBits-1) - 1
hasInfinitynoWhether the format can represent ±Infinity (default true)
hasNaNnoWhether the format can represent NaN (default true). Decided by the layout when hasInfinity is set: true with a mantissa field (passing false there is an error), false without one
hasSubnormalsnoWhether exponent field 0 is a subnormal/zero region (default true). Set false for a scale type such as E8M0.

For integers:

json
{ "bits": 16, "signed": true }
FieldRequiredDescription
bitsyesTotal bit width (1–64)
signednotrue for signed two's-complement, false for unsigned (default true)
fractionBitsnoImplicit 2^-fractionBits scale (default 0; MXINT8 uses 6)
symmetricnoLeave the most-negative encoding unused so the range is symmetric (default false)

Precision note: encoding, decoding and conversion are exact at every width. A value a JSON number could not name exactly (a 64-bit integer's maximum, a mantissa wider than 53 bits, a magnitude outside fp64's range) is returned as a decimal digit string rather than a rounded number. Every flag in a custom format, when given, must be a JSON boolean.

Client configuration

Refer to the following examples with details on how to configure the MCP server:

VS Code (.vscode/mcp.json)

json
{  "servers": {    "fp-conv": {      "type": "stdio",      "command": "npx",      "args": ["-y", "fp-conv-mcp"]    }  }}

Claude Code

bash
claude mcp add fp-conv -- npx -y fp-conv-mcp

GitHub Copilot CLI

bash
copilot mcp add fp-conv -- npx -y fp-conv-mcp

Cursor (.cursor/mcp.json) / Windsurf / Claude Desktop

json
{  "mcpServers": {    "fp-conv": {      "command": "npx",      "args": ["-y", "fp-conv-mcp"]    }  }}

Antigravity (~/.gemini/config/mcp_config.json)

json
{  "mcpServers": {    "fp-conv": {      "command": "npx",      "args": ["-y", "fp-conv-mcp"]    }  }}

Streamable HTTP (local only)

Alternatively, the server can run a local Streamable HTTP endpoint:

bash
npm install -g fp-conv-mcpfp-conv-mcp --http --host 127.0.0.1 --port 3001# endpoint: http://127.0.0.1:3001/mcp

Security: The HTTP transport has no authentication and binds to 127.0.0.1 by default. Do not bind it to a non-loopback interface unless you add your own authentication and understand the implications.

To block DNS-rebinding and cross-site requests from web pages, the server refuses (403) a request whose Host is not a loopback name or the --host address, and one whose Origin names any other host. A wildcard bind (--host 0.0.0.0) cannot know its own names, so it skips the Host check and only accepts an Origin that is loopback or matches the Host. Request bodies are capped at 1 MiB, and a session idle for 30 minutes is closed.

Usage

Once connected, you can ask an agent things like:

  • "Encode 3.14159 as bf16 and show the binary."
  • "What does the fp16 bit-pattern 0x3E00 decode to?"
  • "Convert 0.1 from fp32 to fp8 e4m3 and tell me the precision loss."
  • "List all supported formats."

Debugging

Use the MCP Inspector:

bash
npx @modelcontextprotocol/inspector npx fp-conv-mcp

Then open the Tools tab, click List Tools, and try any tool.

Development

This package lives in the fp-conv repository as an npm workspace. The published bundle (dist/index.js) inlines the shared conversion engine (lib/floating-point.js) and tool definitions (src/webmcp.js) from the repo root via esbuild, keeping a single source of truth.

bash
npm install                         # from the repo rootnpm run build --workspace fp-conv-mcpnpm test  --workspace fp-conv-mcp

License

MIT © Spencer Williams

來源:packages/fp-conv-mcp/README.md,提交 1fd706a

工具

5

list_formats

List formats

List all available floating-point and integer format presets supported by this converter. Returns format keys, names, categories, and parameters (bits, exponent, mantissa, etc.).

無需輸入參數。

encode_number

Encode number

Encode a decimal number (or special value like Infinity / NaN) into a specified floating-point or integer format. Returns binary, hex, and component breakdown.

輸入參數value必填format必填overflowModeroundingMode

decode_bits

Decode bits

Decode a binary or hexadecimal bit-pattern into a specified format. Returns the decimal value and full component breakdown.

輸入參數bits必填format必填

convert_format

Convert format

Convert a value or bit pattern from one floating-point or integer format to another. Returns full encoding details for both formats and precision loss analysis.

輸入參數bitsvaluenanModeinputFormat必填outputFormat必填overflowModeroundingMode

get_format_info

Get format info

Get detailed information about a floating-point or integer format, including value range (max/min normal, subnormal), bias, and special value support.

輸入參數format必填

版本歷史

1
  1. v1.5.1最新Oct 31, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分