goalstory_read_current_focus
Retrieve the user's current active goal and step to maintain context during discussions and story creation.
Instructions
Identify which goal and step the user is currently focused on to maintain context in discussions and story creation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:401-413 (handler)The handler function for the 'goalstory_read_current_focus' tool. It makes a GET request to the '/current' API endpoint using the shared doRequest helper and formats the response as text content.async (args) => { const url = `${GOALSTORY_API_BASE_URL}/current`; const result = await doRequest(url, "GET"); return { content: [ { type: "text", text: `Current goal/step focus:\n${JSON.stringify(result, null, 2)}`, }, ], isError: false, }; },
- src/index.ts:397-414 (registration)Registers the 'goalstory_read_current_focus' tool on the MCP server using the tool specification imported from tools.ts, with an inline handler implementation.server.tool( READ_CURRENT_FOCUS_TOOL.name, READ_CURRENT_FOCUS_TOOL.description, READ_CURRENT_FOCUS_TOOL.inputSchema.shape, async (args) => { const url = `${GOALSTORY_API_BASE_URL}/current`; const result = await doRequest(url, "GET"); return { content: [ { type: "text", text: `Current goal/step focus:\n${JSON.stringify(result, null, 2)}`, }, ], isError: false, }; }, );
- src/tools.ts:186-194 (schema)Defines the tool specification including name, description, and empty input schema (z.object({})) for 'goalstory_read_current_focus'./** * GET /current */ export const READ_CURRENT_FOCUS_TOOL = { name: "goalstory_read_current_focus", description: "Identify which goal and step the user is currently focused on to maintain context in discussions and story creation.", inputSchema: z.object({}), };
- src/types.ts:54-54 (schema)TypeScript interface for the tool's input, which is empty.export interface GoalstoryReadCurrentFocusInput {}
- src/index.ts:62-122 (helper)Shared helper function used by all tools (including this one) to make authenticated HTTP requests to the GoalStory API.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)}`, ); } } }