get_jira_project
Retrieve comprehensive metadata for a Jira project using its key or ID to access project details and structure.
Instructions
Get full metadata for a Jira project by key or ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectIdOrKey | Yes | Project key or ID (e.g., PROJ or 10001) |
Implementation Reference
- src/server.ts:193-209 (handler)The handler function that fetches and returns detailed metadata for a specified Jira project using the REST API endpoint /rest/api/3/project/{projectIdOrKey}, including error handling and structured content.async (args: { projectIdOrKey: string }) => { try { const url = `${JIRA_URL}/rest/api/3/project/${encodeURIComponent(args.projectIdOrKey)}`; const response = await fetch(url, { method: "GET", headers: getJiraHeaders() }); if (!response.ok) { const errorText = await response.text(); return { content: [{ type: "text", text: `Failed to get project ${args.projectIdOrKey}: ${response.status} ${response.statusText}\n${errorText}` }], isError: true }; } const project = await response.json() as any; return { content: [{ type: "text", text: `Project ${project.key}: ${project.name}` }], structuredContent: { id: project.id, key: project.key, name: project.name, url: `${JIRA_URL}/jira/software/c/projects/${project.key}`, lead: project.lead, components: project.components, issueTypes: project.issueTypes, raw: project }, }; } catch (error) { return { content: [{ type: "text", text: `Error getting project ${args.projectIdOrKey}: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }
- src/server.ts:189-191 (schema)Zod-based input schema defining the required 'projectIdOrKey' parameter for the tool.inputSchema: { projectIdOrKey: z.string().describe("Project key or ID (e.g., PROJ or 10001)"), },
- src/server.ts:185-210 (registration)MCP tool registration call that defines the tool name, title, description, input schema, and attaches the handler function."get_jira_project", { title: "Get Jira Project Details", description: "Get full metadata for a Jira project by key or ID.", inputSchema: { projectIdOrKey: z.string().describe("Project key or ID (e.g., PROJ or 10001)"), }, }, async (args: { projectIdOrKey: string }) => { try { const url = `${JIRA_URL}/rest/api/3/project/${encodeURIComponent(args.projectIdOrKey)}`; const response = await fetch(url, { method: "GET", headers: getJiraHeaders() }); if (!response.ok) { const errorText = await response.text(); return { content: [{ type: "text", text: `Failed to get project ${args.projectIdOrKey}: ${response.status} ${response.statusText}\n${errorText}` }], isError: true }; } const project = await response.json() as any; return { content: [{ type: "text", text: `Project ${project.key}: ${project.name}` }], structuredContent: { id: project.id, key: project.key, name: project.name, url: `${JIRA_URL}/jira/software/c/projects/${project.key}`, lead: project.lead, components: project.components, issueTypes: project.issueTypes, raw: project }, }; } catch (error) { return { content: [{ type: "text", text: `Error getting project ${args.projectIdOrKey}: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
- src/server.ts:37-44 (helper)Utility function that generates the HTTP headers required for authenticated requests to the Jira API, using environment variables for credentials.function getJiraHeaders(): Record<string, string> { const auth = Buffer.from(`${JIRA_EMAIL}:${JIRA_API_TOKEN}`).toString('base64'); return { 'Authorization': `Basic ${auth}`, 'Accept': 'application/json', 'Content-Type': 'application/json', }; }