=============== LIBRARY RULES =============== From library maintainers: - Call faf_init to create project.faf for a folder, then faf_score to see which slots are empty; faf_go suggests the goal and six W's for the user to confirm. - Treat project.faf as the source of the project's facts; faf_sync writes CLAUDE.md from it and faf_tri_sync writes faf's block into the MEMORY.md Claude Code loads. - A core set of tools is listed by default; set FAF_TOOLS=all to list the rest. Every tool is callable by name either way. ### Using FafEngineAdapter with faf_sync and interop commands Source: https://github.com/wolfe-jam/claude-faf-mcp Example usage: instantiate the adapter, get working directory, call engine with 'claude' and '--all', handle success/failure, and test a refused action. Also shows setWorkingDirectory. ```TypeScript import { FafEngineAdapter } from './handlers/engine-adapter'; const engine = new FafEngineAdapter(); console.log(engine.getWorkingDirectory()); // faf_sync with every interop format: const r = await engine.callEngine('claude', ['/my/project', '--all']); if (r.success) { console.log(r.data.message); // "CLAUDE.md refreshed from …" console.log(r.data.filesChanged); // written files, CLAUDE.md first } else { console.error(r.error); // the reason nothing was written } // refused action: const bad = await engine.callEngine('conductor', ['/my/project', '--action=sync']); console.log(bad.error); // "conductor: unknown action "sync" (export). Nothing was written." engine.setWorkingDirectory('/other/project'); ``` -------------------------------- ### Instantiate and start ClaudeFafMcpServer with stdio Source: https://github.com/wolfe-jam/claude-faf-mcp Creates a server instance with stdio transport and debug enabled, then starts it. The start() method creates a StdioServerTransport and connects it, rejecting if connect fails. ```typescript import { ClaudeFafMcpServer } from 'claude-faf-mcp'; // dist/src/server.js const server = new ClaudeFafMcpServer({ transport: 'stdio', debug: true }); await server.start(); ``` -------------------------------- ### start() Source: https://github.com/wolfe-jam/claude-faf-mcp Creates a StdioServerTransport and connects it. Rejects if the connect fails. When config.debug is true, prints 'Claude FAF MCP Server started with stdio transport' to stderr. ```APIDOC ## Method: start() ### Description Creates a StdioServerTransport and connects it. Rejects if the connect fails. When config.debug is true, prints 'Claude FAF MCP Server started with stdio transport' to stderr. ### Returns - **Promise** - Resolves when the server is connected and ready. ### Example ```ts const server = new ClaudeFafMcpServer({ transport: 'stdio' }); try { await server.start(); // server now speaking JSON-RPC over stdin/stdout } catch (err) { console.error('Failed to start MCP server:', err); process.exit(1); } ``` ``` -------------------------------- ### sessionRefresh and setupSessionHook usage example Source: https://github.com/wolfe-jam/claude-faf-mcp Shows importing sessionRefresh, setupSessionHook, and HOOK_COMMAND. Demonstrates preview and confirmed installation of the session hook, then calling sessionRefresh directly. HOOK_COMMAND outputs 'npx -y claude-faf-mcp --session-refresh'. ```typescript import { sessionRefresh } from './faf-core/commands/session-refresh'; import { setupSessionHook, HOOK_COMMAND } from './faf-core/commands/setup-hook'; console.log(HOOK_COMMAND); // 'npx -y claude-faf-mcp --session-refresh' // install (after a preview): const preview = await setupSessionHook('/home/me/app', {}); console.log(preview.action); // 'preview' const installed = await setupSessionHook('/home/me/app', { confirm: true }); console.log(installed.action); // 'installed' | 'already-installed' // the hook's own entry point: const r = await sessionRefresh('/home/me/app'); if (r.message) console.log(r.message); // one quiet line for session context ``` -------------------------------- ### setupSessionHook(projectDir, options) Source: https://github.com/wolfe-jam/claude-faf-mcp Installs or previews the Claude Code session hook that runs `sessionRefresh` on session start. It returns the action taken, such as 'preview', 'installed', or 'already-installed'. ```APIDOC ## `setupSessionHook(projectDir, options)` ### Description Installs or previews the Claude Code session hook that runs `sessionRefresh` on session start. It returns the action taken, such as 'preview', 'installed', or 'already-installed'. ### Method Function Call ### Endpoint `setupSessionHook(projectDir: string, options: { confirm?: boolean }): Promise<{ action: string }>` ### Parameters #### Function Parameters - **`projectDir`** (string) - Required - The project root directory. - **`options`** (object) - Required - Options object. - **`confirm`** (boolean) - Optional - If `true`, performs the installation; otherwise, returns a preview. ### Response #### Success Response - **`action`** (string) - One of `'preview'`, `'installed'`, or `'already-installed'`. ### Request Example ```ts import { setupSessionHook } from './faf-core/commands/setup-hook'; // install (after a preview): const preview = await setupSessionHook('/home/me/app', {}); console.log(preview.action); // 'preview' const installed = await setupSessionHook('/home/me/app', { confirm: true }); console.log(installed.action); // 'installed' | 'already-installed' ``` ``` -------------------------------- ### faf_setup: Session Hook Setup Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/TOOLS.md Adds a SessionStart hook to the project's .claude/settings.json, so every Claude Code session there starts with fresh .faf context. Without confirm: true it only shows what it would write. remove: true takes the hook out. ```json { "name": "faf_setup", "arguments": { "path": "~/orders-api" } } ``` ```text PREVIEW — nothing written. faf_setup would add the faf SessionStart hook to the project settings (~/orders-api/.claude/settings.json); … ```json { "hooks": { "SessionStart": [ { "hooks": [ { "type": "command", "command": "npx -y claude-faf-mcp --session-refresh" } ] } ] } } ``` Nothing has been written. To write the project settings: faf_setup { confirm: true } ``` -------------------------------- ### start() method signature Source: https://github.com/wolfe-jam/claude-faf-mcp Creates a StdioServerTransport and connects it. Rejects if connect fails. When config.debug is true, prints 'Claude FAF MCP Server started with stdio transport' to stderr. ```typescript async start(): Promise ``` -------------------------------- ### Build claude-faf-mcp from source Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/SUPPORT.md Install dependencies and build the project from a source checkout to resolve `Cannot find module` errors. ```bash npm ci npm run build ``` -------------------------------- ### Install claude-faf-mcp globally Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/SUPPORT.md Install the package globally with npm. Verify the installation path with `which claude-faf-mcp`. ```bash npm install -g claude-faf-mcp which claude-faf-mcp # Should show installation path ``` -------------------------------- ### faf_go Source: https://github.com/wolfe-jam/claude-faf-mcp Guided interview tool with two phases. Phase 1 returns the Table-of-8 JSON with questions and suggestions. Phase 2 validates and writes answers to the project.faf file. ```APIDOC ## faf_go ### Description The human half. Phase 1 (no `answers`): runs `faf_init`+`faf_auto` bootstrap when no `project.faf` exists, then returns the Table-of-8 JSON. Phase 2 (with `answers`): validates via `checkAnswers`, refuses any answer landing under a non-mapping, writes with faf-cli's `updateFafFile`, re-scores, records `.faf-dna`. ### Parameters #### Arguments - **path** (string) - Optional - Sets session context. - **answers** (Record) - Optional - Answers to interview questions, e.g. `{ "human_context.why": "…" }`. ### Response #### Phase 1 Response Returns the Table-of-8 JSON: `{ needsInput, complete, currentScore, targetScore: 100, table[], filled, seeded, empty, questionsRemaining, questions[], instructions, … }` — each question carries `suggested` (seed from goal or faf-cli's repo suggestion) and `source`. ### Validation Rules - Answers are validated via `checkAnswers` (slot paths from faf-cli's `INTERVIEW_PATHS`/`SLOT_BY_PATH`). - Proto-pollution keys refused. - Answers must be text. - Duplicate on-wire keys refused. - Any answer landing under a non-mapping is refused. - Legacy scalar `project:` is lifted only when an answer targets `project.*`. ``` -------------------------------- ### Check installation health of claude-faf-mcp Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/SUPPORT.md Verify the global installation, check for outdated packages, and test the MCP connection by asking Claude Desktop to list available faf tools. ```bash # Verify global installation npm list -g claude-faf-mcp # Check for outdated packages npm outdated -g claude-faf-mcp # Test MCP connection # In Claude Desktop, ask: "Can you list available faf tools?" ``` -------------------------------- ### faf: Start Here Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/TOOLS.md Names the project and the .faf faf-cli finds for it, then the steps to 100%. Reads only. ```json { "name": "faf", "arguments": { "path": "~/orders-api" } } ``` ```text Project: orders-api Folder: ~/orders-api .faf: none yet Confirm this is the project (or pass its path), then run: 1. faf_auto — creates project.faf from the repo. 2. faf_score (details: true) — the score, and every slot still empty. 3. faf_go — the goal and the 6Ws only a person can give; repeat until faf_score says 100%. 4. faf_trust — the receipt for that score. 5. faf_sync and faf_tri_sync — CLAUDE.md and MEMORY.md from project.faf. ``` -------------------------------- ### Start server with error handling Source: https://github.com/wolfe-jam/claude-faf-mcp Starts the server and handles connection failures by logging the error and exiting the process. After successful start, the server speaks JSON-RPC over stdin/stdout. ```typescript const server = new ClaudeFafMcpServer({ transport: 'stdio' }); try { await server.start(); // server now speaking JSON-RPC over stdin/stdout } catch (err) { console.error('Failed to start MCP server:', err); process.exit(1); } ``` -------------------------------- ### JSON: Configure Claude Desktop MCP server Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/README.md Adds the faf MCP server to claude_desktop_config.json. Requires Node 22 or later. After restarting Claude Desktop, the server runs via npx. Alternative commands: use installed bin after npm install -g, or bunx with Bun on PATH. ```json { "mcpServers": { "faf": { "command": "npx", "args": ["-y", "claude-faf-mcp"] } } } ``` -------------------------------- ### faf_setup Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/TOOLS.md Adds a SessionStart hook to the project's .claude/settings.json, so every Claude Code session there starts with fresh .faf context. Without confirm: true it only shows what it would write. remove: true takes the hook out. ```APIDOC ## faf_setup ### Description Adds a SessionStart hook to the project's `.claude/settings.json`, so every Claude Code session there starts with fresh `.faf` context. Without `confirm: true` it only shows what it would write. `remove: true` takes the hook out. ### Parameters #### Arguments - **path** (string) - Required - Path to the project directory - **confirm** (boolean) - Optional - If true, writes the hook; otherwise only previews - **remove** (boolean) - Optional - If true, removes the hook ### Request Example ```json { "name": "faf_setup", "arguments": { "path": "~/orders-api" } } ``` ### Response Example ```text PREVIEW — nothing written. faf_setup would add the faf SessionStart hook to the project settings (~/orders-api/.claude/settings.json); … ```json { "hooks": { "SessionStart": [ { "hooks": [ { "type": "command", "command": "npx -y claude-faf-mcp --session-refresh" } ] } ] } } ``` Nothing has been written. To write the project settings: faf_setup { confirm: true } ``` ``` -------------------------------- ### Usage examples for resolveProjectPath Source: https://github.com/wolfe-jam/claude-faf-mcp Shows how to use resolveProjectPath with explicit paths, project names, and README-based inference, including the formatPathConfirmation output. ```ts import { resolveProjectPath, formatPathConfirmation } from './utils/path-resolver'; // Explicit path (relative to the active project): const r1 = resolveProjectPath('src/app', undefined, '/home/me/ws/project-a'); // r1.projectPath === '/home/me/ws/project-a/src/app', source: 'user-explicit' // Name → ~/Projects: const r2 = resolveProjectPath('my-app'); console.log(r2.projectPath); // ~/Projects/my-app (or an existing folder) console.log(formatPathConfirmation(r2));// "✓ Creating at: /" // Inference from a README: const r3 = resolveProjectPath(undefined, { readme: '# Acme Dashboard' }); console.log(r3.projectName); // "acme-dashboard" ``` -------------------------------- ### Run MCP Inspector to debug claude-faf-mcp Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/SUPPORT.md Use the MCP Inspector to talk to the server directly for debugging. This is a debugging tool, not an install step. ```bash npx @modelcontextprotocol/inspector npx -y claude-faf-mcp ``` -------------------------------- ### Third-party verification example Source: https://github.com/wolfe-jam/claude-faf-mcp Example showing how to compute a parity receipt and verify it independently using Node's crypto module. Demonstrates recomputing the parity hash and source hash to confirm authenticity. ```ts import { computeParity, buildProjection, PARITY_SPEC } from './trust/parity'; import { createHash } from 'crypto'; const raw = readFafRaw('/proj/project.faf'); const facts = { score: 85, tier: 'BRONZE', active: 21, populated: 17, empty: 4, ignored: 0, total: 33, slots: { 'project.name': 'populated', 'stack.language': 'populated' } }; const receipt = computeParity(raw, facts, { producedBy: 'my-wrapper@1.0.0' }); // third-party verification — recompute without trusting the server: const recomputed = createHash('sha256').update(receipt.projection).digest('hex'); console.log(recomputed === receipt.parityHash); // true const sourceRecomputed = createHash('sha256').update(raw, 'utf8').digest('hex'); console.log(sourceRecomputed === receipt.sourceSha256); // true ``` -------------------------------- ### Usage example with imports Source: https://github.com/wolfe-jam/claude-faf-mcp Shows how to import and use colors, bars, formatScore, and getTrustEmoji. Note: tool output never carries ANSI codes over MCP because sanitizeToolResult strips them. ```typescript import { colors, bars, formatScore, getTrustEmoji } from './faf-core/fix-once/colors'; console.log(colors.success('OK')); // green text (or plain with NO_COLOR) console.log(bars.cyan(12)); // 12 filled cyan cells console.log(formatScore(85)); // "Score: 85%" in green console.log(getTrustEmoji(90)); // '🧡' ``` -------------------------------- ### Get SDK server capabilities via createSandboxServer Source: https://github.com/wolfe-jam/claude-faf-mcp Creates a sandbox server not connected to any transport and logs its capabilities. Useful for Smithery sandbox scanning. ```typescript import { createSandboxServer } from 'claude-faf-mcp'; const sdkServer = createSandboxServer(); // not connected to any transport console.log(sdkServer.getCapabilities()); ``` -------------------------------- ### Enumerate tools via createSandboxServer Source: https://github.com/wolfe-jam/claude-faf-mcp Creates a sandbox server and lists its tools without starting a transport. Useful for enumerating the tool catalog in a sandbox environment. ```typescript import { createSandboxServer } from 'claude-faf-mcp'; const server = createSandboxServer(); // enumerate the tool catalog without starting a transport: const { tools } = await server.listTools({}); ``` -------------------------------- ### notWritten and oneLine usage example Source: https://github.com/wolfe-jam/claude-faf-mcp Shows how to import and use notWritten and oneLine. The example catches a write error and logs the notWritten message and the one-line error. ```typescript import { notWritten, oneLine } from './utils/write-outcome'; try { await writeSomething('/proj/project.faf'); } catch (err) { console.log(notWritten('/proj/project.faf', err)); // ": not written; original kept (EACCES)" console.error(oneLine(err)); // first line, colours stripped } ``` -------------------------------- ### Using handleFafRead with FileOpContext Source: https://github.com/wolfe-jam/claude-faf-mcp Example of importing and using handleFafRead with a FileOpContext to read a file and handle a denied path. ```typescript import { handleFafRead, type FileOpContext } from './handlers/fileHandler'; const ctx: FileOpContext = { roots: ['/home/me/app'], base: '/home/me/app' }; const ok = await handleFafRead({ path: 'src/index.ts' }, ctx); console.log(ok.content[0].text); // file contents const denied = await handleFafRead({ path: '/etc/passwd' }, ctx); console.log(denied.isError); // true — outside the roots ``` -------------------------------- ### Usage example for FafResourceHandler Source: https://github.com/wolfe-jam/claude-faf-mcp Shows how to instantiate FafResourceHandler and call listResources and readResource. Includes error handling for unknown URIs, catching McpError with code -32002. ```typescript import { FafResourceHandler } from './handlers/resources'; import { FafEngineAdapter } from './handlers/engine-adapter'; const handler = new FafResourceHandler(new FafEngineAdapter()); const list = handler.listResources(); // the two uris const ctx = await handler.readResource('claude-faf://context'); const parsed = JSON.parse(ctx.contents[0].text); // { path, score, tier, data, … } try { await handler.readResource('claude-faf://nope'); } catch (e) { if (e instanceof McpError) console.log(e.code); // -32002 } ``` -------------------------------- ### Type guard usage example Source: https://github.com/wolfe-jam/claude-faf-mcp Shows how to import and use isError, isDefined, and hasProperty. The example checks for structuredContent on a callResult object. ```typescript import { isError, isDefined, hasProperty } from './utils/type-guards'; if (hasProperty(callResult, 'structuredContent')) { const sc = callResult.structuredContent; } ``` -------------------------------- ### Usage example for exportFormat Source: https://github.com/wolfe-jam/claude-faf-mcp Iterates over all FORMATS keys and calls exportFormat, logging success or failure messages. ```ts import { exportFormat, FORMATS, type FormatFile } from './faf-core/utils/export-format'; for (const file of Object.keys(FORMATS) as FormatFile[]) { const r = await exportFormat('/home/me/app', file); console.log(r.success ? r.message : `NOT WRITTEN: ${r.message}`); } ``` -------------------------------- ### Usage example with buildReceipt and renderReceipt Source: https://github.com/wolfe-jam/claude-faf-mcp Shows how to import and use buildReceipt, renderReceipt, and sealForScore. Builds a receipt with a score of 100, tier 'TROPHY', parity from computeParity, tests, and issued timestamp, then renders it and prints the seal for score 40. ```ts import { buildReceipt, renderReceipt, sealForScore } from './trust/receipt'; import { computeParity } from './trust/parity'; const receipt = buildReceipt({ subject: 'my-app', // project.name score: 100, tier: 'TROPHY', parity: computeParity(raw, facts, { producedBy: 'claude-faf-mcp@7.2.1' }), tests: { passed: 42, total: 42, suite: 'WJTTC' }, issued: new Date().toISOString(), }); console.log(renderReceipt(receipt)); console.log(sealForScore(40)); // '○' ``` -------------------------------- ### Usage example for exportSource Source: https://github.com/wolfe-jam/claude-faf-mcp Calls exportSource and logs the found paths or the error message. ```ts import { exportSource } from './faf-core/utils/export-source'; const src = await exportSource('/home/me/app', 'AGENTS.md'); if (src.ok) { console.log(`${src.file} from ${src.fafPath} into ${src.dir}`); } else { console.error(src.message); } ``` -------------------------------- ### YAML: Define 3Ws for project.faf Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/README.md Defines the Who, What, and Why context in a YAML block that Claude uses to build project.faf. This is the minimal starting context for AI sessions. ```yaml human_context: who: "people who need a ride across town" what: "tap a button, car arrives in minutes" why: "taxis are slow, expensive, and hard to find" ``` -------------------------------- ### FafPromptHandler usage example Source: https://github.com/wolfe-jam/claude-faf-mcp Shows how to instantiate the handler, list prompts, retrieve the 'faf' flow prompt with a path argument, and handle an unknown prompt error (McpError InvalidParams, -32602). ```typescript import { FafPromptHandler } from './handlers/prompts'; const handler = new FafPromptHandler(); const listed = handler.listPrompts(); // ['faf', 'faf-bench'] const flow = handler.getPrompt('faf', { path: '/home/me/app' }); console.log(flow.messages[0].content.text); // the 7-step protocol try { handler.getPrompt('faf-whatever'); } catch (e) { // McpError InvalidParams (-32602) } ``` -------------------------------- ### Constants for setup-hook.ts Source: https://github.com/wolfe-jam/claude-faf-mcp Defines the fingerprint, command, and settings scope used by the hook installer. HOOK_COMMAND is the exact command the hook runs; SETTINGS_SCOPE is named in every message. ```ts export const HOOK_FINGERPRINT = 'claude-faf-mcp --session-refresh'; export const HOOK_COMMAND = `npx -y ${HOOK_FINGERPRINT}`; export const SETTINGS_SCOPE = 'project settings'; ``` -------------------------------- ### Using PathValidator.checkFileSize Source: https://github.com/wolfe-jam/claude-faf-mcp Example of calling checkFileSize and logging the error if the file is too large. ```typescript const { valid, error } = await PathValidator.checkFileSize('/proj/big.log'); if (!valid) console.error(error); ``` -------------------------------- ### ClaudeFafMcpServer class definition Source: https://github.com/wolfe-jam/claude-faf-mcp Core server class that wires an MCP SDK Server with tools/resources/prompts capabilities and three handlers over one shared FafEngineAdapter. Importing the module has no side effects; the server starts only when start() is called. ```typescript export class ClaudeFafMcpServer { private server: Server; private resourceHandler: FafResourceHandler; private toolHandler: FafToolHandler; private promptHandler: FafPromptHandler; private config: ClaudeFafMcpServerConfig; constructor(config: ClaudeFafMcpServerConfig) { ... } /** Expose the raw MCP Server instance (used by Smithery sandbox scanning) */ getServer(): Server { ... } private setupHandlers(): void { ... } async start(): Promise { ... } async stop(): Promise { ... } } ``` -------------------------------- ### Usage example — agents and conductor commands Source: https://github.com/wolfe-jam/claude-faf-mcp Shows how to call agentsExportCommand and conductorExportCommand. The conductor result includes filesWritten with four expected filenames when successful. ```typescript import { agentsExportCommand } from './faf-core/commands/agents'; import { conductorExportCommand } from './faf-core/commands/conductor'; const r1 = await agentsExportCommand('/home/me/app'); console.log(r1.action, r1.success, r1.message); const r2 = await conductorExportCommand('/home/me/app'); if (r2.success) { console.log(r2.data.filesWritten); // ['product.md', 'tech-stack.md', 'workflow.md', 'product-guidelines.md'] } ``` -------------------------------- ### Usage example for gitContextCommand and cloneArgs Source: https://github.com/wolfe-jam/claude-faf-mcp Shows preview and write usage of gitContextCommand, plus the output of cloneArgs. The preview returns score, tier, fafContent, and suggestions; the write variant returns an error message if an existing project.faf is present. ```TypeScript import { gitContextCommand, cloneArgs } from './faf-core/commands/git-context'; // preview only — nothing written: const r = await gitContextCommand('Wolfe-Jam/claude-faf-mcp'); if (r.success) { console.log(r.data.score, r.data.tier); // 100 'TROPHY' (for a 100% repo) console.log(r.data.fafContent); // the .faf text for (const s of r.data.suggestions ?? []) { console.log(`${s.slot}: ${s.value} (${s.source})`); // goal/6W suggestions } } // write into an existing project folder: const w = await gitContextCommand('owner/repo', '/home/me/app'); if (!w.success) console.error(w.message); // e.g. existing project.faf refusal console.log(cloneArgs('owner/repo', '/tmp/x')); // ['-c','core.symlinks=false','clone','--depth','1','--quiet','--','owner/repo','/tmp/x'] ``` -------------------------------- ### createSandboxServer function definition Source: https://github.com/wolfe-jam/claude-faf-mcp Creates a ClaudeFafMcpServer with stdio transport and returns the underlying SDK Server. Returns the SDK Server with capabilities scanned, no transport started, and no side effects. Purpose: Smithery sandbox capability scanning. ```typescript export function createSandboxServer(): Server { const wrapper = new ClaudeFafMcpServer({ transport: 'stdio' }); return wrapper.getServer(); } ``` -------------------------------- ### Using writeClaudeFromFaf and isOldClaudeMd Source: https://github.com/wolfe-jam/claude-faf-mcp Example usage of writeClaudeFromFaf and isOldClaudeMd. Calls writeClaudeFromFaf, logs each note, then checks if a given text is legacy and logs the result. ```ts import { isOldClaudeMd, writeClaudeFromFaf } from './faf-core/commands/claude'; const { before, after, notes } = await writeClaudeFromFaf('/home/me/app', data, null); for (const note of notes) console.log(note); // e.g. legacy-stamp note, old-template outcome const legacy = isOldClaudeMd(oldClaudeText, data, null, '/home/me/app'); console.log(legacy); // false when any line is not provably faf's ``` -------------------------------- ### Using conductorExport and renderConductor Source: https://github.com/wolfe-jam/claude-faf-mcp Example usage of the conductor parser functions: renderConductor returns the markdown bodies, conductorExport writes files and returns the list of written files. ```TypeScript import { conductorExport, renderConductor } from './faf-core/parsers/conductor-parser'; const bodies = await renderConductor(fafData, '/home/me/app'); console.log(bodies['product.md']); // the rendered markdown const out = await conductorExport(fafData, '/home/me/app'); console.log(out.filesWritten); // ['product.md', 'tech-stack.md', 'workflow.md', 'product-guidelines.md'] ``` -------------------------------- ### faf_setup Source: https://github.com/wolfe-jam/claude-faf-mcp Installs/removes the faf SessionStart hook in `/.claude/settings.json`. Preview by default; writes only with `confirm: true`; `remove: true` (+confirm) removes only the entry whose command is exactly `HOOK_COMMAND`. Never writes the user settings (home refused via `homeRefusal`). Delegates to `setupSessionHook`. ```APIDOC ## faf_setup ### Description Installs/removes the faf SessionStart hook in `/.claude/settings.json`. Preview by default; writes only with `confirm: true`; `remove: true` (+confirm) removes only the entry whose command is exactly `HOOK_COMMAND`. Never writes the user settings (home refused via `homeRefusal`). Delegates to `setupSessionHook`. ### Parameters #### Arguments - `path` (string) - Optional - Project path. - `confirm` (boolean) - Optional - If true, writes changes; otherwise previews. - `remove` (boolean) - Optional - If true, removes the hook entry. ### Response #### Structured Output - `action` (enum: 'preview'|'installed'|'already-installed'|'removed'|'not-installed'|'error') - Result action. - `settingsPath` (string) - Path to settings file. - `hookCommand` (string) - The hook command. - `settings` (object) - Optional settings content. - `message` (string) - Status message. ``` -------------------------------- ### Initialize FAF for any project with faf-cli Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/README.md Run this command to create a .faf file for the current project. It is part of the faf-cli tool, which is described as a must-have for every builder. ```bash npx faf-cli init ``` -------------------------------- ### faf_quick Source: https://github.com/wolfe-jam/claude-faf-mcp Creates a new project.faf from one line: "name, goal, language, framework, hosting" (name+goal required — the goal is the user's confirmed words). The words take their slots over faf-cli's assembleFreshFaf detection (fillEmpties); a framework that is neither stack.frontend nor stack.backend in faf-cli's STACK_INTERVIEW is reported, never guessed. Only creates — an existing project.faf/.faf → isError, nothing written. Writes birth .faf-dna. ```APIDOC ## faf_quick ### Description Creates a new `project.faf` from one line: `"name, goal, language, framework, hosting"` (`name`+`goal` required — the goal is the user's confirmed words). The words take their slots over faf-cli's `assembleFreshFaf` detection (`fillEmpties`); a framework that is neither `stack.frontend` nor `stack.backend` in faf-cli's `STACK_INTERVIEW` is reported, never guessed. Only creates — an existing `project.faf`/`.faf` → isError, nothing written. Writes birth `.faf-dna`. ### Parameters #### Args - **input** (string) - Required - One line: `"name, goal, language, framework, hosting"` - **path** (string) - Optional - Path to the project ### Returns - Created-file text with per-slot placement and score ``` -------------------------------- ### confineFileOp usage example Source: https://github.com/wolfe-jam/claude-faf-mcp Example of calling confineFileOp with roots and base. The '../' is resolved against base, and the result remains inside the roots. ```TypeScript import { confineFileOp } from './utils/safe-path'; const roots = ['/home/me/app', '/srv/shared']; const safe = confineFileOp('../app/README.md', { roots, base: '/home/me/app/src' }); // safe === '/home/me/app/README.md' — '../' is resolved against base, still inside roots ``` -------------------------------- ### faf_quick: Quick Create Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/TOOLS.md Creates project.faf from one line: name, goal, language (and framework, hosting). ```json { "name": "faf_quick", "arguments": { "path": "~/quick-demo", "input": "quick-demo, A CLI that prints the weather, TypeScript" } } ``` ```text Project: quick-demo Goal: A CLI that prints the weather Language: TypeScript Score: 25/100 (3/12 slots populated) — RED Birth DNA: 25% (.faf-dna) Created: ~/quick-demo/project.faf ``` -------------------------------- ### faf_about Source: https://github.com/wolfe-jam/claude-faf-mcp Provides a static overview of the .faf format, server version, bundled faf-cli version, and recommended workflow. Takes no arguments and reads or writes nothing. ```APIDOC ## faf_about ### Description Provides a static overview of the .faf format, server version, bundled faf-cli version, and recommended workflow. Takes no arguments and reads or writes nothing. ### Method Tool call ### Endpoint faf_about ### Parameters None ### Response #### Success Response - `text` (string) - Plain-text overview ``` -------------------------------- ### quietText usage example Source: https://github.com/wolfe-jam/claude-faf-mcp Shows how to import and use quietText. It removes emojis but keeps the seal symbol ✪, as demonstrated by the two example calls. ```typescript import { quietText } from './utils/sanitize-output'; quietText('✅ project.faf created 🏎️'); // 'project.faf created' quietText('Score: 100 ✪ TROPHY'); // 'Score: 100 ✪ TROPHY' (seal kept) ``` -------------------------------- ### setupSessionHook(projectDir, opts) Source: https://github.com/wolfe-jam/claude-faf-mcp Sets up or removes faf's SessionStart hook in the project's Claude settings file. Supports preview mode, confirmation, and removal operations. ```APIDOC ## setupSessionHook(projectDir, opts) ### Description Sets up or removes faf's SessionStart hook in the project's Claude settings file. Supports preview mode, confirmation, and removal operations. ### Method Function call ### Signature ```ts export async function setupSessionHook( projectDir: string, opts: { confirm?: boolean; remove?: boolean } = {}, ): Promise ``` ### Parameters - **projectDir** (string) - Required - Project folder; writes `/.claude/settings.json` - **opts.confirm** (boolean) - Optional - Default: `false` - Write the change; without it, **preview only** - **opts.remove** (boolean) - Optional - Default: `false` - Remove faf's hook (preview unless confirmed) ### Return Value `SetupHookResult = { action: 'preview'|'installed'|'already-installed'|'removed'|'not-installed'|'error', settingsPath, settings?, message }` ### Behavior - No flags → `preview` (with the exact file it would write) - `confirm` → `installed` or `already-installed` - `remove` → `preview` of removal - `remove+confirm` → `removed` or `not-installed` ### Rules - Reads settings through faf-cli's resolver (a `.claude` folder or `settings.json` that is a link out of the project is refused) - Invalid JSON / non-object → `error` - `hooks` not an object or `SessionStart` not a list → `error` with by-hand instructions - The file is rewritten only when it is laid out exactly as faf writes JSON (`JSON.stringify(settings, null, 2)`, LF or CRLF, optional trailing newline — `render()` proves it), otherwise → `error` with the entry to add by hand - Writes go through faf-cli's `safeWriteFile` (atomic, refuses if the file changed meanwhile) - `isNonProjectRoot` → `error(homeRefusal(projectDir))` ``` -------------------------------- ### confinePath usage example Source: https://github.com/wolfe-jam/claude-faf-mcp Example of calling confinePath with requireFafFile: true. The returned safe path is absolute and canonical; callers read it directly. Catches PathConfinementError to log denial messages. ```TypeScript import { confinePath, PathConfinementError } from './utils/safe-path'; try { const safe = confinePath('~/app/project.faf', { requireFafFile: true }); // safe is absolute, canonical — callers read it directly } catch (err) { if (err instanceof PathConfinementError) { console.error('denied:', err.message); } } ``` -------------------------------- ### homeRefusal function signature Source: https://github.com/wolfe-jam/claude-faf-mcp Returns the refusal text for home or root directory, because the .claude/settings.json there is user settings that apply to every project; faf_setup writes only project settings. ```ts export function homeRefusal(projectDir: string): string ``` -------------------------------- ### new ClaudeFafMcpServer(config) Source: https://github.com/wolfe-jam/claude-faf-mcp Creates a new ClaudeFafMcpServer instance with the provided configuration. This constructor initializes the MCP SDK Server, the shared FafEngineAdapter, and all three handlers (resources, tools, prompts), registering all request handlers. ```APIDOC ## Constructor: ClaudeFafMcpServer ### Description Creates a new ClaudeFafMcpServer instance with the provided configuration. This constructor initializes the MCP SDK Server, the shared FafEngineAdapter, and all three handlers (resources, tools, prompts), registering all request handlers. ### Parameters - **config** (ClaudeFafMcpServerConfig) - Required - Configuration object: `{ transport: 'stdio', port?, debug?, cors?, host? }`. Merged over `{ port: 3001, host: '0.0.0.0', cors: true }`. ### Example ```ts import { ClaudeFafMcpServer } from 'claude-faf-mcp'; // dist/src/server.js const server = new ClaudeFafMcpServer({ transport: 'stdio', debug: true }); await server.start(); ``` ``` -------------------------------- ### Run faf_sync on test project Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/examples/README.md Writes CLAUDE.md's faf-managed block from project.faf. ```text Run faf_sync on the test project ``` -------------------------------- ### isRealFilesystemPath(inputPath) Source: https://github.com/wolfe-jam/claude-faf-mcp Checks if a given path is a real filesystem path by rejecting container paths starting with '/mnt/user-data/', '/home/claude/', or '/tmp/uploads/'. ```APIDOC ## isRealFilesystemPath(inputPath) ### Description Checks if a given path is a real filesystem path by rejecting container paths starting with '/mnt/user-data/', '/home/claude/', or '/tmp/uploads/'. ### Method Function ### Signature ```ts export function isRealFilesystemPath(inputPath: string): boolean ``` ### Parameters - **inputPath** (string) - Required - The path to check. ### Returns - **boolean** - `true` if the path is a real filesystem path, `false` otherwise. ``` -------------------------------- ### createSandboxServer() Source: https://github.com/wolfe-jam/claude-faf-mcp Creates a ClaudeFafMcpServer with stdio transport and returns the underlying SDK Server instance. This function has no side effects and is used for Smithery sandbox capability scanning. ```APIDOC ## Function: createSandboxServer() ### Description Creates a ClaudeFafMcpServer with stdio transport and returns the underlying SDK Server instance. This function has no side effects and is used for Smithery sandbox capability scanning. ### Parameters - *(none)* - No parameters. ### Returns - **Server** - The SDK Server instance with capabilities scanned, no transport started. ### Example ```ts import { createSandboxServer } from 'claude-faf-mcp'; const server = createSandboxServer(); // enumerate the tool catalog without starting a transport: const { tools } = await server.listTools({}); ``` ``` -------------------------------- ### Run faf_init on test project Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/examples/README.md Creates project.faf and its .faf-dna birth record. faf-cli detects the project from its files: name, TypeScript, Next.js, and React. ```text Run faf_init on /examples/test-project ``` -------------------------------- ### getServer() Source: https://github.com/wolfe-jam/claude-faf-mcp Returns the raw MCP SDK Server instance. This is used by Smithery's sandbox scanning and allows embedding the server in a custom transport instead of stdio. ```APIDOC ## Method: getServer() ### Description Returns the raw MCP SDK Server instance. This is used by Smithery's sandbox scanning and allows embedding the server in a custom transport instead of stdio. ### Returns - **Server** - The raw MCP SDK Server instance. ### Example ```ts import { createSandboxServer } from 'claude-faf-mcp'; const sdkServer = createSandboxServer(); // not connected to any transport console.log(sdkServer.getCapabilities()); ``` ``` -------------------------------- ### faf_doctor Source: https://github.com/wolfe-jam/claude-faf-mcp Runs 7 diagnostic checks on the .faf setup, including server/faf-cli versions, .faf presence, readability, validation, score, CLAUDE.md presence, and TURBO-CAT format scan. ```APIDOC ## faf_doctor ### Description Runs 7 checks: server/faf-cli versions, `.faf` presence, readability (with `yamlFixHint`), `validateFaf`, score + empty slots with fixes, CLAUDE.md presence, TURBO-CAT format scan. Outputs `health: ok|warning|error` with per-check `diagnostics[] {status, message, fix?}`. ### Method Tool invocation ### Endpoint faf_doctor ### Parameters #### Arguments - `path?` (string) - Optional - Path to the .faf file or context. ### Response #### Success Response - `health` (string: 'ok' | 'warning' | 'error') - Overall health status. - `diagnostics[]` (array) - Per-check diagnostics. - `status` (string) - Status of the check. - `message` (string) - Description of the check result. - `fix?` (string) - Optional fix hint. ``` -------------------------------- ### faf_bench: Grounding Benchmark Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/TOOLS.md Measures what project.faf is worth on this repo. action: "questions" returns questions built from the file's own populated slots. You answer each one twice: cold (without the file) and with the file. action: "grade" then grades both sets mechanically against project.faf. ```json { "name": "faf_bench", "arguments": { "path": "~/orders-api", "action": "questions" } } ``` ```text faf_bench — 8 grounding questions (qset d19d1ca96505… · faf-bench/1) … Then call: faf_bench { action: "grade", cold: { "1": "…", … }, faf: { "1": "…", … } } 1. [project.name] What is the project's name? 2. [project.goal] What is the project's goal — what is it for? 3. [project.main_language] What is the primary programming language? … ``` -------------------------------- ### getServer() method signature Source: https://github.com/wolfe-jam/claude-faf-mcp Returns the raw MCP SDK Server instance. Used by Smithery's sandbox scanning and available to embed the server in a custom transport instead of stdio. ```typescript getServer(): Server ``` -------------------------------- ### Using claudeExportCommand with all formats Source: https://github.com/wolfe-jam/claude-faf-mcp Example usage of claudeExportCommand with the 'all' flag. Logs direction, changed files, and score. If any files failed, prints each failure with its reason. ```ts import { claudeExportCommand } from './faf-core/commands/claude'; const r = await claudeExportCommand('/home/me/app', { all: true }); console.log(r.direction); // 'faf-to-claude' console.log(r.filesChanged); // ['/home/me/app/CLAUDE.md', …] console.log(r.score); // "85%" if (r.filesFailed.length) { for (const f of r.filesFailed) console.log(`${f.file}: ${f.reason}`); } ``` -------------------------------- ### Run faf_auto then faf_go Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/examples/README.md faf_auto fills every slot the repo's own files answer and writes CLAUDE.md; faf_go asks for the goal and the 6Ws that only you can give, and writes your answers into project.faf. ```text Run faf_auto on the test project, then faf_go ``` -------------------------------- ### faf_context Source: https://github.com/wolfe-jam/claude-faf-mcp Shows the active session project, optionally reading the .faf file content. The path must exist and cannot be home or root. ```APIDOC ## faf_context ### Description Shows the active session project, optionally reading the .faf file content. The path must exist and cannot be home or root. ### Method Tool call ### Endpoint faf_context ### Parameters #### Arguments - `path?` (string) - Optional - Path to the project directory - `detail?` (boolean) - Optional - If true, returns the .faf file content ### Response #### Success Response - `active` (boolean) - Whether a project is active - `hasFaf` (boolean) - Whether the project has a .faf file - `filename` (string|null) - Name of the .faf file, if any - `path` (string|null) - Path to the project - `changed` (boolean) - Whether the project has changed - `content` (string) - The .faf file content, if `detail` is true #### Error Response - `isError` (boolean) - True if the path is invalid - `reason` (string) - Reason for the error ``` -------------------------------- ### Using composedTurboCat and composedTurboCatSlots Source: https://github.com/wolfe-jam/claude-faf-mcp Example usage of the Turbo-Cat bridge functions: composedTurboCat returns scan results, composedTurboCatSlots returns partial fills. ```TypeScript import { composedTurboCat, composedTurboCatSlots } from './faf-core/extract/turbocat-bridge'; const scan = await composedTurboCat('/home/me/app'); if (scan) { console.log(scan.stackSignature); // e.g. 'ts:next:react' console.log(scan.discoveredFormats.map((f) => f.fileName)); } const slots = await composedTurboCatSlots('/home/me/app'); console.log(slots?.project?.main_language); ``` -------------------------------- ### Run security audits before submitting PRs Source: https://github.com/wolfe-jam/claude-faf-mcp/blob/main/SECURITY.md Run these commands to check for vulnerabilities, build the project, and run tests before submitting pull requests. ```bash npm audit npm run build npm test ```