openapi: 3.0.3
info:
  title: SiloFree Vault Bridge
  version: "1.0.0"
  description: |
    Local REST surface of the SiloFree MCP server (mcp-server.mjs --http PORT).
    Lets "conventional" integrations — Dots/OpenAI custom connectors, Apple
    Shortcuts, Perplexity connectors, anything that speaks OpenAPI — use the
    vault through scoped, token-protected, read-only endpoints.

    NEVER expose this to the public internet without your own tunnel + auth.
    The passphrase is never accepted here. Card secrets are never returned.
  contact:
    name: iggym
    url: https://github.com/iggym/silo-free
servers:
  - url: http://127.0.0.1:8377
    description: Local bridge (start with --http 8377)
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: bridge-token
  schemas:
    Status:
      type: object
      properties:
        app: { type: string, example: silofree }
        unlocked: { type: boolean }
        items: { type: integer }
        by_type: { type: object, additionalProperties: { type: integer } }
        last_updated: { type: string, format: date-time, nullable: true }
        scopes: { type: array, items: { type: string } }
        read_only: { type: boolean, example: true }
    TitleRow:
      type: object
      properties:
        id: { type: string }
        type: { type: string, enum: [login, note, api_key, card] }
        title: { type: string }
        domain: { type: string }
        updated_at: { type: string, format: date-time, nullable: true }
    Totp:
      type: object
      properties:
        title: { type: string }
        code: { type: string, example: "042199" }
        digits: { type: integer }
        period_seconds: { type: integer }
        seconds_remaining: { type: integer }
        algorithm: { type: string, enum: ["SHA-1", "SHA-256", "SHA-512"] }
    Secret:
      type: object
      properties:
        title: { type: string }
        username: { type: string }
        secret: { type: string, description: password or API key }
security:
  - bearerAuth: []
paths:
  /health:
    get:
      summary: Liveness + lock state (no token)
      security: []
      responses: { "200": { description: ok } }
  /status:
    get:
      summary: Vault health — counts, last update, scopes (no secrets)
      responses:
        "200": { description: ok, content: { application/json: { schema: { $ref: '#/components/schemas/Status' } } } }
        "423": { description: auto-locked }
  /titles:
    get:
      summary: List or search item titles and domains (names only; scope titles)
      parameters:
        - { name: q, in: query, schema: { type: string }, description: substring over titles/domains }
      responses:
        "200": { description: ok, content: { application/json: { schema: { type: object, properties: { count: { type: integer }, items: { type: array, items: { $ref: '#/components/schemas/TitleRow' } } } } } } }
        "403": { description: titles scope not enabled }
  /totp:
    get:
      summary: Current 2FA code for one login (scope totp)
      parameters:
        - { name: title, in: query, required: true, schema: { type: string } }
      responses:
        "200": { description: ok, content: { application/json: { schema: { $ref: '#/components/schemas/Totp' } } } }
        "404": { description: no match / no TOTP on item }
  /secret:
    get:
      summary: One password or API key (scope secrets — OFF by default; card items never)
      parameters:
        - { name: title, in: query, required: true, schema: { type: string } }
      responses:
        "200": { description: ok, content: { application/json: { schema: { $ref: '#/components/schemas/Secret' } } } }
        "403": { description: secrets scope not enabled, or card item refused }
        "404": { description: no match / no stored secret }
  /mcp:
    post:
      summary: Stateless MCP JSON-RPC 2.0 (initialize / tools/list / tools/call)
      requestBody: { required: true, content: { application/json: { schema: { type: object } } } }
      responses: { "200": { description: rpc response }, "204": { description: notification accepted } }
