Database-driven FP enforcement and project management for AI-maintained codebases
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
A language-agnostic programming paradigm designed for AI-generated and AI-maintained codebases
AIMFP (AI Modular Functional Procedural) is a programming paradigm that combines:
Use Case 1: Regular Software Development
Use Case 2: Custom Directive Automation
Key Principle: One AIMFP instance per project directory. You would NOT mix a web app with home automation directives. Run separate instances for separate purposes.
Traditional programming paradigms were designed for humans. AIMFP is optimized for AI-human collaboration:
| Challenge | Traditional Approach | AIMFP Solution |
|---|---|---|
| Context Loss | AI forgets between sessions | Database-driven persistent state |
| OOP Complexity | Classes, inheritance, polymorphism | Pure functions, explicit data structures |
| Infinite Development | Projects never "complete" | Finite completion paths with milestones |
| Code Reasoning | Parse source code repeatedly | Pre-indexed functions, dependencies, interactions |
| Inconsistent Standards | Style guides, linters, reviews | Immutable directives enforcing compliance |
Every function, file, and dependency is tracked in SQLite. AI accesses this data through helper tools β not raw SQL:
No source code reparsing required. Instant context retrieval across sessions.
AIMFP works with Python, JavaScript, TypeScript, Rust, Go, and more. FP directives adapt to language-specific syntax while maintaining universal standards.
Location: Within MCP server installation directory (user-defined location, configured in AI client)
Purpose: Immutable knowledge base containing all AIMFP standards, directives, and helper definitions.
Key Tables:
directives: All FP, project, and user preference directives (workflows, keywords, thresholds)helper_functions: Database, file, Git, and FP utilities organized across multiple registry filesdirective_helpers: Many-to-many junction table mapping directives to their helper functions with execution metadatacategories: Directive groupings (purity, immutability, task management, etc.)directive_flow: Status-driven directive navigation and routingHelper-Directive Relationship (New in v1.4):
directive_helpers junction table in aimfp_core.dbHelper Classification:
is_sub_helper = TRUE): Internal utility called by other helpers only (not exposed to AI)Helper Registry (Development Staging):
dev/helpers-json/*.json during developmentused_by_directives field for relationship mappingaimfp_core.db from JSON files before releaseaimfp_core.db (pre-populated), NOT JSON filesRead-Only Philosophy: This database is version-controlled and immutable once deployed. AI reads from it but never modifies it.
Location: <project-root>/.aimfp-project/project.db
Purpose: Persistent state for a single AIMFP project. Tracks code structure, tasks, and runtime notes.
Key Tables:
project: High-level metadata (name, purpose, goals, status, user_directives_status, last_known_git_hash)files, functions, interactions: Code structure trackingthemes, flows: Organizational groupingscompletion_path, milestones, tasks, subtasks, sidequests: Hierarchical roadmapnotes: Runtime logging with optional directive context (source, severity, directive_name)types: Algebraic data types (ADTs)infrastructure: Project setup (language, packages, testing)work_branches: Git collaboration metadata (user, purpose, merge strategy)merge_history: FP-powered merge conflict resolution audit trailUser Directives Integration: The project.user_directives_status field tracks whether user directives are initialized (NULL/in_progress/active/disabled), allowing aimfp_run and aimfp_status directives to include user directive context when active.
Enhanced Notes: The notes table now includes source (user/ai/directive), directive_name (optional context), and severity (info/warning/error) for better traceability.
Location: <project-root>/.aimfp-project/user_preferences.db
Purpose: User-specific AI behavior customizations and opt-in tracking features.
Key Tables:
directive_preferences: Per-directive behavior overrides (atomic key-value structure)user_settings: Project-wide AI behavior settingstracking_settings: Feature flags for opt-in tracking (all disabled by default)ai_interaction_log: User corrections and learning data (opt-in)fp_flow_tracking: FP compliance history (opt-in)issue_reports: Contextual bug reports (opt-in)Cost Management Philosophy: All tracking features disabled by default to minimize API token usage. Project work should be cost-efficient; debugging and analytics are opt-in.
User Customization Example:
Location: <project-root>/.aimfp-project/user_directives.db
Purpose: Store user-defined domain-specific directives for automation (home automation, cloud infrastructure, etc.). When this database exists, the AIMFP project IS dedicated to building and managing the automation code generated from these directives.
This database only exists in Use Case 2: Custom Directive Automation projects. In regular software development projects, this database is not created.
Key Tables:
user_directives: Directive definitions (triggers, actions, status, validated configuration)directive_executions: Execution statistics (summary only, detailed logs in files)directive_dependencies: Required packages, APIs, environment variablesdirective_implementations: Links directives to generated code fileshelper_functions: AI-generated helper functions (project-specific implementation utilities)directive_helpers: Many-to-many junction table mapping user directives to their helperssource_files: Tracks user directive source files (YAML/JSON/TXT)logging_config: File-based logging configurationHelper Functions (New in v1.0):
File-Based Logging Philosophy: Database stores state and statistics only. Detailed execution logs (30-day retention) and error logs (90-day retention) are stored in rotating files at .aimfp-project/logs/.
Directory Structure Comparison:
Example Workflow (Automation Project):
directives/lights.yaml in their projectsrc/project.db (files, functions, tasks).aimfp-project/logs/, statistics to databaseNote: User directive files stay in the user's project. .aimfp-project/ is AI-managed metadata.
The aimfp_run command serves as a gateway and reminder, not an executor. It tells the AI that AIMFP directives should be applied.
Every aimfp_run call returns:
The MCP server exposes CRUD helper functions for all database operations β tracking files, functions, tasks, project state, user preferences, and (for Use Case 2) automation directives. AI discovers available helpers from the database at runtime.
AI Decision Flow:
aimfp run (or AI assumes it)aimfp_run tool β receives guidanceAI Processing:
aimfp_run(is_new_session=true) β receives session bundle (directive names, project status, settings, supportive context).aimfp-project/ missing β project not initializedaimfp_init helper (Phase 1: mechanical setup)
.aimfp-project/ directory, databases, blueprint templateproject_discovery: collaborates with user on blueprint, themes, flows, completion path, milestonesaimfp_status β project_progression β first task createdBefore acting, AI performs self-assessment using questions provided with directives:
Core Questions:
Does this involve coding or project state changes?
Do I have directives in memory?
aimfp_run(is_new_session=true)Which directives apply?
Action-reaction needed?
Example Flow (Coding Task):
Directives follow a trunk β branches β fallback pattern:
AIMFP is developed and tested on Linux only. There is no platform-conditional code anywhere in the codebase, so Windows and macOS support is unbuilt rather than untested β it has never been attempted, and making it work would be real porting effort, not a compatibility pass.
The core of the server is portable in principle (pure-stdlib JSON-RPC over stdio, SQLite, pathlib), so parts of it may happen to run elsewhere. Nothing about that is verified or supported. If you run AIMFP on another platform, you're on your own β bug reports are welcome, but Linux is the only environment the project targets.
AIMFP installs three ways. On Claude Code, use the plugin (Method 1) β two commands, no manual setup. pip/manual are for other MCP clients or advanced setups.
Prerequisite: uv on your PATH (a single self-contained binary). The plugin launches the MCP server with uvx, which fetches the published aimfp package from PyPI, resolves its watchdog dependency, and provisions a compatible Python (3.11+) automatically β so you don't need a matching system Python or a separate pip install.
That's it β no pip install, no claude mcp add, no config files. The plugin provides:
uvx aimfp@latest (always the latest published release, fully self-contained)/aimfp:run, /aimfp:status, /aimfp:init, /aimfp:endaimfp-mode setup skill + a SessionStart hook β these are setup-only: they prompt the AI to install the system prompt (via the get_system_prompt tool) and start a session. They are deliberately not a copy of the behavioral rules (that would duplicate the system prompt into every session). Your first move after install is still to ask the AI to add the AIMFP system prompt β see Add the System Prompt below; for the plugin the AI does it for you, nothing to download or paste.Updates: /plugin marketplace update aimfp. No Anthropic account, approval, or central registry is involved β the marketplace is just this public GitHub repo.
Tool pre-approval still applies to the plugin's MCP tools β see Pre-Approve All AIMFP Tools below.
This installs the MCP server and makes the aimfp command available. AIMFP requires only one external dependency (watchdog for filesystem monitoring) β the JSON-RPC server itself is pure Python stdlib.
git clone)src/aimfp/ folder β this is the complete MCP server packageaimfp/ folder to wherever you keep MCP servers:
The only runtime dependency (watchdog) is installed automatically. The aimfp/ folder contains everything else the server needs: helper functions, directives, database schemas, and the pre-populated aimfp_core.db.
Do this before anything else. The system prompt is AIMFP's record-keeping backbone β it's what tells the AI to call aimfp_run() first and run the project through AIMFP. Without it the MCP tools are just passive functions that never get called; the AI won't even know to start init or discovery.
Recommended β works for every install method, including the plugin (nothing to download or paste). Just ask the AI:
The AI calls the get_system_prompt tool, which returns the prompt plus placement guidance, and writes it for you:
CLAUDE.md at your project root (Claude Code) or Settings β Custom Instructions (Claude Desktop).CLAUDE.md / instructions file, the AI will not blindly prepend β it reviews it with you and discusses consolidating/optimizing first. Existing content is never discarded..aimfp-project/: no network, no credentials, nothing outside your current project.Manual alternative (other MCP clients, or if you'd rather paste it yourself) β print it and paste it into your client's system-prompt / custom-instructions field:
| AI Client | Where the system prompt goes |
|---|---|
| Claude Code | CLAUDE.md in your project root |
| Claude Desktop | Settings β Custom Instructions |
| Other MCP clients | System prompt / custom instructions field |
Register the AIMFP MCP server in your AI client's configuration. The server uses stdio transport β it reads JSON-RPC messages from stdin and writes responses to stdout.
Edit claude_desktop_config.json:
If you used Method 3 (manual install), add the parent directory of your aimfp/ folder to PYTHONPATH so Python can find it:
For example, if you copied aimfp/ to ~/mcp-servers/aimfp/, set PYTHONPATH to ~/mcp-servers.
If you installed into a virtual environment, use the full path to the venv's Python so Claude Desktop uses the correct interpreter:
Use claude mcp add to register the server. Run the command from within the project folder you want AIMFP to manage.
Choose a scope first. AIMFP enforces strict functional programming and actively rejects OOP codebases. If you work on other projects that use OOP or don't need AIMFP, avoid --scope user β it enables the server in every project you open.
| Scope | Effect | Best for |
|---|---|---|
--scope project (Recommended) | Creates .mcp.json in the current directory. Shareable via git. | Teams and per-project control |
--scope local | Stored in ~/.claude.json keyed to the current directory. Private. | Personal per-project use |
--scope user | Available in every project you open. | Developers who use AIMFP for all projects |
pip install (system-wide):
pip install (virtual environment) β use the venv's Python path:
A bare python3 resolves to the system Python, which won't have the package. Use the full path to the venv's interpreter so the MCP server subprocess finds the installed package.
Manual install or running from source β set PYTHONPATH to the parent of the aimfp/ folder:
Quick reference:
| Install Method | Claude Code Command |
|---|---|
pip install aimfp (system) | -- python3 -m aimfp |
pip install aimfp (venv) | -- /path/to/venv/bin/python3 -m aimfp |
| Manual folder / from source | --env PYTHONPATH=/parent/of/aimfp -- python3 -m aimfp |
Note: All flags (
--transport,--scope,--env) must come before the server name. The--separates the name from the command. Verify the server is connected with/mcpinside Claude Code.
What these tools actually do: AIMFP operates entirely inside the project you point it at. It never reads, writes, or reaches anything outside that project directory β and within it, all of its own state lives in a single .aimfp-project/ folder. The bulk of the 250+ tools are plain CRUD operations against the local SQLite database at .aimfp-project/project.db (tracking tasks, milestones, modules, and project state) plus read-only lookups of the bundled project directives. There are no network calls, no credentials, no access to your wider filesystem.
Claude Code's design prompts you to approve each MCP tool the first time it's called. With 250+ tools that's one one-time prompt per tool β tedious, but every prompt is just Claude Code confirming a local database or directive call. To skip the prompts, drop a Claude Code allowlist file (.claude/settings.local.json) into your project. This is a static Claude Code settings file that simply tells Claude Code "these tool names are pre-approved" β it is not downloaded or executed by AIMFP.
Just ask the AI to set it up:
The AI calls the get_claude_permissions tool, which returns the complete, current allowlist (generated live from the tool registry, so it can never be out of date or incomplete). The AI then writes β or, if you already have a .claude/settings.local.json, merges into β that file. Merging preserves every non-AIMFP permission and any other settings you already have; only the AIMFP entries are refreshed. AIMFP itself never writes the file (it never touches anything outside the project) β the AI does, with its normal file-write confirmation. The first call to get_claude_permissions is the one prompt you approve to eliminate all the rest.
The two MCP-autostart keys (enableAllProjectMcpServers and enabledMcpjsonServers) are included automatically so the AIMFP server starts itself when you have a .mcp.json in the project.
Note: A pre-built copy of this allowlist also ships at
documentation/settings.local.jsonif you'd rather review it directly or copy it in by hand (cp documentation/settings.local.json /path/to/your/project/.claude/). Theget_claude_permissionstool is the recommended path since it's always in sync with the installed version.
The server uses stdio transport. Point your client at python3 -m aimfp (or the full path to your venv's Python). For manual installs, ensure PYTHONPATH includes the parent directory of the aimfp/ folder. No API keys or authentication required.
The server communicates over stdio using the Model Context Protocol. It resolves aimfp_core.db (the directive database) relative to its own installation β no environment variables needed.
Once connected, the AI calls aimfp_run() on every interaction (guided by the system prompt). Project state is stored in .aimfp-project/ in your working directory, created automatically when you initialize a project.
Tell your AI assistant:
The AI calls aimfp_init which creates an .aimfp-project/ folder in your project root containing databases for project state tracking, user preferences, and a ProjectBlueprint document. You don't need to interact with these files β the MCP server manages them automatically.
FP Baseline (Always Active):
FP Directives (Reference Documentation):
fp_purity, fp_monadic_composition, fp_result_types, fp_wrapper_generationManage project lifecycle:
| Level | Directives | Purpose |
|---|---|---|
| Level 0 | aimfp_run | Gateway orchestration (every interaction) |
| Level 1 | aimfp_status, aimfp_init, project_task_decomposition | Status, initialization, high-level coordination |
| Level 2 | project_file_write, project_update_db, project_task_update | Operational execution |
| Level 3 | project_compliance_check, project_evolution | State management |
| Level 4 | project_completion_check, project_archive | Validation & completion |
Manage AI behavior customization and learning:
| Directive | Purpose |
|---|---|
| user_preferences_sync | Loads preferences before directive execution |
| user_preferences_update | Maps user requests to directives, updates preferences |
| user_preferences_learn | Learns from user corrections (requires confirmation) |
| user_preferences_export | Exports preferences to JSON for backup/sharing |
| user_preferences_import | Imports preferences from JSON file |
| project_notes_log | Handles logging to project.db with directive context |
| tracking_toggle | Enables/disables tracking features with token cost warnings |
FOR USE CASE 2 ONLY: Automation projects where AIMFP generates and manages the codebase:
| Directive | Purpose |
|---|---|
| user_directive_parse | Parse YAML/JSON/TXT directive files and extract structured directives |
| user_directive_validate | Validate directives through interactive Q&A to resolve ambiguities |
| user_directive_implement | Generate FP-compliant implementation code in src/ |
| user_directive_approve | User testing and approval workflow before activation |
| user_directive_activate | Deploy and activate directives for real-time execution |
| user_directive_monitor | Track execution statistics and handle errors |
| user_directive_update | Handle changes to directive source files (re-parse, re-validate) |
| user_directive_deactivate | Stop execution and clean up resources |
| user_directive_status | Comprehensive status reporting for all user directives |
Use Cases (Automation Projects):
Key Architecture:
src/, tests/, etc.)Key Features:
src/Example Directive Definition:
User tells AI: "Parse my directive file at directives/home_automation.yaml"
AI Generates (in src/lights_controller.py):
See the directive MD files in src/aimfp/reference/directives/ for complete workflow documentation.
FP-powered Git collaboration for multi-user and multi-AI development:
| Directive | Purpose |
|---|---|
| git_init | Initialize or integrate with Git repository for version control |
| git_detect_external_changes | Detect code modifications made outside AIMFP sessions |
| git_create_branch | Create user/AI work branches (aimfp-{user}-{number}) |
| git_detect_conflicts | FP-powered conflict analysis before merging |
| git_merge_branch | Merge branches with AI-assisted conflict resolution |
| git_sync_state | Synchronize Git hash with project.db for external change detection |
Key Features:
aimfp-alice-001, aimfp-bob-002, aimfp-ai-claude-001Why AIMFP + Git is Superior to OOP + Git:
| OOP Merge Problem | AIMFP FP Solution |
|---|---|
| Class hierarchies conflict | β No classes β No hierarchy conflicts |
| Hidden state changes | β Pure functions β Explicit inputs/outputs |
| Side effects everywhere | β Side effects isolated β Easy to identify conflicts |
| Hard to test both versions | β Pure functions β Easy to test and compare |
Example Conflict Resolution:
See the Git directive MD files in src/aimfp/reference/directives/ for complete multi-user collaboration workflows.
All directive documentation is shipped with the package at src/aimfp/reference/directives/ β 131 MD files covering every directive. Each file includes: purpose, when to apply, complete workflows (trunk β branches), compliant/non-compliant examples, edge cases, related directives, helper functions used, and database operations.
Schema SQL files are in the package at src/aimfp/database/schemas/:
aimfp_core.sql β Global read-only database (directives, helpers, flows)project.sql β Per-project mutable database (files, functions, tasks, milestones)user_preferences.sql β Per-project user customization databaseuser_directives.sql β Per-project automation directives (Use Case 2 only)dev/)The dev/ directory contains the source of truth for directive and helper function definitions. These JSON files are the canonical definitions that get imported into aimfp_core.db before release.
Dev workflow: Modify JSON files in dev/ β run sync-directives.py to rebuild aimfp_core.db β test β release. End users only interact with the pre-populated aimfp_core.db, never the JSON files directly.
All three must be kept in sync when bumping versions:
| File | Variable | Purpose |
|---|---|---|
pyproject.toml | version = "X.Y.Z" | Package version (PyPI, pip install) |
src/aimfp/__init__.py | __version__ = "X.Y.Z" | Runtime version (import aimfp; aimfp.__version__) |
src/aimfp/mcp_server/server.py | SERVER_VERSION = "X.Y.Z" | MCP initialize handshake response (serverInfo.version) |
aimfp_core.db is the rulebook (read-only, global, version-controlled)project.db is the workspace (read-write, per-project, runtime state)user_preferences.db is the customization layer (read-write, per-project, AI behavior)Traditional AI assistants lack persistent memory. AIMFP solves this:
Every AIMFP project has a completion path:
Once project_completion_check passes, the project is done. No endless feature creep.
watchdog), custom JSON-RPC server uses stdlib onlyAIMFP's project management adds token overhead to each session. Database operations (tracking files, updating tasks, managing milestones) consume tokens beyond the code-writing itself. We work to minimize this β continuation calls are lightweight (~2k tokens), batch helpers reduce round-trips, and all optional tracking is off by default.
The payoff comes with project scale. Without AIMFP, every new session requires the AI to re-scan directories, re-read source files, and rebuild context from scratch β costs that grow with codebase size. With AIMFP, the database provides instant structured context: the AI knows exactly which files exist, what functions they contain, where work left off, and what comes next. For projects beyond a handful of files, the up-front tracking cost is recovered many times over through eliminated re-discovery work.
User prompt: "Help me build a calculator"
Tool calls:
What happens:
aimfp_init helper.aimfp-project/ directory with project.db, user_preferences.db, and ProjectBlueprint.mdproject_discovery for collaborative planning (themes, flows, completion path, milestones)User prompt: "Write a multiply_matrices function"
Tool calls:
What happens:
project.db before writing (IDs embedded in names)User prompt: "Where are we?" or "Continue working"
Tool calls:
What happens:
project_continue_on_start=true, AI automatically picks up the next taskproject.dbAIMFP runs entirely on your local machine. No data ever leaves your computer.
.aimfp-project/ directory. You own and control all data.If you have questions about data handling, please open an issue on our GitHub repository.
AIMFP is an open standard for AI-optimized programming. Contributions welcome:
MIT License - See LICENSE for details.
AIMFP transforms AI from a "code generator" into a structured, customizable project collaborator.
It combines:
The result: AI-maintained codebases that are predictable, traceable, customizable, and maintainable across sessions, teams, and even different AI assistants.
Built for the age of AI-native development.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/aifp)<a href="https://allmcps.com/mcp/aifp"><img src="https://allmcps.com/api/badge/aifp?style=directory" alt="Aifp on AllMCPs" /></a>