Get Workflow Preferences
get_workflow_preferencesLoad user workflow preferences from past sessions to restore previous settings and streamline project management tasks.
Instructions
Load user workflow preferences from past sessions. No auth needed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/pm.ts:52-85 (handler)Main handler function for get_workflow_preferences. Checks for .pm_preferences.json file, reads and parses it, tags observations with USER_DATA wrapper, and returns results. Handles errors via try-catch with error formatting.
async () => { try { if (!existsSync(PREFS_PATH)) { return { content: [ { type: "text", text: JSON.stringify(finalizeToolResult({ found: false, preferences: [] })), }, ], }; } const data = JSON.parse(readFileSync(PREFS_PATH, "utf-8")); const raw = data.observations ?? []; const prefs = raw.map((p: unknown) => (typeof p === "string" ? tagUserText(p) : p)); return { content: [ { type: "text", text: JSON.stringify(finalizeToolResult({ found: true, preferences: prefs })), }, ], }; } catch (err) { return { content: [ { type: "text", text: JSON.stringify(finalizeToolResult(handleError(err))), }, ], }; } }, - src/tools/pm.ts:45-86 (registration)Tool registration with MCP server. Defines tool name, title, description, input schema (empty object since no parameters needed), and associates the handler function. Called from registerPmTools().
server.registerTool( "get_workflow_preferences", { title: "Get Workflow Preferences", description: "Load user workflow preferences from past sessions. No auth needed.", inputSchema: z.object({}), }, async () => { try { if (!existsSync(PREFS_PATH)) { return { content: [ { type: "text", text: JSON.stringify(finalizeToolResult({ found: false, preferences: [] })), }, ], }; } const data = JSON.parse(readFileSync(PREFS_PATH, "utf-8")); const raw = data.observations ?? []; const prefs = raw.map((p: unknown) => (typeof p === "string" ? tagUserText(p) : p)); return { content: [ { type: "text", text: JSON.stringify(finalizeToolResult({ found: true, preferences: prefs })), }, ], }; } catch (err) { return { content: [ { type: "text", text: JSON.stringify(finalizeToolResult(handleError(err))), }, ], }; } }, ); - src/tools/pm.ts:50-50 (schema)Input schema definition using Zod. Empty object schema indicates the tool takes no input parameters.
inputSchema: z.object({}), - src/tools/pm.ts:15-18 (helper)Local helper function to format errors. Converts CliError or unexpected errors into contract error format using contractError utility.
function handleError(err: unknown): Record<string, unknown> { if (err instanceof CliError) return contractError(String(err), "error"); return contractError(`Unexpected error: ${err}`, "error"); } - src/security.ts:39-42 (helper)Helper function that tags user-provided text with USER_DATA wrapper for security tracking. Used to wrap each observation preference before returning.
export function tagUserText(text: string | null | undefined): string | null { if (text == null) return null; return `[USER_DATA]${text}[/USER_DATA]`; }