get_active_test_runs
Retrieve currently executing performance tests from LoadRunner Cloud to monitor ongoing test execution status and progress.
Instructions
Get active test runs from LoadRunner Cloud.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_active_test_runs"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| status | No | The status of the test runs (RUNNING, INITIALIZING, CHECKING_STATUS, STOPPING, DELAYED). | |
| projectIds | No | The project IDs to filter the test runs (empty means all). |
Implementation Reference
- The main handler function `executeFunction` that fetches active test runs from LoadRunner Cloud. It handles authentication, constructs the API URL with optional filters (status, projectIds), makes a GET request, parses JSON response, and manages errors.
const executeFunction = async ({ status = '', projectIds = '' } = {}) => { const baseUrl = process.env.LRC_BASE_URL; const tenantId = process.env.LRC_TENANT_ID; const token = await getAuthToken(); try { // Construct the URL with query parameters const url = new URL(`${baseUrl}/test-runs/active`); url.searchParams.append('TENANTID', tenantId); if (status) url.searchParams.append('status', status); if (projectIds) url.searchParams.append('projectIds', projectIds); // Set up headers for the request const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }; // Perform the fetch request const response = await fetch(url.toString(), { method: 'GET', headers }); // Check if the response was successful if (!response.ok) { const text = await response.text(); try { const errorData = JSON.parse(text); throw new Error(JSON.stringify(errorData)); } catch (jsonErr) { // Not JSON, log the raw text console.error('Non-JSON error response:', text); throw new Error(text); } } // Parse and return the response data const text = await response.text(); try { const data = JSON.parse(text); return data; } catch (jsonErr) { // Not JSON, log the raw text console.error('Non-JSON success response:', text); return { error: 'Received non-JSON response from API', raw: text }; } } catch (error) { console.error('Error fetching active test runs:', error); return { error: 'An error occurred while fetching active test runs.' }; } }; - The input schema definition for the tool, specifying optional parameters `status` and `projectIds`.
parameters: { type: 'object', properties: { status: { type: 'string', description: 'The status of the test runs (RUNNING, INITIALIZING, CHECKING_STATUS, STOPPING, DELAYED).' }, projectIds: { type: 'string', description: 'The project IDs to filter the test runs (empty means all).' } }, required: [] } - tools/paths.js:3-3 (registration)The tool's file path is listed in `toolPaths` array, enabling dynamic discovery and loading.
'loadrunner-cloud/load-runner-cloud-api/test-runs-get-active-test-runs.js', - lib/tools.js:7-16 (registration)The `discoverTools` function dynamically imports the tool module using its path from `toolPaths` and extracts the `apiTool` object for registration in the MCP server.
export async function discoverTools() { const toolPromises = toolPaths.map(async (file) => { const module = await import(`../tools/${file}`); return { ...module.apiTool, path: file, }; }); return Promise.all(toolPromises); }