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.7.tar.gz (14.0 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.7-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcp_feet_master-0.1.7.tar.gz
  • Upload date:
  • Size: 14.0 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.7.tar.gz
Algorithm Hash digest
SHA256 86c4a5b217f692cbe95df553942cb4e0db21befa1ed5dc9dee90f48b0044fd24
MD5 f6aeec50a2d8c5c14f3eba1ab96a41bf
BLAKE2b-256 12619593a638f946df38cff14137931515021b6f7a40f22d51eafb2395fdab50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_feet_master-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6f0656ba22f14d99f5916ebe2cc05fe2339b7af06e9b8dc4453c7ccaf9aaaab6
MD5 bf9c0b95798ef6f548c484bb276145c3
BLAKE2b-256 dc8ffdcc850d8018bd31cf62513296cb49448c535db52355bb219b88fce62d66

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