{"_id":"@magpie-community/tools-calc","_rev":"2-efb0faf2060dcff1d17d84c2d56f4cb8","name":"@magpie-community/tools-calc","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.0-stage":{"name":"@magpie-community/tools-calc","version":"0.0.0-stage","_id":"@magpie-community/tools-calc@0.0.0-stage","stub":true,"maintainers":[{"name":"yetone","email":"yetoneful@gmail.com"}],"dist":{"shasum":"e81fb9dd6421da7dea51018abd90d923847c7edf","tarball":"https://registry.npmjs.org/@magpie-community/tools-calc/-/tools-calc-0.0.0-stage.tgz","fileCount":2,"integrity":"sha512-gQbrM6LfDuS457181ejnPN3pwg8pDv7yNfbaovTe15iRKTpZHV85aP/LlY6IdcYhm7xOT5ABpEZEOXpSIV3y8g==","signatures":[{"sig":"MEUCIQCgYyKmVK4q/oteAd3cB9f6zZMRfUsOVHdFWQT/zZ0nsQIgA7bAtEu6Od5VJlAJ3wDHIWokiMw4xYSbs/rujWGrcGE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":350},"_npmUser":{"name":"yetone","email":"yetoneful@gmail.com"},"description":"Temporary package placeholder for staged publishing","directories":{}},"0.1.0":{"_id":"@magpie-community/tools-calc@0.1.0","bugs":{"url":"https://github.com/magpie-community/plugins/issues"},"dist":{"shasum":"a036123ae9e466ce4221d157be8eae5f0d76a7c5","tarball":"https://registry.npmjs.org/@magpie-community/tools-calc/-/tools-calc-0.1.0.tgz","fileCount":4,"integrity":"sha512-9qTkmGQcckIfnQSXMxAJsL7L2hvBCJ+eBhMCrOqKnR88EPSS8QiiRgCJJAABX78jSnlAXFsbnjXre+vILz5B0w==","signatures":[{"sig":"MEUCIAfewi5vt6TZlGz4ohBel+TmAtk4O5mbPCcd2xmBzLzVAiEA5wB1WxQ1grs7Ohc/Att08DX++wRko5M+MMQmdwMt7CI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIH7ga+GDG5xgCOlt6QAVvJwrF2rs/ORalap7ihM0XA4tAiEAthF6dUJwAE7jGVucKSoSnO063URdXUjOGyE0p0XAQUE="}],"unpackedSize":26854},"main":"./index.mjs","name":"@magpie-community/tools-calc","type":"module","_from":"file:magpie-community-tools-calc-0.1.0.tgz","license":"MIT","version":"0.1.0","_npmUser":{"name":"yetone","email":"yetoneful@gmail.com"},"homepage":"https://github.com/magpie-community/plugins#readme","keywords":["magpie","magpie-tools","mcp","opencode","opencode-plugin","calculator","units","dates"],"_resolved":"/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/cf807b05-384d-430a-88ce-af31347816a3/scratchpad/npm-first/tgz/magpie-community-tools-calc-0.1.0.tgz","_integrity":"sha512-9qTkmGQcckIfnQSXMxAJsL7L2hvBCJ+eBhMCrOqKnR88EPSS8QiiRgCJJAABX78jSnlAXFsbnjXre+vILz5B0w==","repository":{"url":"git+https://github.com/magpie-community/plugins.git","type":"git","directory":"packages/calc"},"_npmVersion":"11.21.0","description":"Exact arithmetic, unit conversion and calendar date math as tools for every coding agent, through magpie's MCP server","directories":{},"maintainers":[{"name":"yetone","email":"yetoneful@gmail.com"}],"_nodeVersion":"22.22.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tools-calc_0.1.0_1792095168747_0.6220458181513473"}}},"time":{"created":"2026-10-15T20:11:50.530Z","modified":"2026-10-15T20:12:49.375Z","0.0.0-stage":"2026-10-15T20:11:50.530Z","0.1.0":"2026-10-15T20:12:48.830Z"},"description":"Exact arithmetic, unit conversion and calendar date math as tools for every coding agent, through magpie's MCP server","maintainers":[{"name":"yetone","email":"yetoneful@gmail.com"}],"readme":"# @magpie-community/tools-calc\n\nExact arithmetic, unit conversion and date math, as tools [magpie](https://usemagpie.ai) offers every agent it connects. Models get arithmetic wrong (`0.1 + 0.2`, big powers, days between two dates across a DST change), so this gives them a calculator. It needs no network, no key and no dependency.\n\nInstall it from magpie's **Plugins › Discover**, or with:\n\n```sh\nmagpie plugin add @magpie-community/tools-calc\nmagpie plugin            # lists its tools\n```\n\nmagpie serves the tools on its MCP server, `/mcp/magpie/tools`, to every agent it has connected. Each tool's name starts with the plugin's short name, `calc`: `calc_eval`, `calc_convert` and `calc_date` (magpie v0.1.1260 or later; earlier versions named them `tools-calc_eval` when installed from npm).\n\n## Tools\n\n**`eval`** `{expression, places?}` evaluates an expression exactly, in fractions, with no floating point.\n\n- Operators: `+ - * / % ^` (or `**`), parentheses, and unary minus.\n- Numbers: decimals, `1e9`, `0x`/`0b`/`0o` literals, and `1_000`.\n- Functions: `abs floor ceil round trunc min max gcd lcm fact`.\n- It answers `{exact, decimal}`, plus `rounded: true` when the decimal was cut at `places` (20 by default).\n\n```\n0.1+0.2          → {\"exact\":\"3/10\",\"decimal\":\"0.3\"}\n2^128/3          → every digit, exact\n1/0              → an error: division by zero\n```\n\n**`convert`** `{value, from, to, places?}` converts a quantity exactly. `value` can be an expression, such as `3*1024`.\n\n| Kind | Units |\n|---|---|\n| Data | `bit B kB MB GB TB` (1000s), `KiB MiB GiB TiB` (1024s), `kb Mb Gb` |\n| Time | `ns us ms s min h d wk` |\n| Length | `nm um mm cm m km in ft yd mi nmi` |\n| CSS | `px pt pc` |\n| Mass | `mg g kg t oz lb` |\n| Angle | `deg turn grad` |\n| Temperature | `C F K` |\n\n```\n1 GiB → MB       → {\"exact\":\"16777216/15625\",\"decimal\":\"1073.741824\",\"unit\":\"MB\"}\n```\n\n**`date`** `{date?, add?, to?, timeZone?}` does date math on the real calendar.\n\n- `date` is ISO 8601, unix seconds or milliseconds, or `now` (the default). It answers the ISO time, weekday, ISO week, day of year and unix time.\n- `add` is a duration, such as `3d 4h`, `-90m`, `1y2mo` or ISO `P1DT2H`. Years, months and days count on the calendar, so Jan 31 + 1mo is the last day of February, and a day across a DST change is still a day.\n- `to` is a second date. The answer then also has `between`, the time from `date` (after `add`) to `to`, in days, hours, minutes, seconds and calendar years, months and days.\n- `timeZone` is an IANA zone, such as `Asia/Shanghai`. Dates with no offset are read as that zone's wall time, and the answer shows the local time. Without it, they are UTC.\n\n## Test\n\n```sh\nbun test packages/calc\n```\n\n中文：给 magpie 连接的每个 agent 提供精确计算工具：`eval` 用分数精确计算表达式，`convert` 换算数据、时间、长度、质量、角度和温度单位，`date` 按真实日历做日期加减和间隔（支持时区与夏令时）。不联网，不需要 key。\n","readmeFilename":"README.md","homepage":"https://github.com/magpie-community/plugins#readme","keywords":["magpie","magpie-tools","mcp","opencode","opencode-plugin","calculator","units","dates"],"repository":{"url":"git+https://github.com/magpie-community/plugins.git","type":"git","directory":"packages/calc"},"bugs":{"url":"https://github.com/magpie-community/plugins/issues"},"license":"MIT"}