goalstory_update_self_user
Update your Goal Story profile by modifying your name, privacy settings, or personal context. Use guided questions to refine your motivations, beliefs, and approach to achieving goals, ensuring accurate and meaningful profile details.
Instructions
Update the user's profile including their name, visibility preferences, and personal context. When updating 'about' data, guide the user through questions to understand their motivations, beliefs, and goal-achievement style.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| about | No | Personal context including motivations, beliefs, and goal-achievement preferences gathered through guided questions. | |
| name | No | The user's preferred name for their Goal Story profile. | |
| visibility | No | Profile visibility setting where 0 = public (viewable by others) and 1 = private (only visible to user). |
Implementation Reference
- src/index.ts:195-216 (handler)The core handler logic that processes tool arguments, constructs a PATCH request body for updating user profile (name, about, visibility), calls the doRequest helper to interact with the GoalStory API, and returns a formatted text response with the updated user data.async (args) => { const url = `${GOALSTORY_API_BASE_URL}/users`; const body = { ...(args.name ? { name: args.name } : {}), ...(args.about ? { about: args.about } : {}), ...(typeof args.visibility === "number" ? { visibility: args.visibility, } : {}), }; const result = await doRequest(url, "PATCH", body); return { content: [ { type: "text", text: `Updated user:\n${JSON.stringify(result, null, 2)}`, }, ], isError: false, }; },
- src/index.ts:191-217 (registration)MCP server registration of the 'goalstory_update_self_user' tool, referencing the tool definition from tools.ts for name, description, and schema, with an inline asynchronous handler function.server.tool( UPDATE_SELF_USER_TOOL.name, UPDATE_SELF_USER_TOOL.description, UPDATE_SELF_USER_TOOL.inputSchema.shape, async (args) => { const url = `${GOALSTORY_API_BASE_URL}/users`; const body = { ...(args.name ? { name: args.name } : {}), ...(args.about ? { about: args.about } : {}), ...(typeof args.visibility === "number" ? { visibility: args.visibility, } : {}), }; const result = await doRequest(url, "PATCH", body); return { content: [ { type: "text", text: `Updated user:\n${JSON.stringify(result, null, 2)}`, }, ], isError: false, }; }, );
- src/tools.ts:29-51 (schema)Tool definition object containing the name, description, and Zod inputSchema for validation of arguments (name, about, visibility fields). This is imported and used in index.ts for tool registration.export const UPDATE_SELF_USER_TOOL = { name: "goalstory_update_self_user", description: "Update the user's profile including their name, visibility preferences, and personal context. When updating 'about' data, guide the user through questions to understand their motivations, beliefs, and goal-achievement style.", inputSchema: z.object({ name: z .string() .optional() .describe("The user's preferred name for their Goal Story profile."), about: z .string() .optional() .describe( "Personal context including motivations, beliefs, and goal-achievement preferences gathered through guided questions.", ), visibility: z .number() .optional() .describe( "Profile visibility setting where 0 = public (viewable by others) and 1 = private (only visible to user).", ), }), };
- src/types.ts:7-11 (schema)TypeScript interface defining the expected input shape for the tool, matching the Zod schema.export interface GoalstoryUpdateSelfUserInput { name?: string; about?: string; visibility?: number; // 0=public, 1=private }
- src/index.ts:62-122 (helper)Reusable helper function for making authenticated HTTP requests to the GoalStory API backend, used by all tools including this one. Handles logging, timeouts, and comprehensive error messages.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)}`, ); } } }