get_projects
Retrieve all projects within a specific workspace from the BlazeMeter MCP Server to manage and analyze performance testing data programmatically.
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 core handler function `executeFunction` that makes an authenticated GET request to the BlazeMeter API to retrieve projects for a workspace.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.' }; } } };
- The JSON schema defining the tool 'get_projects', including its name, description, and optional 'workspaceId' parameter.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: [] } } }
- tools/blazemeter/new-collection/get-project-list.js:61-82 (registration)The `apiTool` object that bundles the handler function and schema definition, exported for dynamic loading.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 };
- tools/paths.js:3-3 (registration)The tool path is listed in `toolPaths` array, enabling its discovery and import.'blazemeter/new-collection/get-project-list.js',
- lib/tools.js:7-16 (registration)The `discoverTools` function dynamically imports and registers all tools from `toolPaths`, including get_projects by spreading `module.apiTool`.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); }