Overview
Testing your MCP tools is a critical step before publishing. It ensures your tools work correctly, handle parameters properly, and return expected results. This guide walks you through the testing process.Why Test Your Tools?
Testing helps you:- ✅ Verify Functionality: Ensure queries execute correctly
- ✅ Validate Parameters: Confirm parameters work as expected
- ✅ Check Results: Verify returned data is correct
- ✅ Catch Errors Early: Find issues before agents use the tools
- ✅ Optimize Performance: Identify slow queries
Never skip testing. A tool that fails in testing will fail when agents use it, causing errors and poor user experiences.
Preparing to Test
Before testing, ensure:- ✅ Your tool is created and configured
- ✅ Tool call arguments are set (test values)
- ✅ Your view has data (empty views return no results)
- ✅ SQL query syntax is correct
Step-by-Step Testing
Step 1: Access Test Functionality
- Navigate to your project
- Open the tool you want to test (click on it in the MCP Tools section)
- Locate the “Test Run” button at the top of the tool view
- Click “Test Run”
Step 2: Test Execution
After clicking “Test Run”:-
A popup window appears showing:
- The query being executed
- Parameter values being used
- Execution status
- Wait for the query to complete (you’ll see a loader)
- Results appear in the “Test Results” section
The test uses the Tool Call Arguments you’ve configured. These are the sample values that will be injected into your query.
Step 3: Review Results
The Test Results section shows:- Query Executed: The actual SQL query with parameter values injected
- Result Data: The data returned by the query
- Row Count: Number of rows returned
- Execution Time: How long the query took
- Status: Success or error message
Example Test Results
For our engagement score tool withevent_type = "login":
Query Executed:
- Engagement scores for all events containing “login”
- Ordered from highest to lowest
- Row count and execution time displayed
If the test succeeds, your tool is working correctly and ready for use. If it fails, review the error message and fix the issue.
Understanding Test Results
Successful Test
A successful test shows:- ✅ Query executed without errors
- ✅ Results returned (even if empty)
- ✅ Correct parameter injection
- ✅ Expected data structure
Failed Test
If a test fails, you’ll see:- ❌ Error message explaining what went wrong
- ❌ Query that failed (helpful for debugging)
- ❌ Parameter values used
Common Test Failures
1. Parameter Mismatch- Error: Parameter placeholder doesn’t match parameter name
- Fix: Ensure
{parameter_name}in SQL matches parameter definition exactly
- Error: Invalid SQL syntax
- Fix: Test query manually in SQL IDE first
- Error: Parameter type doesn’t match query expectations
- Fix: Ensure parameter types are correct (string, number, etc.)
- Not an error: Query works but returns no data
- Check: Verify your view has data matching the test criteria
Testing Different Scenarios
Test with Different Values
Use the Tool Call Arguments to test various scenarios: Scenario 1: Exact MatchTesting Multiple Parameters
If your tool has multiple parameters:Best Practices
Test Before Publishing
- ✅ Always test tools before publishing
- ✅ Test with realistic data values
- ✅ Test edge cases (empty strings, nulls, etc.)
- ✅ Verify results match expectations
Test Incrementally
When creating or editing tools:- Test Basic Query: Verify SQL works in SQL IDE
- Test with Parameters: Ensure parameter injection works
- Test Edge Cases: Try unusual inputs
- Test Performance: Check query execution time
Use Realistic Test Data
- ✅ Use values that represent real agent usage
- ✅ Test with data that exists in your view
- ✅ Try different parameter combinations
- ✅ Test with empty/null values if appropriate
Troubleshooting Test Failures
Issue: “Parameter not found”
Cause: Parameter placeholder in SQL doesn’t match parameter name Solution:Issue: “Query syntax error”
Cause: Invalid SQL syntax Solution:- Test the query manually in SQL IDE
- Replace placeholders with actual values
- Fix any syntax errors
- Update tool query
Issue: “No results returned”
Cause: Query executes but no data matches criteria Solution:- Verify your view has data
- Check if test values match data in view
- Try broader test criteria
- Review WHERE conditions
Issue: “Query timeout”
Cause: Query takes too long to execute Solution:- Add LIMIT to restrict results
- Refine WHERE conditions
- Optimize query performance
- Consider data volume
What to Verify
After a successful test, verify:- ✅ Correct Data: Results match what you expect
- ✅ Proper Filtering: WHERE conditions work correctly
- ✅ Sorting: ORDER BY works as intended
- ✅ Parameter Injection: Values are inserted correctly
- ✅ Performance: Query executes in reasonable time
- ✅ Data Structure: Columns and types are correct
Next Steps
Once your tool passes testing:- Publishing Tools - Make your tested tools available to agents
- Editing MCP Tools - Refine tools based on test results
Publish Your Tool
Make your tested tool available to AI agents