- Add MCP Quick Start Guide with 5 practical examples - Add 30+ ready-to-use MCP configuration examples - Add MCP testing and validation guide - Update tools documentation index with MCP guide links This documentation makes it easier for users to get started with Model Context Protocol servers in Qwen Code, reducing setup time from hours to minutes. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
9.1 KiB
MCP Testing & Validation Guide
This guide helps you test and validate your MCP server configurations.
✅ Quick Validation Checklist
1. Check MCP Servers Are Configured
qwen mcp list
Expected output:
Configured MCP servers:
✓ filesystem: npx -y @modelcontextprotocol/server-filesystem ./ (stdio) - Connected
✓ memory: npx -y @modelcontextprotocol/server-memory (stdio) - Connected
Status indicators:
- ✓ (green) - Connected successfully
- ✗ (red) - Connection failed or not connected
2. Verify Server Is Installed
Test the server command directly:
# Filesystem server
npx -y @modelcontextprotocol/server-filesystem --help
# Memory server
npx -y @modelcontextprotocol/server-memory --help
# Custom server
python mcp_server.py --help
3. Check Configuration File Syntax
Validate your JSON configuration:
# Linux/macOS
cat .qwen/settings.json | jq .
# Windows PowerShell
Get-Content .qwen/settings.json | ConvertFrom-Json | ConvertTo-Json
4. Test Within Qwen Code Session
Start an interactive session and check MCP status:
qwen
# Inside the session:
/mcp # Show all MCP servers and tools
/mcp desc # Show tool descriptions
/mcp schema # Show tool parameter schemas
🧪 Test Cases
Test Case 1: Filesystem Server
Configuration:
{
"mcpServers": {
"test-fs": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "./"],
"trust": true
}
}
}
Validation:
- List files: Start
qwenand ask "List all files in this directory" - Read file: "Read the README.md file"
- Verify output contains actual file contents
Expected Tools:
read_file- Read file contentswrite_file- Write to fileslist_directory- List directory contentscreate_directory- Create directoriesmove_file- Move/rename filessearch_files- Search for filesget_file_info- Get file metadata
Test Case 2: Memory Server
Configuration:
{
"mcpServers": {
"test-memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"],
"trust": true
}
}
}
Validation:
- Store information: "Remember that this project uses React 18"
- Query: "What JavaScript framework does this project use?"
- Verify it recalls the information from step 1
Expected Tools:
create_entities- Create knowledge entitiescreate_relations- Create relationships between entitiesadd_observations- Add observations to entitiesdelete_entities- Remove entitiesdelete_observations- Remove observationsdelete_relations- Remove relationshipsread_graph- Read entire knowledge graphsearch_nodes- Search for specific nodesopen_nodes- Open specific nodes by name
Test Case 3: Multiple Servers
Configuration:
{
"mcpServers": {
"files": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "./"],
"trust": true
},
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"],
"trust": true
}
}
}
Validation:
- Check both servers are connected:
qwen mcp list - Use filesystem tool: "List all JavaScript files"
- Use memory tool: "Remember that we prefer TypeScript"
- Verify both tools work simultaneously
Test Case 4: Tool Filtering
Configuration:
{
"mcpServers": {
"readonly-fs": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "./"],
"includeTools": ["read_file", "list_directory"],
"trust": true
}
}
}
Validation:
- Start qwen session
- Run
/mcp descto list available tools - Verify only
read_fileandlist_directoryare present - Verify
write_file,create_directory, etc. are NOT available
Test Case 5: Untrusted Server Confirmation
Configuration:
{
"mcpServers": {
"untrusted": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "./"],
"trust": false
}
}
}
Validation:
- Ask qwen to read a file
- Confirmation dialog should appear before execution
- Options should include:
- Proceed once
- Always allow this tool
- Always allow this server
- Cancel
🔍 Debugging Failed Connections
Issue: Server Shows "Disconnected"
Diagnostic steps:
-
Test command manually:
npx -y @modelcontextprotocol/server-filesystem ./ -
Check for errors:
qwen --debug -
Verify paths are correct:
# Check if directory exists ls ./ # Check if command is in PATH which npx # Linux/macOS where npx # Windows -
Check permissions:
# Verify read/execute permissions ls -la ./ -
Review environment variables:
echo $PATH echo $PYTHONPATH # For Python servers
Issue: No Tools Discovered
Diagnostic steps:
-
Verify server implements MCP protocol:
# For stdio servers, test input/output manually echo '{"jsonrpc": "2.0", "method": "initialize", "id": 1}' | npx -y @modelcontextprotocol/server-filesystem ./ -
Check server logs:
# Some servers log to stderr qwen --debug 2>&1 | grep MCP -
Verify server version:
npm list -g @modelcontextprotocol/server-filesystem
Issue: Tools Fail to Execute
Diagnostic steps:
-
Check parameter format:
- Ensure parameters match the expected schema
- Verify JSON encoding is correct
-
Increase timeout:
{ "mcpServers": { "slow-server": { "command": "...", "timeout": 60000 } } } -
Check server implementation:
- Verify the server actually implements the tool
- Test the tool independently if possible
📊 Validation Results
Expected Server Connection Times
| Server Type | Typical Connection Time | Timeout Recommendation |
|---|---|---|
| Filesystem | < 1 second | 10-30 seconds |
| Memory | < 1 second | 10-30 seconds |
| HTTP/SSE | 1-3 seconds | 30-60 seconds |
| Custom Python | 2-5 seconds | 30-60 seconds |
| Docker | 5-10 seconds | 60-120 seconds |
Tool Execution Times
| Tool Type | Typical Duration | Timeout Recommendation |
|---|---|---|
| Read file | < 100ms | 5-10 seconds |
| List directory | < 500ms | 10-15 seconds |
| Search files | 1-5 seconds | 30-60 seconds |
| Memory operations | < 1 second | 10-30 seconds |
| API calls | 1-10 seconds | 30-120 seconds |
🎯 Success Criteria
Your MCP configuration is working correctly if:
✅ qwen mcp list shows all servers as "Connected"
✅ /mcp command in qwen session displays tools
✅ Tool executions complete without errors
✅ Confirmation dialogs appear for untrusted servers (if trust: false)
✅ Tool filtering works as expected (include/exclude)
✅ Environment variables are properly substituted
✅ Timeouts are appropriate for your server's response time
🚀 Performance Tips
- Use
trust: truefor local servers to skip confirmation dialogs - Set appropriate timeouts - too low causes failures, too high slows down errors
- Filter tools - Only enable tools you actually need
- Test servers independently before configuring in qwen
- Use
--debugflag during initial setup - Monitor resource usage for long-running or resource-intensive servers
📝 Validation Script Example
Create a test script to automate validation:
#!/bin/bash
# validate-mcp.sh
echo "Testing MCP configuration..."
# Test 1: Check config file exists
if [ ! -f .qwen/settings.json ]; then
echo "❌ Missing .qwen/settings.json"
exit 1
fi
echo "✅ Config file exists"
# Test 2: Validate JSON syntax
if ! cat .qwen/settings.json | jq . > /dev/null 2>&1; then
echo "❌ Invalid JSON in settings.json"
exit 1
fi
echo "✅ Valid JSON syntax"
# Test 3: Check servers are configured
SERVER_COUNT=$(cat .qwen/settings.json | jq '.mcpServers | length')
if [ "$SERVER_COUNT" -eq 0 ]; then
echo "❌ No MCP servers configured"
exit 1
fi
echo "✅ $SERVER_COUNT MCP server(s) configured"
# Test 4: Check connection status
qwen mcp list | grep -q "Connected"
if [ $? -eq 0 ]; then
echo "✅ At least one server is connected"
else
echo "❌ No servers connected"
exit 1
fi
echo ""
echo "✅ All validation checks passed!"
📚 Next Steps
After validation:
- Start using MCP tools in your workflow
- Document your custom configurations for team members
- Share your successful configs with the community
- Monitor performance and adjust timeouts as needed
- Explore more MCP servers from the community
Having issues? Check the MCP troubleshooting guide or open an issue on GitHub.