projects_getLoadTests
Retrieve load tests for a specific project in LoadRunner Cloud using the project ID. Facilitates access to performance test data for analysis and integration into engineering workflows.
Instructions
Retrieve load tests for a project from LoadRunner Cloud.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | The ID of the project. |
Implementation Reference
- The handler function that authenticates using getAuthToken, constructs the API URL for the project's load tests, performs a GET request with bearer token, handles responses and errors, and returns the list of load tests.const executeFunction = async ({ projectId }) => { 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}/projects/${projectId}/load-tests`); url.searchParams.append('TENANTID', tenantId); // 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 retrieving load tests:', error); return { error: 'An error occurred while retrieving load tests.' }; } };
- The JSON schema definition for the tool, specifying the name, description, input parameters (projectId: string, required), used for MCP tool validation.type: 'function', function: { name: 'projects_getLoadTests', description: 'Retrieve load tests for a project from LoadRunner Cloud.', parameters: { type: 'object', properties: { projectId: { type: 'string', description: 'The ID of the project.' } }, required: ['projectId'] } } }
- lib/tools.js:7-16 (registration)The discoverTools function that dynamically imports each tool file from paths.js (including projects-get-load-tests.js), extracts and spreads the apiTool object to register it as an MCP tool.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); }
- tools/paths.js:1-11 (registration)The list of all tool file paths, including the path to projects-get-load-tests.js, used by discoverTools to load and register all LoadRunner Cloud tools.export const toolPaths = [ 'loadrunner-cloud/load-runner-cloud-api/projects-get-projects.js', 'loadrunner-cloud/load-runner-cloud-api/test-runs-get-active-test-runs.js', 'loadrunner-cloud/load-runner-cloud-api/test-runs-get-test-run-transactions.js', 'loadrunner-cloud/load-runner-cloud-api/test-runs-get-test-run-summary.js', 'loadrunner-cloud/load-runner-cloud-api/test-runs-get-http-responses.js', 'loadrunner-cloud/load-runner-cloud-api/test-runs-get-test-run-recent.js', 'loadrunner-cloud/load-runner-cloud-api/projects-get-load-tests.js', 'loadrunner-cloud/load-runner-cloud-api/projects-get-load-test-scripts.js', 'loadrunner-cloud/load-runner-cloud-api/projects-get-load-test-runs.js' ];