Skip to main content
Glama
pbandreddy

LoadRunner Cloud MCP Server

by pbandreddy

projects_getLoadTests

Retrieve load tests for a project from LoadRunner Cloud to analyze performance test data and manage testing workflows.

Instructions

Retrieve load tests for a project from LoadRunner Cloud.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesThe ID of the project.

Implementation Reference

  • The handler function `executeFunction` that performs the API call to retrieve load tests for a given projectId from LoadRunner Cloud.
    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.' };
      }
    };
  • Input schema defining the required 'projectId' parameter as a string.
    parameters: {
      type: 'object',
      properties: {
        projectId: {
          type: 'string',
          description: 'The ID of the project.'
        }
      },
      required: ['projectId']
    }
  • tools/paths.js:1-11 (registration)
    The toolPaths array includes the path to this tool's file, enabling its dynamic loading.
    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'
    ];
  • lib/tools.js:7-16 (registration)
    The `discoverTools` function dynamically imports all tools from toolPaths and spreads their apiTool exports to register them.
    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);
    }
  • Supporting `getAuthToken` function used by the handler to obtain authentication token for API requests.
    const getAuthToken = async () => {
      const baseUrl = process.env.LRC_BASE_URL;
      const tenantId = process.env.LRC_TENANT_ID;
      const clientId = process.env.LRC_CLIENT_ID;
      const clientSecret = process.env.LRC_CLIENT_SECRET;
    
      try {
        const url = new URL(`${baseUrl}/auth-client`);
        url.searchParams.append('TENANTID', tenantId);
    
        const headers = {
          'Content-Type': 'application/json',
          'accept': 'application/json'
        };
    
        const body = JSON.stringify({
          client_id: clientId,
          client_secret: clientSecret
        });
    
        const response = await fetch(url.toString(), {
          method: 'POST',
          headers,
          body
        });
    
        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);
          }
        }
    
        const data = await response.json();
        // Adjust according to actual API response structure
        return data.access_token || data.token || data;
      } catch (error) {
        console.error('Error retrieving auth token:', error);
        return { error: 'An error occurred while retrieving auth token.' };
      }
    };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pbandreddy/loadrunner-cloud-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server