File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change 77import argparse
88import os
99import sys
10+ import yaml
1011
1112# Determine how the script was invoked
1213if sys .argv [0 ].endswith ('main.py' ):
@@ -76,6 +77,57 @@ def dump_syntax_tree(
7677 """
7778 return run_ast_grep_dump (code , language , format .value )
7879
80+ @mcp .tool ()
81+ def get_supported_languages () -> List [str ]:
82+ """
83+ Get list of languages supported by ast-grep.
84+
85+ Returns common language identifiers that can be used in the 'language' parameter of other tools.
86+ Includes custom languages from config file if provided.
87+ """
88+ base_languages = [ # https://ast-grep.github.io/reference/languages.html
89+ "bash" ,
90+ "c" ,
91+ "cpp" ,
92+ "csharp" ,
93+ "css" ,
94+ "elixir" ,
95+ "go" ,
96+ "haskell" ,
97+ "html" ,
98+ "java" ,
99+ "javascript" ,
100+ "json" ,
101+ "jsx" ,
102+ "kotlin" ,
103+ "lua" ,
104+ "nix" ,
105+ "php" ,
106+ "python" ,
107+ "ruby" ,
108+ "rust" ,
109+ "scala" ,
110+ "solidity" ,
111+ "swift" ,
112+ "tsx" ,
113+ "typescript" ,
114+ "yaml"
115+ ]
116+
117+ # Check for custom languages in config file
118+ # https://ast-grep.github.io/advanced/custom-language.html#register-language-in-sgconfig-yml
119+ if CONFIG_PATH and os .path .exists (CONFIG_PATH ):
120+ try :
121+ import yaml
122+ with open (CONFIG_PATH , 'r' ) as f :
123+ config = yaml .safe_load (f )
124+ if config and 'customLanguages' in config :
125+ custom_langs = list (config ['customLanguages' ].keys ())
126+ return sorted (set (base_languages + custom_langs ))
127+ except Exception :
128+ pass
129+
130+ return base_languages
79131
80132@mcp .tool ()
81133def test_match_code_rule (
You can’t perform that action at this time.
0 commit comments