get_projects
Retrieve performance testing projects from a BlazeMeter workspace to manage and analyze test configurations and results.
Instructions
Get projects from a specified workspace.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspaceId | No | The ID of the workspace to retrieve projects from. |
Implementation Reference
- The handler function that executes the logic to fetch projects from the BlazeMeter API using the workspaceId parameter or environment variable.const executeFunction = async ({ workspaceId } = {}) => { const baseUrl = process.env.BASE_URL; // loaded from .env const username = process.env.BZM_USERNAME; // loaded from .env const password = process.env.BZM_PASSWORD; // loaded from .env const resolvedWorkspaceId = workspaceId || process.env.BZM_WORKSPACE_ID; try { // Construct the URL with query parameters const url = new URL(`${baseUrl}/api/v4/projects`); url.searchParams.append('workspaceId', resolvedWorkspaceId); // Set up headers for the request const headers = { 'Authorization': 'Basic ' + Buffer.from(`${username}:${password}`).toString('base64'), 'Accept': 'application/json' }; // Perform the fetch request const response = await fetch(url.toString(), { method: 'GET', headers }); // Check if the response was successful if (!response.ok) { let errorData; try { errorData = await response.json(); } catch (jsonErr) { errorData = await response.text(); } throw new Error(`HTTP ${response.status} ${response.statusText}: ${typeof errorData === 'string' ? errorData : JSON.stringify(errorData)}`); } // Parse and return the response data const data = await response.json(); return data; } catch (error) { if (error instanceof Error) { return { error: error.message }; } else { return { error: 'Unknown error occurred while getting projects.' }; } } };
- tools/blazemeter/new-collection/get-project-list.js:61-82 (registration)The tool registration object `apiTool` that defines the tool name 'get_projects', its schema (parameters), description, and links to the handler function. Exported for use in MCP tool registration.const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'get_projects', description: 'Get projects from a specified workspace.', parameters: { type: 'object', properties: { workspaceId: { type: 'string', description: 'The ID of the workspace to retrieve projects from.' } }, required: [] } } } }; export { apiTool };
- The input schema defining the optional 'workspaceId' parameter for the get_projects tool.parameters: { type: 'object', properties: { workspaceId: { type: 'string', description: 'The ID of the workspace to retrieve projects from.' } }, required: [] } }