|
| 1 | +""" |
| 2 | +Fix definition IDs: |
| 3 | +- Community-driven definitions: use GitHub org as domain (e.g., crystaldba.postgres-mcp-uvx) |
| 4 | +- Official vendor definitions: keep current domain (com.redis-mcp, com.mongodb-mcp, etc.) |
| 5 | +- Ensure all IDs match filename pattern |
| 6 | +
|
| 7 | +Rules: |
| 8 | +- If contributor.github matches the repo org AND it's not a major vendor domain (com., io., etc.), |
| 9 | + use the GitHub org: githubuser.servername-tool |
| 10 | +- For modelcontextprotocol/servers, keep "community." prefix |
| 11 | +- For official vendor repos (company.com domains), keep existing convention |
| 12 | +""" |
| 13 | +import json, subprocess, re, os |
| 14 | + |
| 15 | +os.chdir('d:\\mcpmux\\mcp-servers') |
| 16 | + |
| 17 | +main_files = set(subprocess.check_output( |
| 18 | + ['git', 'ls-tree', '-r', '--name-only', 'main', '--', 'servers/'], |
| 19 | + text=True |
| 20 | +).strip().split('\n')) |
| 21 | + |
| 22 | +branches = subprocess.check_output(['git', 'branch', '--list', 'fix/*'], text=True).strip().split('\n') |
| 23 | +branches = [b.strip().lstrip('* ') for b in branches if b.strip()] |
| 24 | + |
| 25 | +# Map of current file -> what the ID SHOULD be based on repo org |
| 26 | +# community.* prefix servers that should use github org instead |
| 27 | +COMMUNITY_REMAP = { |
| 28 | + # crystaldba/postgres-mcp -> crystaldba.postgres-mcp-uvx |
| 29 | + 'community.postgresql-uvx': 'crystaldba.postgres-mcp-uvx', |
| 30 | + # domdomegg/airtable-mcp-server -> domdomegg.airtable-mcp-npx |
| 31 | + 'community.airtable-npx': 'domdomegg.airtable-mcp-npx', |
| 32 | + # ThetaBird/mcp-server-axiom-js -> thetabird.axiom-mcp-npx |
| 33 | + 'community.axiom-npx': 'thetabird.axiom-mcp-npx', |
| 34 | + # orellazri/coda-mcp -> orellazri.coda-mcp-npx |
| 35 | + 'community.coda-npx': 'orellazri.coda-mcp-npx', |
| 36 | + # aashari/mcp-server-atlassian-jira -> aashari.jira-mcp-npx |
| 37 | + 'community.jira-npx': 'aashari.jira-mcp-npx', |
| 38 | + # CakeRepository/1Password-MCP -> cakerepository.1password-mcp-npx |
| 39 | + 'community.1password-npx': 'cakerepository.1password-mcp-npx', |
| 40 | + # modelcontextprotocol/servers - these stay community.* |
| 41 | + # 'community.fetch-uvx': keep as is |
| 42 | + # 'community.memory-npx': keep as is |
| 43 | + # 'community.sequential-thinking-npx': keep as is |
| 44 | + # 'community.google-maps-npx': keep as is |
| 45 | + # 'community.gitlab-npx': keep as is |
| 46 | +} |
| 47 | + |
| 48 | +results = [] |
| 49 | + |
| 50 | +for branch in sorted(branches): |
| 51 | + files_out = subprocess.run( |
| 52 | + ['git', 'ls-tree', '-r', '--name-only', branch, '--', 'servers/'], |
| 53 | + capture_output=True, text=True |
| 54 | + ) |
| 55 | + if files_out.returncode != 0: |
| 56 | + continue |
| 57 | + |
| 58 | + all_files = files_out.stdout.strip().split('\n') |
| 59 | + new_files = [f for f in all_files if f not in main_files and f.endswith('.json')] |
| 60 | + |
| 61 | + if not new_files: |
| 62 | + continue |
| 63 | + |
| 64 | + # Check if any file needs ID remap |
| 65 | + needs_fix = False |
| 66 | + for f in new_files: |
| 67 | + basename = os.path.basename(f).replace('.json', '') |
| 68 | + if basename in COMMUNITY_REMAP: |
| 69 | + needs_fix = True |
| 70 | + break |
| 71 | + |
| 72 | + if not needs_fix: |
| 73 | + continue |
| 74 | + |
| 75 | + # Checkout |
| 76 | + subprocess.run(['git', 'checkout', branch], capture_output=True, text=True) |
| 77 | + |
| 78 | + changed = False |
| 79 | + renames_done = [] |
| 80 | + |
| 81 | + for f in new_files: |
| 82 | + basename = os.path.basename(f).replace('.json', '') |
| 83 | + if basename not in COMMUNITY_REMAP: |
| 84 | + continue |
| 85 | + |
| 86 | + new_id = COMMUNITY_REMAP[basename] |
| 87 | + new_filename = f"servers/{new_id}.json" |
| 88 | + |
| 89 | + # Read and update |
| 90 | + with open(f) as fh: |
| 91 | + defn = json.load(fh) |
| 92 | + |
| 93 | + old_id = defn['id'] |
| 94 | + defn['id'] = new_id |
| 95 | + |
| 96 | + with open(f, 'w') as fh: |
| 97 | + json.dump(defn, fh, indent=2) |
| 98 | + fh.write('\n') |
| 99 | + |
| 100 | + # Git mv |
| 101 | + subprocess.run(['git', 'mv', f, new_filename], capture_output=True, text=True) |
| 102 | + renames_done.append((basename, new_id, old_id)) |
| 103 | + changed = True |
| 104 | + |
| 105 | + if changed: |
| 106 | + subprocess.run(['git', 'add', '-A'], capture_output=True, text=True) |
| 107 | + msg = "fix: use GitHub org as ID domain for community definitions\n\n" |
| 108 | + for old, new, old_id in renames_done: |
| 109 | + msg += f"- {old_id} -> {new}\n" |
| 110 | + |
| 111 | + subprocess.run([ |
| 112 | + 'git', 'commit', '-s', |
| 113 | + '--author=Mohammod Al Amin Ashik <maa.ashik00@gmail.com>', |
| 114 | + '-m', msg |
| 115 | + ], capture_output=True, text=True) |
| 116 | + |
| 117 | + push = subprocess.run(['git', 'push', 'origin', branch], capture_output=True, text=True) |
| 118 | + for old, new, old_id in renames_done: |
| 119 | + status = "OK" if push.returncode == 0 else "PUSH_FAIL" |
| 120 | + print(f"{status} {branch}: {old_id} -> {new}") |
| 121 | + results.append((branch, old_id, new)) |
| 122 | + |
| 123 | +subprocess.run(['git', 'checkout', 'main'], capture_output=True, text=True) |
| 124 | +print(f"\n=== Fixed {len(results)} community definition IDs ===") |
0 commit comments