TESTING.md•5.85 kB
# Testing Guide for Trade Me MCP Server
This guide explains how to test the Trade Me MCP Server.
## Prerequisites
1. **Get Trade Me API Credentials**
- Go to https://www.trademe.co.nz/MyTradeMe/Api/DeveloperOptions.aspx
- Create a new application
- Note your **Consumer Key** and **Consumer Secret**
- For testing, use the **Sandbox** environment
2. **Install Dependencies**
```bash
pip install -e .
```
3. **Configure Environment**
- Copy `.env.example` to `.env`
- Add your credentials:
```bash
TRADEME_CONSUMER_KEY=your_consumer_key
TRADEME_CONSUMER_SECRET=your_consumer_secret
TRADEME_ENVIRONMENT=sandbox
```
## Testing Options
### Option 1: Quick Validation Test (Recommended)
Run the provided test script:
```bash
python test_server.py
```
This will test:
- ✅ Catalogue tools (categories, localities)
- ✅ Search tools (general, property, motors)
- ✅ Listing tools (details, photos)
- ⚠️ Authenticated tools (if tokens configured)
**Expected Output:**
```
============================================================
Trade Me MCP Server - Test Suite
============================================================
Environment: sandbox
Consumer Keys: ✓ Configured
Access Tokens: ⚠️ Not configured (optional)
=== Testing Catalogue Tools ===
1. Testing get_categories...
✓ Got X top-level categories
2. Testing get_localities...
✓ Got locality data
✅ Catalogue tools working!
[... more tests ...]
✅ Testing complete!
```
### Option 2: Test MCP Server Directly
Start the MCP server:
```bash
python -m trademe_mcp.server
```
The server will run and wait for MCP client connections via stdio.
### Option 3: Test with Claude Desktop
1. **Configure Claude Desktop**
Edit your Claude Desktop config file:
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
Add this configuration:
```json
{
"mcpServers": {
"trademe": {
"command": "python",
"args": ["-m", "trademe_mcp.server"],
"cwd": "C:\\Users\\GabeRijpma\\Documents\\GitHub\\trademe-mcp",
"env": {
"TRADEME_CONSUMER_KEY": "your_consumer_key",
"TRADEME_CONSUMER_SECRET": "your_consumer_secret",
"TRADEME_ENVIRONMENT": "sandbox"
}
}
}
}
```
2. **Restart Claude Desktop**
3. **Test in Claude**
Try these prompts:
- "Search Trade Me for laptops under $1000"
- "Find 3-bedroom houses for sale in Auckland"
- "Show me Toyota cars from 2015 or newer"
- "Get details for listing 4567890123"
### Option 4: Manual API Testing
Test individual tools directly:
```python
import asyncio
from src.trademe_mcp.client import TradeMeClient
from src.trademe_mcp.tools import search
async def test():
client = TradeMeClient()
result = await search.search_general(
client,
search_string="laptop",
price_max=1000,
rows=10
)
print(f"Found {result['TotalCount']} laptops")
client.close()
asyncio.run(test())
```
## What to Test
### 1. Catalogue Tools (No Auth Required)
- ✅ `get_categories` - Get full category tree
- ✅ `get_category_details` - Get specific category info
- ✅ `get_localities` - Get NZ locations
- ✅ `get_districts` - Get districts
- ✅ `get_attributes` - Get category attributes
### 2. Search Tools (No Auth Required)
- ✅ `search_general` - Search all categories
- ✅ `search_property_residential` - Search houses for sale
- ✅ `search_property_rental` - Search rental properties
- ✅ `search_property_commercial` - Search commercial properties
- ✅ `search_motors` - Search vehicles
- ✅ `search_jobs` - Search jobs
- ✅ `search_services` - Search services
### 3. Listing Tools (No Auth Required)
- ✅ `get_listing_details` - Get full listing info
- ✅ `get_listing_photos` - Get listing photos
- ✅ `get_listing_questions` - Get Q&A
- ✅ `get_bidding_history` - Get bid history
- ✅ `get_shipping_options` - Get shipping options
- ✅ `get_similar_listings` - Find similar listings
### 4. Authenticated Tools (Requires Access Tokens)
- 🔐 `get_watchlist` - View your watchlist
- 🔐 `add_to_watchlist` - Add item to watchlist
- 🔐 `remove_from_watchlist` - Remove from watchlist
## Getting OAuth Access Tokens
For authenticated tools, you need OAuth access tokens:
1. **Create OAuth Application** at Trade Me Developer Portal
2. **Implement OAuth Flow** (or use pre-generated tokens)
3. **Add to .env**:
```bash
TRADEME_ACCESS_TOKEN=your_access_token
TRADEME_ACCESS_TOKEN_SECRET=your_token_secret
```
## Common Issues
### Issue: "Consumer key and secret are required"
**Solution**: Make sure `.env` file exists with valid credentials
### Issue: HTTP 401 Unauthorized
**Solution**: Check your consumer key/secret are correct for sandbox environment
### Issue: HTTP 404 Not Found
**Solution**: Verify the listing ID exists in the sandbox environment
### Issue: Empty search results
**Solution**: Sandbox has limited data - try broader searches or different categories
## Sandbox vs Production
**Sandbox:**
- Test environment with sample data
- Safe for testing
- Limited real listings
- Use for all development
**Production:**
- Real Trade Me marketplace
- Real user data
- Only use after thorough testing
- Change `TRADEME_ENVIRONMENT=production`
## Next Steps
After successful testing:
1. ✅ Verify all tools work with sandbox
2. ✅ Test with Claude Desktop integration
3. ✅ Implement additional features (Phase 4: Bidding & Buying)
4. ⚠️ Only move to production after extensive testing
## Support
- **Trade Me API Docs**: https://developer.trademe.co.nz/
- **MCP Documentation**: https://modelcontextprotocol.io/
- **Sandbox Site**: https://www.tmsandbox.co.nz/