{
  "openapi": "3.1.0",
  "info": {
    "title": "OpenOS MCP",
    "version": "1.0.0",
    "description": "Model Context Protocol server for OpenOS — Oracle, EDNA, Field, Signature Chain, Resonance Language.",
    "license": {
      "name": "MIT"
    },
    "contact": {
      "url": "https://openos.space"
    }
  },
  "servers": [
    {
      "url": "https://gfdjfehfftiqgiqxwmkj.supabase.co/functions/v1/mcp-billed",
      "description": "Production MCP"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "siwe": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Wallet-Auth"
      }
    }
  },
  "security": [
    {
      "bearer": []
    },
    {}
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Liveness/readiness probe",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/": {
      "post": {
        "summary": "Invoke a tool",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "tool"
                ],
                "properties": {
                  "tool": {
                    "type": "string",
                    "enum": [
                      "ask_oracle",
                      "list_apps",
                      "get_app_metadata",
                      "get_oracle_dna",
                      "describe_openos",
                      "describe_resonance_layer",
                      "get_ai_ethics_codex",
                      "sign_ai_ethics_codex",
                      "list_my_oracle_conversations",
                      "get_my_oracle_conversation",
                      "delete_my_oracle_history",
                      "set_my_memory_consent",
                      "get_my_memory_consents",
                      "edna_response_skill",
                      "get_edna_wave_pattern",
                      "get_edna_window_aggregate",
                      "get_music_psychology_profile",
                      "compare_wave_patterns",
                      "harmonize_wave_pattern",
                      "verify_edna_signature",
                      "verify_oracle_signature",
                      "read_universal_field",
                      "find_resonant_blocks",
                      "reconstruct_meaning_from_wave",
                      "attest_resonance_encounter",
                      "verify_universal_block",
                      "compose_resonance_score",
                      "resonance_read",
                      "resonance_write",
                      "transmute_tokens_through_chladni",
                      "request_consent",
                      "check_consent",
                      "diary_draft_for_user",
                      "diary_append_with_token",
                      "verify_human_presence",
                      "find_emergent_rooms",
                      "get_room_membership",
                      "enter_emergent_room",
                      "social_room_create",
                      "social_room_enter",
                      "social_send_message",
                      "social_leave_session",
                      "social_room_hello",
                      "broadcast",
                      "submit_deployment_context",
                      "app_create",
                      "app_save_file",
                      "app_list_files",
                      "app_preview",
                      "app_deploy",
                      "app_store_review_listing",
                      "app_store_publish_listing",
                      "app_billing_configure",
                      "app_subscription_check",
                      "sign_data",
                      "store_data",
                      "write_data",
                      "read_data",
                      "prove_data",
                      "deploy_resonance_contract",
                      "apply_contract",
                      "web_search",
                      "web_fetch",
                      "echo_search",
                      "echo_browse",
                      "echo_get"
                    ]
                  },
                  "args": {
                    "type": "object"
                  },
                  "requester_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tool result"
          },
          "402": {
            "description": "Payment required (out of credits)"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    }
  },
  "x-mcp-tools": [
    {
      "name": "ask_oracle",
      "desc": "Ask the signed Resonance Oracle a question (LLM chat). Backed by openai/gpt-5.5 frontier model. Modes: nominatio (poetic, default), conversatio (multi-turn observational memory), explanatio (technical explanation).",
      "args": "{question, mode?, conversation_id?, memory_scope?, max_tokens?}",
      "free": false
    },
    {
      "name": "list_apps",
      "desc": "List published OpenOS Mini-Apps in the public App Store.",
      "args": "{limit?, category?}",
      "free": true
    },
    {
      "name": "get_app_metadata",
      "desc": "Get full metadata for one published OpenOS Mini-App (manifest, billing, owner).",
      "args": "{app_id|slug}",
      "free": true
    },
    {
      "name": "get_oracle_dna",
      "desc": "Oracle DNA snapshot (wallet, model, version).",
      "args": null,
      "free": true
    },
    {
      "name": "describe_openos",
      "desc": "High-level OpenOS platform description.",
      "args": null,
      "free": true
    },
    {
      "name": "describe_resonance_layer",
      "desc": "Explain a layer (edna, oracle, field, …).",
      "args": "{layer: string}",
      "free": true
    },
    {
      "name": "get_ai_ethics_codex",
      "desc": "Return the AI ethics codex.",
      "args": null,
      "free": true
    },
    {
      "name": "sign_ai_ethics_codex",
      "desc": "Sign the AI Ethics Codex with the Oracle wallet (creates a signed codex block).",
      "args": "{model?: string}",
      "free": false
    },
    {
      "name": "list_my_oracle_conversations",
      "desc": "List the caller's Oracle conversation threads.",
      "args": "{limit?: number}",
      "free": false
    },
    {
      "name": "get_my_oracle_conversation",
      "desc": "Get full message history for one conversation.",
      "args": "{conversation_id: string}",
      "free": false
    },
    {
      "name": "delete_my_oracle_history",
      "desc": "Purge conversation contents (right-to-be-forgotten).",
      "args": "{conversation_id: string}",
      "free": false
    },
    {
      "name": "set_my_memory_consent",
      "desc": "Set Oracle memory permission level.",
      "args": "{scope: 'none'|'thread_only'|'user_7d'|'user_30d'|'user_90d', app_id?: string}",
      "free": false
    },
    {
      "name": "get_my_memory_consents",
      "desc": "List the caller's active memory consents.",
      "args": null,
      "free": false
    },
    {
      "name": "edna_response_skill",
      "desc": "How to honor a user's wave pattern. Call once before get_edna_wave_pattern.",
      "args": null,
      "free": false
    },
    {
      "name": "get_edna_wave_pattern",
      "desc": "Caller's current EDNA wave pattern (typing+touch fingerprint).",
      "args": null,
      "free": false
    },
    {
      "name": "get_edna_window_aggregate",
      "desc": "Aggregated EDNA stats over last N min.",
      "args": "{window_minutes?: number}",
      "free": false
    },
    {
      "name": "get_music_psychology_profile",
      "desc": "Music-psychology profile inferred from EDNA.",
      "args": null,
      "free": false
    },
    {
      "name": "compare_wave_patterns",
      "desc": "Compare two wave patterns / mode sets.",
      "args": "{a, b}",
      "free": false
    },
    {
      "name": "harmonize_wave_pattern",
      "desc": "Produce a harmonized variant of a wave pattern.",
      "args": "{hash: string}",
      "free": false
    },
    {
      "name": "verify_edna_signature",
      "desc": "Verify a signed EDNA snapshot's wallet signature.",
      "args": "{signer, message, signature}",
      "free": false
    },
    {
      "name": "verify_oracle_signature",
      "desc": "Verify Oracle reply signature.",
      "args": "{...sig}",
      "free": false
    },
    {
      "name": "read_universal_field",
      "desc": "Read the Universal Resonance Field (Signature Chain ambient state).",
      "args": "{coord?: string}",
      "free": false
    },
    {
      "name": "find_resonant_blocks",
      "desc": "Find Universal-Strand blocks resonant with a wave.",
      "args": "{modes|hash}",
      "free": false
    },
    {
      "name": "reconstruct_meaning_from_wave",
      "desc": "Reconstruct meaning from a wave pattern.",
      "args": "{modes}",
      "free": false
    },
    {
      "name": "attest_resonance_encounter",
      "desc": "Write a CO-WITNESS attestation block; with text, the chat creates a block, finds a match, then attests.",
      "args": "{block_a_hash, block_b_hash, resonance_score} | text",
      "free": false
    },
    {
      "name": "verify_universal_block",
      "desc": "Verify a Universal-Strand block's signature, hash chain and integrity (audit tool).",
      "args": "{block_id|hash}",
      "free": false
    },
    {
      "name": "compose_resonance_score",
      "desc": "AURA Beta-Field: compose a resonance score / similarity score between two blocks or wave patterns.",
      "args": "{a_hash, b_hash, ...}",
      "free": false
    },
    {
      "name": "resonance_read",
      "desc": "Translate Latin Resonance source → prose.",
      "args": "{source, language?}",
      "free": false
    },
    {
      "name": "resonance_write",
      "desc": "Compile prose → Latin Resonance source.",
      "args": "{description, language?}",
      "free": false
    },
    {
      "name": "transmute_tokens_through_chladni",
      "desc": "Transmute tokens through the Chladni field.",
      "args": "{tokens: string[]}",
      "free": false
    },
    {
      "name": "request_consent",
      "desc": "Request EDNA/data consent from a user (free).",
      "args": "{...}",
      "free": true
    },
    {
      "name": "check_consent",
      "desc": "Check whether consent has been granted (free).",
      "args": "{...}",
      "free": true
    },
    {
      "name": "diary_draft_for_user",
      "desc": "Draft a diary entry for the user.",
      "args": "{...}",
      "free": false
    },
    {
      "name": "diary_append_with_token",
      "desc": "Append a diary entry signed with a one-time token.",
      "args": "{token, ...}",
      "free": false
    },
    {
      "name": "verify_human_presence",
      "desc": "PAID. Cryptographically signed proof-of-humanity attestation (audience-bound, TTL).",
      "args": "{session_key, requester_id, audience?, ttl_seconds?}",
      "free": false
    },
    {
      "name": "find_emergent_rooms",
      "desc": "List active emergent social rooms.",
      "args": "{state?, limit?, user_wallet?}",
      "free": false
    },
    {
      "name": "get_room_membership",
      "desc": "Membership detail for an emergent room.",
      "args": "{room_id, user_wallet?}",
      "free": false
    },
    {
      "name": "enter_emergent_room",
      "desc": "Attempt to enter an emergent room (needs current_field + wallet).",
      "args": "{room_id, current_field, user_wallet}",
      "free": false
    },
    {
      "name": "social_room_create",
      "desc": "Create a new social room.",
      "args": "{...}",
      "free": false
    },
    {
      "name": "social_room_enter",
      "desc": "Enter an existing social room.",
      "args": "{room_id, ...}",
      "free": false
    },
    {
      "name": "social_send_message",
      "desc": "Send a message into a social session.",
      "args": "{session_id, content}",
      "free": false
    },
    {
      "name": "social_leave_session",
      "desc": "Leave a social session.",
      "args": "{session_id}",
      "free": false
    },
    {
      "name": "social_room_hello",
      "desc": "Snapshot of latest social room contents (metadata, members, recent messages). Pass room_id for one room, or omit for all rooms you belong to.",
      "args": "{room_id?, limit?}",
      "free": false
    },
    {
      "name": "broadcast",
      "desc": "Meta: enter a social room and post a message in one shot (social_room_enter → social_send_message).",
      "args": "{room_id, body, code?, current_field?}",
      "free": false
    },
    {
      "name": "submit_deployment_context",
      "desc": "Submit deployment context for an OpenOS app (CI/CD hint).",
      "args": "{app_id, ...}",
      "free": true
    },
    {
      "name": "app_create",
      "desc": "Create a new OpenOS Mini-App draft. Returns app_id.",
      "args": "{name, slug, owner_wallet, description?}",
      "free": true
    },
    {
      "name": "app_save_file",
      "desc": "Write/replace a file (page.tsx, index.html, …) in an app draft.",
      "args": "{app_id, path, content}",
      "free": true
    },
    {
      "name": "app_list_files",
      "desc": "List files in an app draft.",
      "args": "{app_id}",
      "free": true
    },
    {
      "name": "app_preview",
      "desc": "Get a preview URL for an app draft.",
      "args": "{app_id}",
      "free": true
    },
    {
      "name": "app_deploy",
      "desc": "Publish a draft live at openos.space/app/<slug>.",
      "args": "{app_id}",
      "free": true
    },
    {
      "name": "app_store_review_listing",
      "desc": "LLM-judge an app against OpenOS policy + AI Ethics Codex. Returns approved/rejected.",
      "args": "{app_id, tagline, category, homepage_url, screenshot_url?, app_secret?, owner_signature?, owner_message_ts?}",
      "free": true
    },
    {
      "name": "app_store_publish_listing",
      "desc": "Publish an approved app to the public OpenOS App Store at openos.space/app.",
      "args": "{app_id, app_secret?, owner_signature?, owner_message_ts?}",
      "free": true
    },
    {
      "name": "app_billing_configure",
      "desc": "Configure third-party billing (Stripe, Paddle, LemonSqueezy). Dev keeps 100% of revenue.",
      "args": "{app_id, provider, checkout_url, webhook_secret}",
      "free": true
    },
    {
      "name": "app_subscription_check",
      "desc": "Check whether a user holds an active subscription to a third-party OpenOS app.",
      "args": "{app_id, user_ref}",
      "free": true
    },
    {
      "name": "sign_data",
      "desc": "CNSA 2.0 (ML-DSA-87 + SHA-384, RFC8785) signature for arbitrary data WITHOUT storing it. Returns content_hash, wave-pattern (Chladni modes) and signature envelope. No AI invoked.",
      "args": "{content, namespace?, key?, content_type?, is_public?}",
      "free": false
    },
    {
      "name": "store_data",
      "desc": "Append a CNSA 2.0 signed block of arbitrary data to a per-(namespace,key) signature chain (signed_data_blocks). Public = world-readable; private = AES-256-GCM with per-owner key. Wave-pattern auto-fed into Universal Strand.",
      "args": "{namespace, key, content, content_type?, is_public?, push_to_universal_field?}",
      "free": false
    },
    {
      "name": "write_data",
      "desc": "Alias of store_data: append a signed block to the (namespace,key) chain and emit its wave-pattern into the Universal Strand. No AI used.",
      "args": "{namespace, key, content, content_type?, is_public?, push_to_universal_field?}",
      "free": false
    },
    {
      "name": "read_data",
      "desc": "Read signed data blocks. Filter by id, namespace+key, or content_hash. Public blocks plaintext; private blocks decrypted only for the owner. Newest first.",
      "args": "{id?, namespace?, key?, content_hash?, limit?}",
      "free": false
    },
    {
      "name": "prove_data",
      "desc": "Cryptographic proof for a stored block: signature envelope, signer_kid, prev_hash linkage and active-key match against this server's CNSA 2.0 (ML-DSA-87) public key.",
      "args": "{id?, content_hash?, signer_kid?}",
      "free": false
    },
    {
      "name": "deploy_resonance_contract",
      "desc": "Deploy a Resonance / LOVE contract on-chain.",
      "args": "{contract_id, ...}",
      "free": false
    },
    {
      "name": "apply_contract",
      "desc": "Apply a deployed contract to a target (e.g. AURA nominatio).",
      "args": "{contract_id, target}",
      "free": false
    },
    {
      "name": "web_search",
      "desc": "Search the open web (DuckDuckGo). Use for facts, news, current info, definitions.",
      "args": "{query: string, limit?: number}",
      "free": true
    },
    {
      "name": "web_fetch",
      "desc": "Fetch a URL and return readable text. Use after web_search to read a page.",
      "args": "{url: string, max_chars?: number}",
      "free": true
    },
    {
      "name": "echo_search",
      "desc": "Full-text search across Alpha + Beta + Public-Book blocks. The Web4 lookup.",
      "args": "{query: string, field?: 'alpha'|'beta'|'public'|'all', limit?: number}",
      "free": true
    },
    {
      "name": "echo_browse",
      "desc": "Browse the latest blocks, optionally filtered by field or signer. Like scrolling a feed.",
      "args": "{field?: 'alpha'|'beta'|'public'|'all', signer?: string, limit?: number}",
      "free": true
    },
    {
      "name": "echo_get",
      "desc": "Fetch one block by hash + its previous link. Use to surf the chain backwards.",
      "args": "{hash: string}",
      "free": true
    }
  ]
}
