stitchmath-mcp
Professional knitting and crochet math calculators that enable AI to design perfectly sized patterns.
README
🧶 StitchMath Core (stitchmath-core)
🏆 Featured & Approved On
StitchMath Core is the open-source mathematical calculation engine and standardized dataset repository by StitchMath.com. Built for developers, designers, and craft bloggers, this library eliminates guesswork in knitting and crochet by providing robust algorithms for gauge sizing, even row decreases, yarn WPI classification, and international needle size conversions.
[!IMPORTANT] 🌟 Need the Full Interactive Web Suite & AI Assistant?
This repository contains our lightweight algorithmic SDK and public datasets. For the complete visual experience—including 20+ interactive calculators, our custom Sweater Pattern Generator, and the AI Pattern Assistant—visit the official web application at https://stitchmath.com.
🆚 Open-Source SDK vs. StitchMath.com Platform
| Feature | stitchmath-core (This Repo) |
StitchMath.com Official Platform |
|---|---|---|
| Core Math Algorithms (JS/TS SDK) | ✅ Yes (Raw Functions) | ✅ Yes (Visual & Interactive) |
| Standardized JSON Datasets | ✅ Yes (Needles, Yarn WPI, Blankets) | ✅ Yes (Interactive Tables) |
| 20+ Visual Web Calculators | ❌ | ✅ Yes (Gauge, Socks, Sleeves, etc.) |
| AI Pattern Assistant | ❌ | ✅ Yes (Instant AI Fitment Solving) |
| Custom Sweater Pattern Generator | ❌ | ✅ Yes (Dynamic Garment Sizing) |
| Printable Guides & Swatch Tutorials | ❌ | ✅ Yes (Comprehensive Reference Hub) |
👉 Experience all interactive tools for free on StitchMath.com →
📦 Features & Datasets
- 📏 Gauge Conversion Algorithm: Adjust pattern stitch counts precisely based on actual swatch measurements.
- ➕ Increase & Decrease Spacing: Automatically calculate even stitch distribution and generate row work instructions (
k2tog,m1). - ⚖️ Curated JSON Datasets: Machine-readable, standardized JSON files for:
- Needle Sizes (
data/needle-sizes.json): Comprehensive US, UK/Canadian, and Metric (mm) conversions. - Yarn Weights & WPI (
data/yarn-weights.json): Standard 0–6 classifications, Wraps Per Inch ranges, and UK/Aus Ply equivalents. - Standard Dimensions (
data/blanket-sizes.json): Standard sizes for throws, baby blankets, scarves, and socks.
- Needle Sizes (
- 🌐 Unit Agnostic: Seamless bidirectional conversion between US Imperial (
in,oz,yd) and Metric (cm,g,m). - 🔷 Full TypeScript Support: Bundled with comprehensive type declarations (
src/index.d.ts).
🤖 Model Context Protocol (MCP) Server
StitchMath Core now includes a built-in MCP server, allowing AI assistants like Claude Desktop and Cursor to perform 100% accurate knitting math, gauge conversions, and sizing calculations directly within your chats.
Available AI Tools
The server exposes the following tools to LLMs:
calculate_gauge: Adjust stitch counts precisely based on actual swatch measurements.calculate_even_spacing: Calculate evenly spaced increases or decreases across a row.convert_needle_size: Convert between US, UK, and Metric needle sizes.convert_units: Convert Imperial / Metric dimensions.get_blanket_cast_on: Get recommended cast-on stitches for standard blanket sizes.
Installing in Claude Desktop
Add the following to your claude_desktop_config.json:
{
"mcpServers": {
"stitchmath": {
"command": "npx",
"args": ["-y", "stitchmath-core"]
}
}
}
🚀 Quick Start (For Developers)
Installation
You can install stitchmath-core via npm or yarn into your Node.js, React, Vue, or React Native projects:
npm install stitchmath-core
Usage Examples
1. Calculate Gauge Adjustment
When a pattern calls for 20 stitches over 4 inches, but your actual swatch is 22 stitches over 4 inches:
const { calculateGauge } = require('stitchmath-core');
// How many stitches should you cast on for a 36-inch bust?
const castOnStitches = calculateGauge(22, 4, 36);
console.log(`Cast on ${castOnStitches} stitches`); // Output: Cast on 198 stitches
2. Calculate Even Decreases Across a Row
When shaping a sleeve or hat crown and you need to decrease 8 stitches evenly across 80 total stitches:
const { calculateEvenSpacing } = require('stitchmath-core');
const shaping = calculateEvenSpacing(80, 8, true); // true = decrease
console.log(shaping.instructions);
// Output: Work 9 sts, then [k2tog (or decrease), work 9 sts] across the row.
3. Lookup Needle Sizes & Conversions
const { convertNeedleSize } = require('stitchmath-core');
const sizeInfo = convertNeedleSize('8', 'us');
console.log(sizeInfo);
// Output: { mm: '5.0', us: '8', uk: '6' }
📊 Standardized JSON Datasets
You can import our curated industry datasets directly without importing the calculation functions:
// Import needle chart dataset directly
const needleChart = require('stitchmath-core/data/needle-sizes.json');
// Import yarn weight classifications and WPI standards
const yarnChart = require('stitchmath-core/data/yarn-weights.json');
// Import standard blanket and scarf dimensions
const blanketDimensions = require('stitchmath-core/data/blanket-sizes.json');
🌐 Embedding StitchMath on Your Blog or Website
Are you a craft blogger, pattern designer, or knitting tutorial author? We encourage you to reference and embed StitchMath in your articles!
To add a direct link or badge to the official calculation suite on your website, simply copy the following HTML snippet:
<!-- StitchMath Badge & Link -->
<a href="https://stitchmath.com" target="_blank" rel="noopener noreferrer" style="display:inline-block;padding:10px 20px;background:#10b981;color:#fff;text-decoration:none;border-radius:25px;font-weight:bold;box-shadow:0 4px 10px rgba(16,185,129,0.3);">
🧶 Powered by StitchMath Calculators →
</a>
By linking to StitchMath.com, you help your readers calculate exact gauge swatches and sizing without leaving their browser!
🤝 Contributing
We welcome contributions from fellow developers, knitters, and crocheters!
- Fork the repository.
- Create your feature branch (
git checkout -b feature/amazing-calculation). - Commit your changes (
git commit -m 'Add new sock heel shaping formula'). - Push to the branch (
git push origin feature/amazing-calculation). - Open a Pull Request.
📄 License
This repository is licensed under the MIT License. See the LICENSE file for details.
<p align="center"> Made with ❤️ by the craft tech team at <a href="https://stitchmath.com"><strong>StitchMath.com</strong></a>.<br> <em>Making knitting and crochet math simple for crafters everywhere.</em> </p>
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
