list-projects
Retrieve all projects from QA Studio; optionally filter by project name for targeted results.
Instructions
List all projects in QA Studio
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| search | No | Optional search query to filter projects by name |
Implementation Reference
- src/index.ts:49-83 (registration)Registration of the 'list-projects' tool via server.registerTool(), including its input schema (optional 'search' parameter) and the async handler function
// Register tool: list-projects server.registerTool( 'list-projects', { description: 'List all projects in QA Studio', inputSchema: { search: z.string().optional().describe('Optional search query to filter projects by name') } }, async (args) => { try { const { search } = args; const query = search ? `?search=${encodeURIComponent(search)}` : ''; const data = await apiRequest(`/projects${query}`); return { content: [ { type: 'text' as const, text: JSON.stringify(data, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text' as const, text: `Error: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } ); - src/index.ts:58-82 (handler)The handler function for 'list-projects' - calls the API endpoint /projects with an optional search query, returns the JSON response, or an error message on failure
async (args) => { try { const { search } = args; const query = search ? `?search=${encodeURIComponent(search)}` : ''; const data = await apiRequest(`/projects${query}`); return { content: [ { type: 'text' as const, text: JSON.stringify(data, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text' as const, text: `Error: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } - src/index.ts:52-56 (schema)Input schema for 'list-projects' defining an optional 'search' string parameter to filter projects by name
{ description: 'List all projects in QA Studio', inputSchema: { search: z.string().optional().describe('Optional search query to filter projects by name') } - src/index.ts:16-34 (helper)The apiRequest helper function used by the handler to make authenticated API calls to the QA Studio backend
// Helper function to make API requests async function apiRequest(endpoint: string, options: RequestInit = {}): Promise<any> { const url = `${API_URL}${endpoint}`; const response = await fetch(url, { ...options, headers: { 'Content-Type': 'application/json', 'X-API-Key': API_KEY, ...options.headers } }); if (!response.ok) { const error = await response.text(); throw new Error(`API Error (${response.status}): ${error}`); } return response.json(); }