Skip to main content

A Model Context Protocol server for calculating animal feet counts (rabbits and chickens)

Project description

MCP feet Master 🐰🐔

Python 3.8+ MIT License PyPI version

一個專門計算動物腳數的 Model Context Protocol (MCP) 伺服器。解決經典的「兔子和雞」數學問題,讓 AI 模型能夠準確計算農場動物的總腳數。

✨ 功能特色

  • 🧮 精確計算:計算兔子(4腳)和雞(2腳)的總腳數
  • 🔄 反推功能:根據總腳數推算可能的動物組合
  • 📚 範例資源:內建計算範例和使用說明
  • 📝 提示模板:生成標準化的數學問題
  • 🔧 FastMCP:基於 FastMCP 框架,易於整合

🚀 安裝

使用 pip 安裝

pip install mcp-feet-master

從源碼安裝

git clone https://github.com/yourusername/mcp-feet-master.git
cd mcp-feet-master
pip install -e .

📖 使用方法

作為 MCP 伺服器運行

mcp-feet-master

或者在 Python 中:

from mcp_feet_master import create_server

server = create_server()
server.run()

與 Claude Desktop 整合

在 Claude Desktop 的配置文件中添加:

{
  "mcpServers": {
    "mcp-feet-master": {
      "command": "mcp-feet-master",
      "args": []
    }
  }
}

🛠️ 可用工具

1. get_foot_num(rabbits, chickens)

計算兔子和雞的總腳數。

參數:

  • rabbits (int): 兔子數量
  • chickens (int): 雞的數量

返回:

{
    "total_feet": 22,
    "rabbit_feet": 12,
    "chicken_feet": 10,
    "rabbits": 3,
    "chickens": 5,
    "calculation": "3 隻兔子 × 4 腳 + 5 隻雞 × 2 腳 = 22 隻腳",
    "formula": "3 × 4 + 5 × 2 = 22"
}

2. calculate_animals_from_feet(total_feet, animal_type)

根據總腳數反推動物組合。

參數:

  • total_feet (int): 總腳數
  • animal_type (str): "rabbits", "chickens", 或 "mixed"

範例:

# 混合動物組合
{
    "total_feet": 20,
    "possible_combinations": [
        {"rabbits": 5, "chickens": 0, "verification": 20},
        {"rabbits": 3, "chickens": 4, "verification": 20},
        {"rabbits": 1, "chickens": 8, "verification": 20},
        {"rabbits": 0, "chickens": 10, "verification": 20}
    ],
    "count": 4
}

📚 可用資源

feet://examples

獲取使用範例和計算說明。

📝 可用提示

animal_feet_problem

生成標準化的動物腳數數學問題。

參數:

  • rabbits (int): 兔子數量
  • chickens (int): 雞的數量
  • include_explanation (bool): 是否包含解釋(預設:true)

💡 使用範例

與 AI 模型對話範例

用戶: "農場裡有 3 隻兔子和 5 隻雞,總共有多少隻腳?"

AI 模型使用 MCP:

調用 get_foot_num(3, 5)
結果:22 隻腳 (3 × 4 + 5 × 2 = 12 + 10 = 22)

用戶: "如果總共有 20 隻腳,可能的動物組合有哪些?"

AI 模型使用 MCP:

調用 calculate_animals_from_feet(20, "mixed")
可能組合:
- 5 隻兔子 + 0 隻雞
- 3 隻兔子 + 4 隻雞  
- 1 隻兔子 + 8 隻雞
- 0 隻兔子 + 10 隻雞

🧪 開發

安裝開發依賴

pip install -e ".[dev]"

運行測試

pytest tests/

程式碼格式化

black src/ tests/
isort src/ tests/

型別檢查

mypy src/

📈 版本歷史

  • 0.1.0: 初始版本
    • 基本的兔子雞腳數計算功能
    • 反推動物組合功能
    • FastMCP 整合

🤝 貢獻

歡迎貢獻!請查看 CONTRIBUTING.md 了解詳細說明。

  1. Fork 專案
  2. 創建功能分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 開啟 Pull Request

📄 授權

本專案使用 MIT 授權。詳見 LICENSE 文件。

🔗 相關連結

📞 支援

如果遇到問題或有建議,請:


讓 AI 計算動物腳數變得簡單又準確! 🎯

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_feet_master-0.1.6.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_feet_master-0.1.6-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file mcp_feet_master-0.1.6.tar.gz.

File metadata

  • Download URL: mcp_feet_master-0.1.6.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mcp_feet_master-0.1.6.tar.gz
Algorithm Hash digest
SHA256 965811726336b5ba63ab7b49c7ca44d660f9f2b0fdc24793a311d5f2c537cb62
MD5 4b3892cee55055ea298f6b9fc7e334c2
BLAKE2b-256 e329281c47d7aec5cca9e76a8328de10ac4635fa6361a4e5ee044b36bc135795

See more details on using hashes here.

File details

Details for the file mcp_feet_master-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_feet_master-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 fd43444c88171fc9596465cc07d80e0b4ce33d250bd65cd53bac7565fbe7122e
MD5 34d342d25119e9da7bc5c0d161928715
BLAKE2b-256 9385eb1952c4547a29dbc9f2c5a3fe3b5d45de0f1594261895e52ec2e4b614ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page