list_projects
Get a list of Jira projects, filtered by query or with expanded details like description, lead, and issue types.
Instructions
List projects from Jira
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_projects"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxResults | No | The maximum number of results to return, (max: 100) | |
| query | No | A query string used to filter the returned projects. The query string cannot be used with the startAt and maxResults parameters. | |
| expand | No | Use this parameter to include additional information in the response. This parameter accepts a comma-separated list. Expand options include: `description`, `lead`, `issueTypes`, `url`, `projectKeys`, `permissions`, `insight`. Comma separated list of options. |
Implementation Reference
- src/tools/list_projects.ts:37-52 (handler)The `listProjects` async function that fetches projects from Jira's REST API. It builds a URL with optional query, maxResults, and expand parameters, calls $jiraJson, and returns the result.
export async function listProjects(input: ListProjectsInput) { const url = new URL(`/rest/api/2/project`, env.JIRA_BASE_URL); if (input.maxResults) url.searchParams.set("maxResults", input.maxResults.toString()); if (input.query) url.searchParams.set("query", input.query); if (input.expand) url.searchParams.set("expand", input.expand); const json = await $jiraJson(url.toString()); if (json.isErr()) return err(json.error); return ok(json.value); } - src/tools/list_projects.ts:10-27 (schema)The Zod schema (`listProjectsInputSchema`) that validates input parameters: maxResults (number, optional), query (string, optional), expand (string, optional).
export const listProjectsInputSchema = z.object({ maxResults: z .number() .optional() .describe("The maximum number of results to return, (max: 100)"), query: z .string() .optional() .describe( "A query string used to filter the returned projects. The query string cannot be used with the startAt and maxResults parameters.", ), expand: z .string() .optional() .describe( "Use this parameter to include additional information in the response. This parameter accepts a comma-separated list. Expand options include: `description`, `lead`, `issueTypes`, `url`, `projectKeys`, `permissions`, `insight`. Comma separated list of options.", ), }); - src/tools/list_projects.ts:29-48 (registration)The tool definition (`LIST_PROJECTS_TOOL`) with name 'list_projects', description, and inputSchema registered as a Tool object.
export const LIST_PROJECTS_TOOL: Tool = { name: "list_projects", description: "List projects from Jira", inputSchema: zodToJsonSchema(listProjectsInputSchema) as Tool["inputSchema"], }; export type ListProjectsInput = z.output<typeof listProjectsInputSchema>; export async function listProjects(input: ListProjectsInput) { const url = new URL(`/rest/api/2/project`, env.JIRA_BASE_URL); if (input.maxResults) url.searchParams.set("maxResults", input.maxResults.toString()); if (input.query) url.searchParams.set("query", input.query); if (input.expand) url.searchParams.set("expand", input.expand); const json = await $jiraJson(url.toString()); - src/app.ts:39-41 (registration)The tool is added to the `tools` array exported from app.ts, which is used to register all tools with the MCP server.
export const tools = [ // list LIST_PROJECTS_TOOL, - src/app.ts:88-113 (handler)The CallToolRequestSchema handler that routes 'list_projects' requests: parses input, calls listProjects, and formats the response.
if (name === LIST_PROJECTS_TOOL.name) { const input = listProjectsInputSchema.safeParse(args); if (!input.success) { return { isError: true, content: [{ type: "text", text: "Invalid input" }], }; } const result = await listProjects(input.data); if (result.isErr()) { console.error(result.error.message); return { isError: true, content: [{ type: "text", text: "An error occurred" }], }; } return { content: [ { type: "text", text: JSON.stringify(result.value, null, 2) }, ], }; }