{
  "markdown": "# Memory Interchange Format (MIF)\n\n[![PyPI](https://img.shields.io/pypi/v/mif-tools?label=PyPI&logo=python&logoColor=white)](https://pypi.org/project/mif-tools/)\n[![npm](https://img.shields.io/npm/v/@varunshodh/mif-tools?label=npm&logo=npm&logoColor=white)](https://www.npmjs.com/package/@varunshodh/mif-tools)\n[![License](https://img.shields.io/github/license/varun29ankuS/mif-spec)](https://github.com/varun29ankuS/mif-spec/blob/main/LICENSE)\n[![Tests](https://img.shields.io/github/actions/workflow/status/varun29ankuS/mif-spec/validate.yml?label=tests&logo=github)](https://github.com/varun29ankuS/mif-spec/actions/workflows/validate.yml)\n[![Docs](https://img.shields.io/github/actions/workflow/status/varun29ankuS/mif-spec/pages.yml?label=docs&logo=github)](https://varun29ankus.github.io/mif-spec/)\n\n**Your AI agent has 6 months of memories in System A. You want to try System B. Without MIF, you lose everything. With MIF:**\n\n```bash\npip install mif-tools\nmif convert mem0_export.json --to shodh -o memories.mif.json\n```\n\nDone. Your memories are portable.\n\n## What is MIF?\n\nA vendor-neutral JSON envelope for AI agent memories. Like vCard for contacts or iCalendar for events — a minimal schema so memories move between providers without data loss.\n\n**3 required fields.** That's it.\n\n```json\n{\n  \"mif_version\": \"2.0\",\n  \"memories\": [\n    {\n      \"id\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n      \"content\": \"User prefers dark mode across all applications\",\n      \"created_at\": \"2026-01-15T10:30:00Z\"\n    }\n  ]\n}\n```\n\nEverything else — memory types, tags, entities, embeddings, knowledge graph, vendor extensions — is optional. Add what you have, ignore what you don't.\n\n## Install\n\n```bash\n# Python\npip install mif-tools              # core (zero dependencies)\npip install mif-tools[validate]    # with JSON Schema validation\npip install mif-tools[mcp]         # with MCP server\n\n# Node.js / TypeScript\nnpm install @varunshodh/mif-tools\n```\n\n## Convert Between Formats\n\n```bash\n# mem0 → MIF\nmif convert mem0_export.json --from mem0 -o memories.mif.json\n\n# MIF → Markdown (Obsidian/Letta style)\nmif convert memories.mif.json --to markdown -o memories.md\n\n# Auto-detect source format\nmif convert any_memory_file.json -o output.mif.json\n\n# Inspect any memory file\nmif inspect memories.json\n\n# Validate MIF document\nmif validate memories.mif.json\n```\n\n## Python API\n\n```python\nfrom mif import load, dump, convert, MifDocument, Memory\n\n# Load from any format (auto-detects mem0, markdown, generic JSON, MIF)\ndoc = load(open(\"mem0_export.json\").read())\nprint(f\"{len(doc.memories)} memories loaded\")\n\n# Convert between formats in one line\nmarkdown = convert(data, from_format=\"mem0\", to_format=\"markdown\")\n\n# Create memories from scratch\ndoc = MifDocument(memories=[\n    Memory(\n        id=\"123e4567-e89b-12d3-a456-426614174000\",\n        content=\"User prefers dark mode\",\n        created_at=\"2026-01-15T10:30:00Z\",\n        memory_type=\"observation\",\n        tags=[\"preferences\", \"ui\"],\n    )\n])\nprint(dump(doc))  # MIF v2 JSON\n\n# Deep validation (UUIDs, references, timestamps, embedding dimensions)\nfrom mif import validate_deep\nok, warnings = validate_deep(open(\"export.mif.json\").read())\n```\n\n## Add MIF to Your MCP Server (10 lines)\n\n```python\nfrom mif import load, dump\n\n# Export handler\ndef export_memories(user_id: str) -> str:\n    memories = my_storage.get_all(user_id)\n    return dump(memories)\n\n# Import handler — auto-detects mem0, markdown, generic JSON, MIF\ndef import_memories(data: str) -> dict:\n    doc = load(data)\n    for mem in doc.memories:\n        my_storage.save(mem.id, mem.content, mem.created_at)\n    return {\"memories_imported\": len(doc.memories)}\n```\n\n## Supported Formats\n\n| Format | ID | Auto-detect | Description |\n|--------|----|-------------|-------------|\n| **MIF v2** | `shodh` | `\"mif_version\"` in JSON | Native format, lossless round-trip |\n| **mem0** | `mem0` | JSON array with `\"memory\"` field | mem0 memory exports |\n| **CrewAI** | `crewai` | JSON array with `\"task_description\"` | CrewAI LTMSQLiteStorage exports |\n| **LangChain** | `langchain` | JSON array with `\"namespace\"` + `\"value\"` | LangChain/LangMem Item format |\n| **Generic JSON** | `generic` | JSON array with `\"content\"` field | Any JSON memory array |\n| **Markdown** | `markdown` | Starts with `---` | YAML frontmatter (Letta/Obsidian style) |\n\n## Full Spec\n\nMIF supports optional fields for rich memory data:\n\n- **Memory types** — `observation`, `decision`, `learning`, `error`, `context`, `conversation`, and custom types\n- **Entity references** — named entities with type and confidence\n- **Embeddings** — model name, dimensions, vector (reuse or regenerate)\n- **Knowledge graph** — entities and relationships with confidence scores\n- **Vendor extensions** — system-specific metadata preserved on round-trip\n- **Privacy** — PII detection and redaction markers\n\nFull specification: [`spec/mif-v2.md`](./spec/mif-v2.md) | JSON Schema: [`schema/mif-v2.schema.json`](./schema/mif-v2.schema.json)\n\n## MCP Server\n\nExpose MIF tools to any MCP-compatible AI client:\n\n```bash\npip install mif-tools[mcp]\nmif mcp\n```\n\nTools: `export_memories`, `import_memories`, `validate_memories`, `inspect_memories`, `list_formats`\n\n## Adapters & Implementations\n\n| System | Status | Type |\n|--------|--------|------|\n| [shodh-memory](https://github.com/varun29ankuS/shodh-memory) | Production | Built-in HTTP API (`/api/export/mif`, `/api/import/mif`) |\n| [mif-tools (PyPI)](https://pypi.org/project/mif-tools/) | Production | Python package with CLI + MCP server |\n| [@varunshodh/mif-tools (npm)](https://www.npmjs.com/package/@varunshodh/mif-tools) | Production | TypeScript/Node.js package with CLI |\n| mem0 | Adapter ready | Python + npm |\n| CrewAI | Adapter ready | Python + npm |\n| LangChain | Adapter ready | Python + npm |\n| Generic JSON | Adapter ready | Python + npm |\n| Markdown (YAML frontmatter) | Adapter ready | Python + npm |\n\n## Design Principles\n\n1. **Minimal** — 3 required fields. Everything else is optional.\n2. **Extensible** — Unknown fields and vendor extensions MUST be preserved on round-trip.\n3. **Vendor-neutral** — The schema doesn't favor any implementation.\n4. **Forward-compatible** — Importers MUST ignore unknown fields.\n\n## Contributing\n\nWe welcome adapter implementations for any memory system. See [CONTRIBUTING.md](./CONTRIBUTING.md).\n\n## Related\n\n- [Documentation](https://varun29ankus.github.io/mif-spec/) — Full docs site\n- [MCP SEP #2342](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2342) — Original proposal to the Model Context Protocol\n- [tower-mcp #531](https://github.com/joshrotenberg/tower-mcp/issues/531) — Tracking issue in tower-mcp\n- [shodh-memory](https://github.com/varun29ankuS/shodh-memory) — Reference implementation (Rust)\n- [mif-tools on PyPI](https://pypi.org/project/mif-tools/) — Python package\n- [@varunshodh/mif-tools on npm](https://www.npmjs.com/package/@varunshodh/mif-tools) — npm package\n\n## License\n\nApache 2.0\n",
  "bytes": 6991,
  "sha": "943443238642f4dbc37d0766aeb225dda508c1597ba4b2c57bece96221c728d7",
  "repo_slug": "varun29ankus/mif-spec",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_varun29ankus_mif_tools_a75ee996/readme"
}