goalstory_update_scheduled_story
Modify scheduled story configurations on the Goal Story MCP Server, including updating generation times or toggling active/paused status for personalized goal narratives.
Instructions
Update the configuration of a scheduled story generation, such as changing the time or its status (active/paused).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Unique identifier of the scheduled story configuration to update. | |
| status | No | Status of the scheduled story: 0 = Active, 1 = Paused. Check ScheduledStoryStatus enum for exact values if available. | |
| timeSettings | No | Specifies the time of day (hour and minute) for the scheduled story generation. |
Implementation Reference
- src/index.ts:778-800 (handler)The core handler function for the 'goalstory_update_scheduled_story' tool. It constructs a PATCH request to the backend API endpoint '/schedules/stories/{id}' with the provided id, optional timeSettings, and optional status, then returns the formatted response.server.tool( UPDATE_SCHEDULED_STORY_TOOL.name, UPDATE_SCHEDULED_STORY_TOOL.description, UPDATE_SCHEDULED_STORY_TOOL.inputSchema.shape, async (args) => { const url = `${GOALSTORY_API_BASE_URL}/schedules/stories/${args.id}`; const body = { id: args.id, ...(args.timeSettings ? { timeSettings: args.timeSettings } : {}), ...(typeof args.status === "number" ? { status: args.status } : {}), }; const result = await doRequest(url, "PATCH", body); return { content: [ { type: "text", text: `Scheduled story updated:\n${JSON.stringify(result, null, 2)}`, }, ], isError: false, }; }, );
- src/tools.ts:508-526 (schema)The schema definition for the tool, including name, description, and input schema with Zod validation for id, optional timeSettings (referencing TimeSettingsSchema), and optional status.export const UPDATE_SCHEDULED_STORY_TOOL = { name: "goalstory_update_scheduled_story", description: "Update the configuration of a scheduled story generation, such as changing the time or its status (active/paused).", inputSchema: z.object({ id: z .string() .describe( "Unique identifier of the scheduled story configuration to update.", ), timeSettings: TimeSettingsSchema.optional(), status: z .number() .optional() .describe( "Status of the scheduled story: 0 = Active, 1 = Paused. Check ScheduledStoryStatus enum for exact values if available.", ), }), };
- src/tools.ts:412-465 (schema)The shared TimeSettingsSchema used in the inputSchema for defining time settings (hour, period, utcOffset).export const TimeSettingsSchema = z .object({ hour: z.enum([ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", ]), period: z.enum(["AM", "PM"]), utcOffset: z .enum([ "-12:00", "-11:00", "-10:00", "-09:00", "-08:00", "-07:00", "-06:00", "-05:00", "-04:00", "-03:00", "-02:00", "-01:00", "±00:00", "+01:00", "+02:00", "+03:00", "+04:00", "+05:00", "+06:00", "+07:00", "+08:00", "+09:00", "+10:00", "+11:00", "+12:00", "+13:00", "+14:00", ]) .describe( "Choose a current UTC offset based on the user's location (accounting for adjustments like daylight savings time for instance). For example, the UTC offset for Los Angeles, California is -08:00 during standard time (PST, Pacific Standard Time) and -07:00 during daylight saving time (PDT, Pacific Daylight Time).", ), }) .describe( "Specifies the time of day (hour and minute) for the scheduled story generation.", );
- src/index.ts:62-122 (helper)The doRequest helper function used by all tool handlers to make authenticated HTTP requests to the GoalStory backend API, with logging, timeout, and comprehensive error handling.async function doRequest<T = any>( url: string, method: string, body?: unknown, ): Promise<T> { console.error("Making request to:", url); console.error("Method:", method); console.error("Body:", body ? JSON.stringify(body) : "none"); try { const response = await axios({ url, method, headers: { "Content-Type": "application/json", Authorization: `Bearer ${GOALSTORY_API_TOKEN}`, }, data: body, timeout: 10000, // 10 second timeout validateStatus: function (status) { return status >= 200 && status < 500; // Accept all status codes less than 500 }, }); console.error("Response received:", response.status); return response.data as T; } catch (err) { console.error("Request failed with error:", err); if (axios.isAxiosError(err)) { if (err.code === "ECONNABORTED") { throw new Error( `Request timed out after 10 seconds. URL: ${url}, Method: ${method}`, ); } if (err.response) { // The request was made and the server responded with a status code // that falls out of the range of 2xx throw new Error( `HTTP Error ${ err.response.status }. URL: ${url}, Method: ${method}, Body: ${JSON.stringify( body, )}. Error text: ${JSON.stringify(err.response.data)}`, ); } else if (err.request) { // The request was made but no response was received throw new Error( `No response received from server. URL: ${url}, Method: ${method}`, ); } else { // Something happened in setting up the request that triggered an Error throw new Error(`Request setup failed: ${err.message}`); } } else { // Something else happened throw new Error( `Unexpected error: ${err instanceof Error ? err.message : String(err)}`, ); } } }
- src/index.ts:778-800 (registration)The MCP server.tool registration call that registers the tool with its name, description, input schema shape, and handler function.server.tool( UPDATE_SCHEDULED_STORY_TOOL.name, UPDATE_SCHEDULED_STORY_TOOL.description, UPDATE_SCHEDULED_STORY_TOOL.inputSchema.shape, async (args) => { const url = `${GOALSTORY_API_BASE_URL}/schedules/stories/${args.id}`; const body = { id: args.id, ...(args.timeSettings ? { timeSettings: args.timeSettings } : {}), ...(typeof args.status === "number" ? { status: args.status } : {}), }; const result = await doRequest(url, "PATCH", body); return { content: [ { type: "text", text: `Scheduled story updated:\n${JSON.stringify(result, null, 2)}`, }, ], isError: false, }; }, );