Skip to main content
Glama
pbandreddy

LoadRunner Cloud MCP Server

by pbandreddy

test_runs_getRecentTestRuns

Retrieve recent test run details from LoadRunner Cloud to monitor performance testing results and analyze trends over the past month.

Instructions

Get recent test runs details for the last month from LoadRunner Cloud. Optionally filter by projectIds.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdsNoOptional project IDs to filter the usage.

Implementation Reference

  • The core handler function `executeFunction` that makes an authenticated GET request to the LoadRunner Cloud `/license/usage` endpoint for recent test runs data over the last 30 days, optionally filtered by project IDs.
    const executeFunction = async ({ projectIds = '' } = {}) => {
      const baseUrl = process.env.LRC_BASE_URL;
      const tenantId = process.env.LRC_TENANT_ID;
      const token = await getAuthToken();
    
      // Calculate startTime and endTime for the last 1 month
      const endTime = Date.now();
      const startTime = endTime - 30 * 24 * 60 * 60 * 1000; // 30 days in ms
    
      try {
        // Construct the URL with query parameters
        const url = new URL(`${baseUrl}/license/usage`);
        url.searchParams.append('TENANTID', tenantId);
        if (projectIds) url.searchParams.append('projectIds', projectIds);
        url.searchParams.append('startTime', startTime);
        url.searchParams.append('endTime', endTime);
    
        // 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 license usage:', error);
        return { error: 'An error occurred while retrieving license usage.' };
      }
    };
  • The input schema definition for the tool, including the tool name, description, and parameters (optional `projectIds` string).
      type: 'function',
      function: {
        name: 'test_runs_getRecentTestRuns',
        description: 'Get recent test runs  details for the last month from LoadRunner Cloud. Optionally filter by projectIds.',
        parameters: {
          type: 'object',
          properties: {
            projectIds: {
              type: 'string',
              description: 'Optional project IDs to filter the usage.'
            }
          },
          required: []
        }
      }
    }
  • The `apiTool` object that packages the handler function and schema definition for dynamic registration in the MCP server.
    const apiTool = {
      function: executeFunction,
      definition: {
        type: 'function',
        function: {
          name: 'test_runs_getRecentTestRuns',
          description: 'Get recent test runs  details for the last month from LoadRunner Cloud. Optionally filter by projectIds.',
          parameters: {
            type: 'object',
            properties: {
              projectIds: {
                type: 'string',
                description: 'Optional project IDs to filter the usage.'
              }
            },
            required: []
          }
        }
      }
    };
    
    export { apiTool }; 
  • tools/paths.js:1-11 (registration)
    The `toolPaths` array that lists the path to this tool's file, enabling its discovery and import.
    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 that dynamically loads all `apiTool` objects from files listed in `toolPaths`, including this 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);
    }
  • mcpServer.js:40-160 (registration)
    The `setupServerHandlers` function in the MCP server that registers the list tools and call tool handlers, dynamically handling calls to `test_runs_getRecentTestRuns` by matching name and invoking its `function`.
    async function setupServerHandlers(server, tools) {
      server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: await transformTools(tools),
      }));
    
      server.setRequestHandler(CallToolRequestSchema, async (request) => {
        const toolName = request.params.name;
        const tool = tools.find((t) => t.definition.function.name === toolName);
        if (!tool) {
          throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${toolName}`);
        }
        const args = request.params.arguments;
        const requiredParameters =
          tool.definition?.function?.parameters?.required || [];
        for (const requiredParameter of requiredParameters) {
          if (!(requiredParameter in args)) {
            throw new McpError(
              ErrorCode.InvalidParams,
              `Missing required parameter: ${requiredParameter}`
            );
          }
        }
        try {
          const result = await tool.function(args);
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(result, null, 2),
              },
            ],
          };
        } catch (error) {
          console.error("[Error] Failed to fetch data:", error);
          throw new McpError(
            ErrorCode.InternalError,
            `API error: ${error.message}`
          );
        }
      });
    }
    
    async function run() {
      const args = process.argv.slice(2);
      const isSSE = args.includes("--sse");
      const tools = await discoverTools();
    
      if (isSSE) {
        const app = express();
        const transports = {};
        const servers = {};
    
        app.get("/sse", async (_req, res) => {
          // Create a new Server instance for each session
          const server = new Server(
            {
              name: SERVER_NAME,
              version: "0.1.0",
            },
            {
              capabilities: {
                tools: {},
              },
            }
          );
          server.onerror = (error) => console.error("[Error]", error);
          await setupServerHandlers(server, tools);
    
          const transport = new SSEServerTransport("/messages", res);
          transports[transport.sessionId] = transport;
          servers[transport.sessionId] = server;
    
          res.on("close", async () => {
            delete transports[transport.sessionId];
            await server.close();
            delete servers[transport.sessionId];
          });
    
          await server.connect(transport);
        });
    
        app.post("/messages", async (req, res) => {
          const sessionId = req.query.sessionId;
          const transport = transports[sessionId];
          const server = servers[sessionId];
    
          if (transport && server) {
            await transport.handlePostMessage(req, res);
          } else {
            res.status(400).send("No transport/server found for sessionId");
          }
        });
    
        const port = process.env.PORT || 3001;
        app.listen(port, () => {
          console.log(`[SSE Server] running on port ${port}`);
        });
      } else {
        // stdio mode: single server instance
        const server = new Server(
          {
            name: SERVER_NAME,
            version: "0.1.0",
          },
          {
            capabilities: {
              tools: {},
            },
          }
        );
        server.onerror = (error) => console.error("[Error]", error);
        await setupServerHandlers(server, tools);
    
        process.on("SIGINT", async () => {
          await server.close();
          process.exit(0);
        });
    
        const transport = new StdioServerTransport();
        await server.connect(transport);
      }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions the time scope ('last month') and optional filtering, but it doesn't disclose key behavioral traits such as whether this is a read-only operation, potential rate limits, authentication needs, or what the return format looks like (e.g., list structure, pagination). For a tool with no annotations, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose and includes the optional parameter detail. There is no wasted text, and it's appropriately sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a simple input schema with full coverage, the description is adequate but has clear gaps. It covers the basic purpose and parameter hint, but lacks details on behavior, return values, and differentiation from siblings. For a read operation with minimal complexity, it's minimally viable but not fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single parameter 'projectIds' with its type and optional nature. The description adds marginal value by reiterating the optional filtering, but it doesn't provide additional semantics like format examples or constraints beyond what the schema states. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and resource 'recent test runs details for the last month from LoadRunner Cloud', making the purpose specific. However, it doesn't explicitly differentiate from sibling tools like 'get_active_test_runs' or 'projects_getLoadTestRuns', which likely serve similar purposes, so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by mentioning 'Optionally filter by projectIds', which suggests when to use the optional parameter, but it doesn't provide explicit guidance on when to choose this tool over alternatives like 'get_active_test_runs' or 'projects_getLoadTestRuns'. No exclusions or detailed context are provided, leaving usage somewhat vague.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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