Skip to main content
Glama
ampcome-mcps

Shortcut MCP Server

by ampcome-mcps

add-relation-to-story

Link stories in Shortcut by establishing relationships like blocks, duplicates, or relates to connections between work items.

Instructions

Add a story relationship to a story

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
storyPublicIdYesThe public ID of the story
relatedStoryPublicIdYesThe public ID of the related story
relationshipTypeNoThe type of relationshiprelates to

Implementation Reference

  • The handler function that executes the tool logic: validates inputs, fetches stories, adjusts relationship direction if needed (for 'blocked by' or 'duplicated by'), calls the client to add the relation, and returns a success message.
    async addRelationToStory({
    	storyPublicId,
    	relatedStoryPublicId,
    	relationshipType,
    }: {
    	storyPublicId: number;
    	relatedStoryPublicId: number;
    	relationshipType: "relates to" | "blocks" | "blocked by" | "duplicates" | "duplicated by";
    }) {
    	if (!storyPublicId) throw new Error("Story public ID is required");
    	if (!relatedStoryPublicId) throw new Error("Related story public ID is required");
    
    	const story = await this.client.getStory(storyPublicId);
    	if (!story)
    		throw new Error(`Failed to retrieve Shortcut story with public ID: ${storyPublicId}`);
    
    	const relatedStory = await this.client.getStory(relatedStoryPublicId);
    	if (!relatedStory)
    		throw new Error(`Failed to retrieve Shortcut story with public ID: ${relatedStoryPublicId}`);
    
    	let subjectStoryId = storyPublicId;
    	let objectStoryId = relatedStoryPublicId;
    
    	if (relationshipType === "blocked by" || relationshipType === "duplicated by") {
    		relationshipType = relationshipType === "blocked by" ? "blocks" : "duplicates";
    		subjectStoryId = relatedStoryPublicId;
    		objectStoryId = storyPublicId;
    	}
    
    	await this.client.addRelationToStory(subjectStoryId, objectStoryId, relationshipType);
    
    	return this.toResult(
    		relationshipType === "blocks"
    			? `Marked sc-${subjectStoryId} as a blocker to sc-${objectStoryId}.`
    			: relationshipType === "duplicates"
    				? `Marked sc-${subjectStoryId} as a duplicate of sc-${objectStoryId}.`
    				: `Added a relationship between sc-${subjectStoryId} and sc-${objectStoryId}.`,
    	);
    }
  • Zod schema defining the input parameters for the tool: storyPublicId, relatedStoryPublicId, and optional relationshipType.
    	storyPublicId: z.number().positive().describe("The public ID of the story"),
    	relatedStoryPublicId: z.number().positive().describe("The public ID of the related story"),
    	relationshipType: z
    		.enum(["relates to", "blocks", "blocked by", "duplicates", "duplicated by"])
    		.optional()
    		.default("relates to")
    		.describe("The type of relationship"),
    },
  • Registers the MCP tool 'add-relation-to-story' with the server, including description, input schema, and handler reference.
    server.tool(
    	"add-relation-to-story",
    	"Add a story relationship to a story",
    	{
    		storyPublicId: z.number().positive().describe("The public ID of the story"),
    		relatedStoryPublicId: z.number().positive().describe("The public ID of the related story"),
    		relationshipType: z
    			.enum(["relates to", "blocks", "blocked by", "duplicates", "duplicated by"])
    			.optional()
    			.default("relates to")
    			.describe("The type of relationship"),
    	},
    	async (params) => await tools.addRelationToStory(params),
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ampcome-mcps/shortcut-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server