
Arabicfmt Mcp
io.github.cc1a2b由 GitHub 账号 cc1a2b 发布v0.1.1更新于 Oct 24, 2026
Arabic formatting: 22 Arab currencies (Saudi riyal U+20C1), Hijri dates, تفقيط, RTL/bidi fixes.
概览
本地 MCP 服务器,封装 arabicfmt 库,让助手格式化阿拉伯货币、回历日期、阿拉伯语数字读法、تفقيط 及 RTL 文本。
- 可以做什么
- 按 22 个阿拉伯国家货币格式化金额,包括符号、小数精度、区间以及新 Unicode 符号的分段输出,并为支票和发票提供 تفقيط 金额大写。把数字转换为阿拉伯语单词、序数、分数、时长、文件大小和相对时间,并把阿拉伯数字字符串解析回数值。用固定的 Umm al-Qura 表生成回历日期。处理阿拉伯语文本:复数形式、排序、slug、搜索归一化和 RTL/双向文本隔离。校验 IBAN 和沙特身份证号。
- 适用场景
- 适合助手起草阿拉伯语发票、支票、合同、价目表或本地化界面,需要正确的货币符号、小数精度、回历日期或金额大写时使用。也适合修正混合方向文本以及处理阿拉伯语搜索和 slug。
- 运行要求
- 以本地进程通过 stdio 运行,从 npm 包 arabicfmt-mcp 安装;需要 Node.js 18 或更高版本。未声明认证、环境变量或请求头。
安装
在 SourceWeft 中
- 打开 控制台中的 Arabicfmt Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
arabicfmt
Arabic-first formatting for JavaScript & TypeScript
Currency symbols · Hijri/Islamic calendar · number-to-words · تفقيط · 6 plural forms · RTL/bidi —
correct for all 22 Arab League countries, with zero dependencies and full TypeScript types.
أرقامٌ وعملاتٌ وتواريخُ هجريةٌ ولغةٌ عربيةٌ سليمة — في سطرٍ واحد.
[npm version] [downloads] [jsDelivr hits] [gzipped size] [zero dependencies] [types included]
arabicfmt is the only JavaScript library that handles the entire Arabic formatting stack in one zero-dependency package — currency symbols, number precision, Hijri/Islamic calendar dates, RTL bidirectional text, Arabic number-to-words and تفقيط — with full TypeScript types. Works in Node, the browser, Deno, Bun and React Native.
New in 0.1.5: every currency sign from the Unicode 17.0/18.0 transition — SAR
U+20C1, MVRU+20C2, AEDU+20C3, OMRU+20C4— plus the tooling to actually render them: typed parts, a generated@font-face, price ranges and a date-aware transition registry.
What other libraries get wrong
Install
Requirements: Node.js ≥ 18 · TypeScript ≥ 4.7 (optional) · zero runtime dependencies.
Browser / CDN — no build step
Every release is mirrored on the jsDelivr and unpkg CDNs automatically. Import the browser-ready ESM bundle straight from a URL — no install, no bundler:
Subpaths work too — e.g. https://cdn.jsdelivr.net/npm/arabicfmt/dist/currency/index.js for just the currency module. Pin a version for production, e.g. [email protected].
Quick start
Currency formatting
Symbol strategy: symbolMode
The Saudi riyal received its own Unicode symbol (U+20C1) in September 2025. Most libraries either emit the wrong ligature (U+FDFC, the Iranian rial) or fall back to SAR. arabicfmt gives you full control:
Unicode 18.0 (16 September 2026): the AED (U+20C3), OMR (U+20C4) and MVR (U+20C2) signs are now
live, andautoprefers them. Need maximum compatibility today? UsesymbolMode: "text". The Saudi riyal keeps its safe text default by design. See the transition section for the full table.
Correct decimal precision — all 22 Arab League countries
Generated from CLDR 48.2.0 at build time and verified on every build:
All currency options
Price ranges
Pass rangeSeparator for anything other than the default spaced en dash
({ rangeSeparator: " إلى " }), and isolate: true to wrap the whole range
when it sits inside a mixed-direction sentence.
Rendering the new signs
A brand-new sign needs two things a string cannot give you: a webfont scoped to its codepoint, and a way to wrap only the symbol in the element that uses that font. Both are one call each.
1. The parts API — the currency counterpart to
Intl.NumberFormat.prototype.formatToParts:
needsFont is true exactly when the part holds a dedicated Unicode sign, so a
component never has to pattern-match a finished string (which is how bidi bugs
start):
Part types mirror Intl (integer, group, decimal, fraction,
minusSign, plusSign, literal) plus four arabicfmt adds: currency,
parenthesis (accounting), isolate (bidi controls) and rangeSeparator.
2. The @font-face rule — generated, with the unicode-range that makes it
free on pages that never print a sign:
Because the range is scoped to those codepoints, the browser downloads the font only when one of them is actually painted — body text is untouched. Put the family first in your stack and the rest falls through:
signUnicodeRange() returns just the range string ("U+20C1, U+20C2, U+20C3, U+20C4") for CSS-in-JS. Both helpers reject anything that would break out of
the rule, so a URL from config can't inject CSS.
Number formatting
Number to Arabic words (arabicToWords)
Convert integers to their Arabic word representation — handles gender agreement and all six scale levels.
Spell money in words — التفقيط
spellCurrency is the tafqit every Arabic invoice, cheque and contract needs: it turns a numeric amount into its full legal Arabic wording, splitting major and minor units and inflecting every noun for correct grammatical agreement (singular / dual / plural / accusative).
Full Arabic noun paradigms are bundled for all 22 Arab League currencies (SAR, AED, KWD, BHD, QAR, OMR, JOD, EGP, IQD, LYD, TND, DZD, MAD, SDG, LBP, SYP, YER, SOS, DJF, KMF, MRU). Inspect or extend them via the exported CURRENCY_WORDS table.
Ordinal numbers — الأعداد الترتيبية
Duration — spelled Arabic
formatDuration turns a time span into its spoken Arabic form, with correct
dual/plural/accusative agreement on every unit — something Intl.DurationFormat
(still barely supported) does not give you.
largest (default 2) caps how many units appear, biggest first. Want to drive
the noun agreement yourself? countedNoun(n, forms) is exported for any custom
counted noun.
File size — Arabic data units
Units scale through بايت · كيلوبايت · ميجابايت · جيجابايت · تيرابايت · بيتابايت,
with base: 1024 (binary, default) or base: 1000 (decimal).
Arabic plural rules (6 forms)
Arabic has six plural forms — more than any other major language. Standard i18n libraries handle 1–2 forms and break for Arabic.
Hijri / Islamic calendar dates
Two engines with an identical API:
Month and weekday name tables
Bidirectional (RTL) text helpers
Stop phone numbers and English words from scrambling Arabic sentences:
Text normalization for Arabic search
Match Arabic text despite diacritics, alef variants, hamza and taa marbuta differences:
List formatting
Join values into a grammatical Arabic list. Wraps Intl.ListFormat and degrades gracefully on runtimes without it.
Transliteration & URL slugs
Romanize Arabic script to readable Latin, or turn it into URL-safe slugs for routes, filenames and CMS permalinks. Deterministic — short vowels appear only when the text is vowelled (carries tashkeel).
Note: this is a pragmatic, reversible-ish romanization, not a strict academic transliteration (DIN 31635 / ISO 233). It is built for slugs, search keys and readable IDs.
Validation — IBAN & Saudi ID
Real checksums, not regex guesses. isValidIBAN runs the ISO 7064 mod-97
algorithm with SWIFT-registry length checks; isValidSaudiId runs the Luhn
check digit and classifies citizen vs. resident.
Registry lengths are enforced for SA, AE, KW, BH, QA, JO, LB, EG, IQ, PS, TN, MR, LY (plus common partners). Unknown-country IBANs are validated by checksum and the general 15–34 length bound, never accepted on structure alone.
Framework usage
React / Next.js
Vue 3
Node.js / Express
Locale auto-detection
Subpath imports — tree-shakeable
Pick only what you need for the smallest possible bundle:
Measured cost of each entry point (esbuild --bundle --minify, gzipped — v0.1.5):
The complete Arabic formatting stack costs less than a single small image.
Full API reference
Every public function, by module. Full signatures and options are in the sections above and in the bundled TypeScript types.
MCP server — use arabicfmt from AI agents
AI agents (Claude Desktop, Claude Code, Cursor) can call arabicfmt directly through the
arabicfmt-mcp Model Context Protocol server —
21 tools (format_currency, format_currency_range, currency_transition,
spell_currency, format_hijri, arabic_to_words, isolate_foreign,
validate_iban, …). Add it to your client's mcpServers config:
Source and full tool list: mcp/.
Examples
Runnable scripts for every feature live in examples/:
Engineering
Unicode currency-sign transition
Complete as of Unicode 18.0 — released 16 September 2026
Four currencies moved from an ad-hoc abbreviation to a dedicated Unicode sign in
this cycle, and arabicfmt carries all four. Note what is not on this list:
Kuwait has never issued a dinar sign — KWD is still د.ك / KD, and
transitionStatus("KWD") returns "none".
The rufiyaa is not an Arab League currency, but it was encoded in the same batch
and sits between the dirham and rial in the Currency Symbols block — carrying it
keeps the range contiguous, so one unicode-range covers the whole transition.
Because system-font coverage for brand-new signs still varies, symbolMode: "text" always returns the safe abbreviation, and the Saudi riyal keeps the text
symbol as its auto default by design.
The transition as data
Encoding is not rendering. A sign exists in the standard months or years before system fonts draw it, and every product shipping in that window has to decide what to print. That timeline is queryable:
transitionStatus takes a moment in time, so a historical invoice can be
re-rendered with the symbol that was correct on its own date.
Live demo
arabicfmt.vercel.app — the whole library, interactive and computed live in your browser. Change any input and watch the Arabic update in real time: currency studio, تفقيط, Hijri converter, plurals, RTL fixes and more.
[arabicfmt interactive playground]
Run it locally:
Contributing
Issues and pull requests are welcome on GitHub.
License
MIT — free for commercial and personal use.
Author & more projects
Built and maintained by cc1a2b.
If arabicfmt saves you time, please star it on GitHub — it helps other Arabic developers find it. Explore my other open-source projects, or open an issue with ideas, bugs and feature requests.
来源:README.md,提交 946ad4a
工具
0版本历史
1- v0.1.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分