get-objective
Retrieve Shortcut objectives by public ID, offering full or slim field options, enabling efficient project management integration via the Shortcut MCP Server.
Instructions
Get a Shortcut objective by public ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| full | No | True to return all objective fields from the API. False to return a slim version that excludes uncommon fields | |
| objectivePublicId | Yes | The public ID of the objective to get |
Implementation Reference
- src/tools/objectives.ts:88-98 (handler)The main handler function that implements the logic for retrieving a specific Shortcut objective (milestone) by its public ID, fetches related data, and formats the response.async getObjective(objectivePublicId: number, full = false) { const objective = await this.client.getMilestone(objectivePublicId); if (!objective) throw new Error(`Failed to retrieve Shortcut objective with public ID: ${objectivePublicId}`); return this.toResult( `Objective: ${objectivePublicId}`, await this.entityWithRelatedEntities(objective, "objective", full), ); }
- src/tools/objectives.ts:12-26 (registration)Registers the MCP tool named 'objectives-get-by-id' (the get-objective tool), including its description, input schema, and links to the handler.server.addToolWithReadAccess( "objectives-get-by-id", "Get a Shortcut objective by public ID", { objectivePublicId: z.number().positive().describe("The public ID of the objective to get"), full: z .boolean() .optional() .default(false) .describe( "True to return all objective fields from the API. False to return a slim version that excludes uncommon fields", ), }, async ({ objectivePublicId, full }) => await tools.getObjective(objectivePublicId, full), );
- src/server.ts:50-50 (registration)Initializes the ObjectiveTools instance and adds its tools (including get-objective) to the MCP server.ObjectiveTools.create(client, server);
- src/tools/objectives.ts:16-24 (schema)Zod schema defining the input parameters for the get-objective tool: objectivePublicId (required number) and full (optional boolean).objectivePublicId: z.number().positive().describe("The public ID of the objective to get"), full: z .boolean() .optional() .default(false) .describe( "True to return all objective fields from the API. False to return a slim version that excludes uncommon fields", ), },
- src/tools/base.ts:601-623 (helper)Helper method used by the handler to fetch and attach related entities (users, teams, etc.) to the objective data.protected async entityWithRelatedEntities( entity: | Story | StorySearchResult | StorySlim | Epic | EpicSearchResult | Iteration | IterationSlim | Group | Workflow | ObjectiveSearchResult | Milestone, entityType = "entity", full = false, ) { const finalEntity = full ? entity : this.getSimplifiedEntity(entity, "simple"); const relatedEntities = await this.getRelatedEntities(entity, full ? "full" : "simple"); return { [entityType]: this.renameEntityProps(finalEntity as unknown as Record<string, unknown>), relatedEntities, }; }