File size: 2,237 Bytes
6993919
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
"""
Platform Auto-Sync — Keep all external directory listings in sync.

One command updates all platform descriptions everywhere by reading
the manifest and generating listing files for each directory.

Usage:
    python3 sync_platforms.py

Updates:
    - Smithery listing (smithery.json)
    - Glama listing (glama.json)
    - mcp.so listing (mcp-so.json)
    - /mcp/manifest endpoint (live, no sync needed)
    - README.md (platform description section)
"""

import json
import sys

sys.path.insert(0, "/root/backend")

from app.caching_shield.platform_manifest import (
    get_platform_manifest,
    sync_to_directory_listing,
    sync_to_readme,
)


def sync_all():
    m = get_platform_manifest()
    listing = sync_to_directory_listing()
    base_dir = "/srv/x402-gateway-base"

    # Smithery
    smithery = {
        **listing,
        "schema_version": "v1",
        "tools_count": m["tools"]["total"],
        "chains": sorted(m["tools"].get("chains", [])),
        "categories": list(m["agent_skills"]["categories"].keys()),
        "pricing": m["pricing"],
        "skills_count": m["agent_skills"]["total"],
        "endpoint": m["endpoints"]["mcp"],
        "discovery": m["endpoints"]["discovery"],
    }
    with open(f"{base_dir}/smithery.json", "w") as f:
        json.dump(smithery, f, indent=2)
    print(f"Smithery: {len(json.dumps(smithery))} bytes")

    # Glama
    glama = {
        "name": m["name"],
        "description": m["descriptions"]["medium"],
        "version": m["version"],
        "server_endpoint": m["endpoints"]["mcp"],
        "tools_count": m["tools"]["total"],
        "categories": list(m["agent_skills"]["categories"].keys()),
        "pricing": {
            "type": "pay_per_use",
            "free_trials": True,
            "memberships": True,
        },
    }
    with open(f"{base_dir}/glama.json", "w") as f:
        json.dump(glama, f, indent=2)
    print(f"Glama: {len(json.dumps(glama))} bytes")

    # Backend README section
    readme_section = sync_to_readme()
    print(f"README section: {len(readme_section)} chars")
    print(f"\nSync complete. Updated {m['version']}{m['tools']['total']} tools.")


if __name__ == "__main__":
    sync_all()