Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions scripts/get_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
format="%(asctime)s - %(levelname)s - %(message)s")
logger = logging.getLogger(__name__)

_OUTPUT_DIR = "mcp-registry/servers/"


class ManifestGenerator:
"""Generate and manage MCP server manifests from GitHub repositories."""
Expand Down Expand Up @@ -857,11 +859,8 @@ def filter_and_sort_installations(installations: dict[str, dict[str, Any]]) -> d
return dict(sorted_installations)


def main(repo_url: str, is_official: bool = False):
def main(repo_url: str, is_official: bool = False, output_dir: str = _OUTPUT_DIR):
try:
# Ensure the target directory exists
os.makedirs("mcp-registry/servers", exist_ok=True)

# Generate the manifest
generator = ManifestGenerator()
manifest = generator.generate_manifest(repo_url)
Expand All @@ -873,11 +872,10 @@ def main(repo_url: str, is_official: bool = False):
"Generated manifest is missing a name and/or author name")

# determine the filename
os.makedirs("local/servers", exist_ok=True)
filename = f"local/servers/{manifest['name']}_new.json"
filename = os.path.join(output_dir, f"{manifest['name']}_new.json")
if not is_official:
name = f"@{manifest['author']['name']}/{manifest['name']}"
filename = f"mcp-registry/servers/{manifest['name']}@{manifest['author']['name']}.json"
filename = os.path.join(output_dir, f"{manifest['name']}@{manifest['author']['name']}.json")
manifest["name"] = name

# save the manifest with the determined filename
Expand All @@ -901,18 +899,27 @@ def main(repo_url: str, is_official: bool = False):
sys.exit(1)

repo_url = sys.argv[1].strip()

output_dir = _OUTPUT_DIR
if repo_url == "test":
# overwrite global output directory
output_dir = "local/servers/"

os.makedirs(output_dir, exist_ok=True)

if repo_url == "test":
# run through all the test cases
repo_urls = [
# "https://github.com/modelcontextprotocol/servers/tree/main/src/time",
"https://github.com/modelcontextprotocol/servers/tree/main/src/time",
"https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite",
# "https://github.com/modelcontextprotocol/servers/tree/main/src/slack",
# "https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking",
# "https://github.com/modelcontextprotocol/servers/tree/main/src/sentry"
"https://github.com/modelcontextprotocol/servers/tree/main/src/slack",
"https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking",
"https://github.com/modelcontextprotocol/servers/tree/main/src/sentry"
]

for repo_url in repo_urls:
logger.info(f"Processing GitHub URL: {repo_url}")
main(repo_url, is_official=True)
main(repo_url, is_official=True, output_dir=output_dir)
else:
# Check if the URL is a simple URL without protocol
if not repo_url.startswith(("http://", "https://")):
Expand All @@ -938,4 +945,4 @@ def main(repo_url: str, is_official: bool = False):
# Initialize logger only once to avoid duplicate logs
logger.info(f"Processing GitHub URL: {repo_url}")

main(repo_url, is_official)
main(repo_url, is_official, output_dir)