list_projects
Retrieve a specified number of Jira projects using the REST API endpoint /rest/api/3/project. Ideal for managing and organizing project data efficiently.
Instructions
List all the projects on Jira on the api /rest/api/3/project. Do not use markdown in your query.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| number_of_results | No | Number of results to return |
Implementation Reference
- src/index.ts:537-555 (handler)Core handler function that executes the tool logic by fetching projects from the Jira API endpoint /rest/api/3/project with the specified maxResults parameter.async function listProjects(number_of_results: number): Promise<any> { try { const params = { maxResults: number_of_results, // Adjust as needed }; const response = await axios.get(`${JIRA_URL}/rest/api/3/project`, { headers: getAuthHeaders().headers, params, }); return response.data; } catch (error: any) { //return the error in a json return { error: error.response.data, }; } }
- src/index.ts:803-818 (handler)Tool dispatch handler within the CallToolRequestSchema that extracts input arguments, calls listProjects, and formats the response as MCP content.case 'list_projects': { const number_of_results = Number( request.params.arguments?.number_of_results ?? 1, ); const response = await listProjects(number_of_results); return { content: [ { type: 'text', text: JSON.stringify(response, null, 2), }, ], }; }
- src/index.ts:126-139 (registration)Registers the 'list_projects' tool in the ListToolsRequestSchema response, including name, description, and input schema.name: 'list_projects', description: 'List all the projects on Jira on the api /rest/api/3/project. Do not use markdown in your query.', inputSchema: { type: 'object', properties: { number_of_results: { type: 'integer', description: 'Number of results to return', default: 1, }, }, }, },
- src/index.ts:521-531 (helper)Helper function providing authentication headers used by listProjects to authenticate API requests to Jira.function getAuthHeaders(): AxiosRequestConfig<any> { const authHeader = `Basic ${Buffer.from( `${JIRA_API_MAIL}:${JIRA_API_KEY}`, ).toString('base64')}`; return { headers: { Authorization: authHeader, 'Content-Type': 'application/json', }, }; }