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