get_projects
Discover available Jira projects and retrieve their keys, names, IDs, and metadata to prepare for issue creation or other operations.
Instructions
Retrieve all Jira projects accessible to the authenticated user. Returns project keys, names, IDs, and basic metadata. Use this to discover available projects before creating issues or performing other operations.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expand | No | Comma-separated list of additional data to include: description,lead,issueTypes,url,projectKeys,permissions,insight | |
| recent | No | Return only recently viewed projects (0-20). Useful for quick access to frequently used projects. |
Implementation Reference
- src/tools/projects.ts:48-69 (handler)Handler function for the 'get_projects' tool. Validates args using the schema, calls jiraClient.getProjects(), extracts essential fields (key, name, id, projectTypeKey) and returns them as JSON text content.
case 'get_projects': { const validatedArgs = await getProjectsSchema.validate(args); const projects = await jiraClient.getProjects(validatedArgs); // Extract only essential fields to reduce token usage const pageProject = projects; const essentialProjects = pageProject.values?.map((project) => ({ key: project.key, name: project.name, id: project.id, projectTypeKey: project.projectTypeKey })) || []; return { content: [ { type: 'text', text: JSON.stringify(essentialProjects, null, 2), }, ], }; } - src/schemas/index.ts:109-113 (schema)Yup validation schema for get_projects. Defines optional 'expand' (string) and 'recent' (number) input fields.
// Schema for getting projects export const getProjectsSchema = yup.object({ expand: yup.string().optional(), recent: yup.number().optional(), }); - src/tools/projects.ts:7-24 (registration)Tool registration/definition: name 'get_projects', description, and input JSON Schema for expand (string) and recent (number). Created via createProjectTools() which is called in src/index.ts.
return [ { name: 'get_projects', description: 'Retrieve all Jira projects accessible to the authenticated user. Returns project keys, names, IDs, and basic metadata. Use this to discover available projects before creating issues or performing other operations.', inputSchema: { type: 'object', properties: { expand: { type: 'string', description: 'Comma-separated list of additional data to include: description,lead,issueTypes,url,projectKeys,permissions,insight', }, recent: { type: 'number', description: 'Return only recently viewed projects (0-20). Useful for quick access to frequently used projects.', }, }, }, }, - src/index.ts:69-71 (registration)Routing in the main server: tools starting with 'get_projects' are routed to handleProjectTool().
if (name.startsWith('get_projects') || name.startsWith('get_issue_types')) { return await handleProjectTool(name, args || {}, this.jiraClient); } else if ( - src/jira-client.ts:81-91 (helper)JiraClient.getProjects method. Calls jira.js SDK's projects.searchProjects() with optional expand parameter and returns the response.
// Get all projects async getProjects(input: GetProjectsInput = {}) { try { const response = await this.jira.projects.searchProjects({ expand: input.expand, }); return response; } catch (error) { throw new Error(`Failed to get projects: ${error instanceof Error ? error.message : 'Unknown error'}`); } }