smarttest-mcp
v1.1.2
Published
Local MCP Server for automated testing (SmartTest) - Works with Gemini API & Local CLIs
Maintainers
Readme
SmartTest Local MCP
🚀 ระบบทดสอบอัตโนมัติที่ทำงาน offline - เลียนแบบ TestSprite MCP แต่ใช้ Gemini API และทำงานได้โดยไม่ต้องจ่ายเงิน
✨ คุณสมบัติ
- ✅ ทำงาน Offline - ไม่ต้องเชื่อมต่อ TestSprite cloud
- ✅ 9 MCP Tools - เพิ่มฟีเจอร์ Auto-fix และ Coverage Analysis
- ✅ Zero API Key - รองรับการใช้
geminiและclaudeCLI ในเครื่อง (ไม่ต้องมี API Key!) - ✅ Gemini AI SDK - รองรับ Google Generative AI ผ่าน API Key สำหรับการประมวลผลความเร็วสูง
- ✅ รองรับ Multi-language - สร้างไฟล์ทดสอบตามภาษาจริงของโปรเจกต์ (e.g.,
.test.js,.py,.go,.java,.rs) - ✅ รองรับทุกประเภท - Frontend, Backend, Fullstack
- ✅ MIT License - ใช้งานได้ฟรี
📦 การติดตั้ง
คุณสามารถเลือกใช้งานได้ 2 แบบ:
1. ใช้งานทันทีผ่าน npx (แนะนำ)
ไม่ต้องติดตั้งลงเครื่อง เรียกใช้ได้เลย:
npx smarttest-mcp2. ติดตั้งลงเครื่อง (Global Install)
ถ้าต้องการใช้บ่อยๆ หรืออยากใช้คำสั่งสั้นๆ smarttest:
npm install -g smarttest-mcp🔑 การตั้งค่า
1. โหมดไม่ต้องใช้ API Key (Zero API Key Mode) 🆕
หากคุณมีการติดตั้ง gemini หรือ claude CLI ในระบบและล็อกอินไว้แล้ว SmartTest จะสลับไปใช้งาน CLI เหล่านั้นโดยอัตโนมัติหากไม่พบ GEMINI_API_KEY:
# ตรวจสอบว่ามี CLI หรือไม่
gemini "hello"
# ถ้าใช้งานได้ SmartTest จะใช้ตัวนี้ทันที2. โหมดใช้ Gemini API Key (ความเร็วสูง)
- ไปที่ Google AI Studio
- สร้าง API Key ฟรี
- ตั้งค่า environment variable:
# Linux/Mac
export GEMINI_API_KEY=your-api-key-here
# Windows
set GEMINI_API_KEY=your-api-key-here2. การเชื่อมต่อกับ Clients (Config)
🤖 Claude Desktop / CLI
แก้ไขไฟล์ config ที่:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"smarttest": {
"command": "npx",
"args": ["-y", "smarttest-mcp"],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}💎 Gemini CLI / General MCP Clients
หากใช้ Gemini CLI หรือ Tools อื่นๆ ที่รองรับ MCP ให้เพิ่ม config ดังนี้:
{
"mcpServers": {
"smarttest": {
"command": "npx",
"args": ["-y", "smarttest-mcp"],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}📝 Cursor / VSCode
เพิ่มใน MCP settings ของ Editor:
{
"mcpServers": {
"SmartTestLocal": {
"command": "npx",
"args": ["-y", "smarttest-mcp"],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}🛠️ MCP Tools (9 Tools)
| Tool | คำอธิบาย |
|------|-----------|
| smarttest_bootstrap | เริ่มต้นระบบ สร้าง config file |
| smarttest_generate_code_summary | วิเคราะห์และสรุปโครงสร้าง codebase |
| smarttest_generate_standardized_prd | สร้าง PRD มาตรฐาน |
| smarttest_generate_frontend_test_plan | สร้างแผนทดสอบ Frontend |
| smarttest_generate_backend_test_plan | สร้างแผนทดสอบ Backend |
| smarttest_generate_code_and_execute | สร้างโค้ดทดสอบและรัน (รองรับหลายภาษา) |
| smarttest_rerun_tests | รัน test ซ้ำ |
| smarttest_analyze_and_fix | 🆕 วิเคราะห์ Error และแนะนำวิธีแก้ (Auto-fix) |
| smarttest_analyze_coverage | 🆕 วิเคราะห์ Test Coverage และแนะนำ test เพิ่ม |
📋 การใช้งาน
Workflow แนะนำ
1. smarttest_bootstrap
↓
2. smarttest_generate_code_summary
↓
3. smarttest_generate_standardized_prd
↓
4. smarttest_generate_frontend/backend_test_plan
↓
5. smarttest_generate_code_and_execute
↓
6. (หาก Fail) smarttest_analyze_and_fix
↓
7. (ตรวจสอบคุณภาพ) smarttest_analyze_coverageตัวอย่างการใช้งานใน Cursor
คุณ: ช่วยทดสอบโปรเจกต์นี้ด้วย SmartTest Local
Cursor: รับทราบครับ ผมจะเริ่มด้วยการ bootstrap โปรเจกต์...
[ใช้ tool: smarttest_bootstrap]
✅ Bootstrapped successfully
[ใช้ tool: smarttest_generate_code_summary]
✅ Code summary generated
[ใช้ tool: smarttest_generate_standardized_prd]
✅ PRD generated
[ใช้ tool: smarttest_generate_frontend_test_plan]
✅ Generated 15 frontend test cases
[ใช้ tool: smarttest_generate_code_and_execute]
✅ Generated 15 test files in .smarttest/generated_tests/📁 โครงสร้างไฟล์ที่สร้าง
your-project/
├── .smarttest/
│ ├── config.json # Config ของ project
│ ├── code_summary.json # สรุปโครงสร้างโค้ด
│ ├── standard_prd.json # PRD มาตรฐาน
│ ├── frontend_test_plan.json # แผนทดสอบ Frontend
│ ├── backend_test_plan.json # แผนทดสอบ Backend
│ ├── test_report.json # รายงานผลการทดสอบ
│ └── generated_tests/ # โค้ดทดสอบที่สร้าง
│ ├── TC001.test.js
│ ├── TC002.test.js
│ └── ...
└── prd_files/ # ไฟล์ PRD ดิบ (ถ้ามี)
└── ...🆚 ความแตกต่างจาก TestSprite
| รายการ | TestSprite | SmartTest Local | |---------|------------|------------------| | API Key | ต้องจ่ายเงิน | ใช้ Gemini API ฟรี | | Cloud Execution | ต้องเชื่อมต่อ cloud | ทำงาน offline | | License | BUSL-1.1 | MIT | | Test Runner | รันใน cloud | รันในเครื่อง | | AI Model | ไม่ระบุ | Gemini 1.5 Flash |
🚀 CLI Commands
สามารถใช้ npx smarttest-mcp แทน smarttest ได้ทุกคำสั่ง:
# ตรวจสอบ environment
smarttest init
# หรือ
npx smarttest-mcp init
# ตรวจสอบ project
smarttest validate /path/to/project
# หรือ
npx smarttest-mcp validate /path/to/project
# รัน MCP server (default)
smarttest
# หรือ
npx smarttest-mcp🛠️ Development
# Clone repo
git clone https://github.com/your-repo/smarttest-mcp
cd smarttest-mcp
# Install dependencies
npm install
# Build
npm run build
# Run
npm start📝 License
MIT License - ใช้งานได้ฟรีทั้งการใช้ส่วนตัวและเชิงพาณิชย์
🤝 มีส่วนร่วม
ยินดีรับ PR และ Issue ทุกชนิด!
⚠️ ข้อจำกัด
- หากไม่ใช้ API Key ต้องมี Gemini/Claude CLI ติดตั้งในเครื่อง
- ประสิทธิภาพในโหมด CLI อาจขึ้นอยู่กับความเร็วของการเรียก shell command
- ขึ้นอยู่กับ quota ของ Gemini API (ถ้าใช้ API Key)
- Test code ที่สร้างอาจต้องแก้ไขเล็กน้อยก่อนรัน
📞 ติดต่อ
- GitHub Issues: github.com/your-repo/issues
- Email: [email protected]
⭐ ถ้าชอบ project นี้ อย่าลืมให้ดาว!
