Add supported languages to MCP tool parameter description #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With this PR the language parameter description is dynamically calculated on mcp server start based on the supported languages by ast-grep including custom languages configured in sgconfig.yaml
I had to wrap the mcp tool definitions into a function so that their language description field is not computed on import time but after the args are parsed and thus the sgconfig.yaml file can be loaded.
So to better review the PR check the changes with whitespace changes ignored: https://github.com/ast-grep/ast-grep-mcp/pull/11/files?w=1
An alternative to the current approach would be to move the mcp tool functions to a dedicated file (e.g. mcp_tools.py) and only do arg parsing, server setup in the main.py. this feels cleaner to me but is a bigger change. I would be happy to do that if you agree.