SuperAPI AI Directory

storage abstraction layer

Agents & models

View repository

Updated 10-16 08:39

About this skill

Storage Abstraction Layer

Unified interface for saving notes across different storage backends


Storage Selection

function get_storage_backend() {
  config = Read("km-config.json")
  return config?.storage?.primary || "local"
}

🛑 MCP Tool Priority Usage Rules (CRITICAL)

┌─────────────────────────────────────────────────────┐
│ 🛑 CRITICAL: MCP 도구 사용 강제                      │
│                                                      │
│ MCP 도구가 사용 가능한 환경에서는 반드시 MCP 사용!    │
│                                                      │
│ ❌ 잘못된 예:                                        │
│    - write_to_file("vault/note.md", content)         │
│                                                      │
│ ✅ 올바른 예:                                        │
│    - mcp_obsidian_create_note(path, content)         │
└─────────────────────────────────────────────────────┘

Backend Mapping (Antigravity/Gemini CLI)

Feature Obsidian Notion Local
Create mcp_obsidian_create_note mcp_notion_API-post-page write_to_file
Search mcp_obsidian_search_vault mcp_notion_API-post-search N/A
Read mcp_obsidian_read_note mcp_notion_API-get-block-children read_file
Path format Relative to vault Database/Page ID File system path
Wikilinks Supported Converted to mentions Supported

Note: Antigravity uses a single underscore (_) in MCP tool names.

MCP Tool Usage Guide (Obsidian)

Task Tool Name Description
Create Note mcp_obsidian_create_note Create a new note
Search Notes mcp_obsidian_search_vault Search keywords within the Vault
Read Note mcp_obsidian_read_note Read note content
List Notes mcp_obsidian_list_notes List notes within a folder

Unified Save Function

// Antigravity/Gemini CLI용 (싱글 언더스코어 사용)
function save_note(relativePath, content) {
  backend = get_storage_backend()
  config = Read("km-config.json")

  switch (backend) {
    case "obsidian":
      // ⚠️ 반드시 MCP 도구 사용!
      return mcp_obsidian_create_note({
        path: relativePath,
        content: content
      })

    case "notion":
      return mcp_notion_API_post_page({
        parent: { page_id: config.storage.notion.parentPageId },
        properties: { title: [{ text: { content: getTitle(relativePath) } }] }
      })

    case "local":
    default:
      fullPath = `${config.storage.local.outputPath}/${relativePath}`
      return write_to_file(fullPath, content)
  }
}

Path Normalization

function normalize_path(path) {
  // Windows backslash → forward slash
  path = path.replace(/\\/g, '/')

  // Remove leading slash for relative paths
  path = path.replace(/^\//, '')

  return path
}

Verification (CRITICAL)

After every save operation:

□ Did the tool actually execute? (no JSON-only output!)
□ Did we receive a success response?
□ Verify with Glob that file exists