1818 format = "%(asctime)s - %(levelname)s - %(message)s" )
1919logger = logging .getLogger (__name__ )
2020
21+ _OUTPUT_DIR = "mcp-registry/servers/"
22+
2123
2224class ManifestGenerator :
2325 """Generate and manage MCP server manifests from GitHub repositories."""
@@ -857,11 +859,8 @@ def filter_and_sort_installations(installations: dict[str, dict[str, Any]]) -> d
857859 return dict (sorted_installations )
858860
859861
860- def main (repo_url : str , is_official : bool = False ):
862+ def main (repo_url : str , is_official : bool = False , output_dir : str = _OUTPUT_DIR ):
861863 try :
862- # Ensure the target directory exists
863- os .makedirs ("mcp-registry/servers" , exist_ok = True )
864-
865864 # Generate the manifest
866865 generator = ManifestGenerator ()
867866 manifest = generator .generate_manifest (repo_url )
@@ -873,11 +872,10 @@ def main(repo_url: str, is_official: bool = False):
873872 "Generated manifest is missing a name and/or author name" )
874873
875874 # determine the filename
876- os .makedirs ("local/servers" , exist_ok = True )
877- filename = f"local/servers/{ manifest ['name' ]} _new.json"
875+ filename = os .path .join (output_dir , f"{ manifest ['name' ]} _new.json" )
878876 if not is_official :
879877 name = f"@{ manifest ['author' ]['name' ]} /{ manifest ['name' ]} "
880- filename = f"mcp-registry/servers/ { manifest ['name' ]} @{ manifest ['author' ]['name' ]} .json"
878+ filename = os . path . join ( output_dir , f" { manifest ['name' ]} @{ manifest ['author' ]['name' ]} .json")
881879 manifest ["name" ] = name
882880
883881 # save the manifest with the determined filename
@@ -901,18 +899,27 @@ def main(repo_url: str, is_official: bool = False):
901899 sys .exit (1 )
902900
903901 repo_url = sys .argv [1 ].strip ()
902+
903+ output_dir = _OUTPUT_DIR
904+ if repo_url == "test" :
905+ # overwrite global output directory
906+ output_dir = "local/servers/"
907+
908+ os .makedirs (output_dir , exist_ok = True )
909+
904910 if repo_url == "test" :
905911 # run through all the test cases
906912 repo_urls = [
907- # "https://github.com/modelcontextprotocol/servers/tree/main/src/time",
913+ "https://github.com/modelcontextprotocol/servers/tree/main/src/time" ,
908914 "https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite" ,
909- # "https://github.com/modelcontextprotocol/servers/tree/main/src/slack",
910- # "https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking",
911- # "https://github.com/modelcontextprotocol/servers/tree/main/src/sentry"
915+ "https://github.com/modelcontextprotocol/servers/tree/main/src/slack" ,
916+ "https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking" ,
917+ "https://github.com/modelcontextprotocol/servers/tree/main/src/sentry"
912918 ]
919+
913920 for repo_url in repo_urls :
914921 logger .info (f"Processing GitHub URL: { repo_url } " )
915- main (repo_url , is_official = True )
922+ main (repo_url , is_official = True , output_dir = output_dir )
916923 else :
917924 # Check if the URL is a simple URL without protocol
918925 if not repo_url .startswith (("http://" , "https://" )):
@@ -938,4 +945,4 @@ def main(repo_url: str, is_official: bool = False):
938945 # Initialize logger only once to avoid duplicate logs
939946 logger .info (f"Processing GitHub URL: { repo_url } " )
940947
941- main (repo_url , is_official )
948+ main (repo_url , is_official , output_dir )
0 commit comments