goalstory_count_goals
Count total goals in your journey to track progress and manage goal patterns.
Instructions
Get the total number of goals in the user's journey. Useful for tracking overall progress and goal management patterns.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:222-239 (handler)The tool handler registered via server.tool(). It makes a GET request to the '/count/goals' API endpoint using the shared doRequest helper and formats the response as MCP content.server.tool( COUNT_GOALS_TOOL.name, COUNT_GOALS_TOOL.description, COUNT_GOALS_TOOL.inputSchema.shape, async (args) => { const url = `${GOALSTORY_API_BASE_URL}/count/goals`; const result = await doRequest(url, "GET"); return { content: [ { type: "text", text: `Count of goals:\n${JSON.stringify(result, null, 2)}`, }, ], isError: false, }; }, );
- src/tools.ts:56-61 (schema)Tool metadata including name, description, and empty Zod input schema (no parameters required).export const COUNT_GOALS_TOOL = { name: "goalstory_count_goals", description: "Get the total number of goals in the user's journey. Useful for tracking overall progress and goal management patterns.", inputSchema: z.object({}), };
- src/types.ts:13-13 (schema)TypeScript interface for the tool input (empty).export interface GoalstoryCountGoalsInput {}
- src/index.ts:62-122 (helper)Shared HTTP request helper function used by all API-interacting tools, including goalstory_count_goals.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:19-43 (registration)Import of the COUNT_GOALS_TOOL constant from tools.ts for use in server.tool registration.COUNT_GOALS_TOOL, CREATE_GOAL_TOOL, CREATE_SCHEDULED_STORY_TOOL, CREATE_STEPS_TOOL, CREATE_STORY_TOOL, DESTROY_GOAL_TOOL, DESTROY_SCHEDULED_STORY_TOOL, DESTROY_STEP_TOOL, GET_STORY_CONTEXT_TOOL, READ_CURRENT_FOCUS_TOOL, READ_GOALS_TOOL, READ_ONE_GOAL_TOOL, READ_ONE_STEP_TOOL, READ_ONE_STORY_TOOL, READ_SCHEDULED_STORIES_TOOL, READ_SELF_USER_TOOL, READ_STEPS_TOOL, READ_STORIES_TOOL, SET_STEPS_ORDER_TOOL, UPDATE_GOAL_TOOL, UPDATE_SCHEDULED_STORY_TOOL, UPDATE_SELF_USER_TOOL, UPDATE_STEP_NOTES_TOOL, UPDATE_STEP_TOOL, } from "./tools.js";