ast-grep/ast-grep-mcp
ast-grep/ast-grep-mcp
51d5a23f025csg-mcp0.1.0 in pyproject.tomlPaths from tool input into commands, SQL, files and URLs
How much power the tools give an agent over the machine
Hidden instructions and poisoning in text for the model
Known vulnerabilities in the packages the server uses
How the server reads credentials and where they can go
Whether the tools do only what their descriptions say
Top risks in plain words
- CRITICAL2 production dependencies have known vulnerabilities (worst: critical).
How to use it safely
Practical steps from what we found in this server. They lower the risk; they do not replace a review of the code.
- Update its vulnerable packages
Use
opentelemetry-api1.45.2 or later,pyjwt2.15.0 or later. - Keep confirmations on
Leave your MCP client's confirmation prompt on for tools that change files, run commands or send data.
What its tools can do on your machine
The server offers 4 tools. When an AI agent calls them, this is what their code can do on the machine where the server runs, as traced in the source. Tools that call code the scanner could not follow may do more.
dump_syntax_tree, find_code, find_code_by_rule, test_match_code_ruledump_syntax_tree, find_codeNo tool was seen to: connect to the internet or other hosts; read passwords, tokens or keys; read environment variables; touch sensitive locations.
Where its requests and secrets go
Read from the names along each tool's calls, not from a run: what the code says, not every address it may reach at run time.
The literal addresses the tools' requests name.
- None: no request names a fixed host.
Constants or settings that start an address; the value comes from configuration.
- None seen.
Credential-like environment variables. Give the server a key with the least access it needs.
- None: no credential-like variable is read by the tools.
Text it brings in from outside
Text that reaches the model from outside: an instruction hidden in it can steer the agent (prompt injection). Treat what these tools return as data, not as orders.
- files2 tools · dump_syntax_tree, find_code
Tool annotations
No tool declares MCP annotations (readOnlyHint, destructiveHint and the rest). Clients use them to decide what to confirm; directories such as Anthropic's and OpenAI's ask for them.
Tools, prompts and resources (4: 4 tools)
Open a row for its full description. Chips show what its code can reach, and which risky capability its own description declares.
dump_syntax_treetool Dump code's syntax structure or dump a query's pattern structure.ProcessesFilesoutside text
Dump code's syntax structure or dump a query's pattern structure.
This is useful to discover correct syntax kind and syntax tree structure. Call it when debugging a rule.
The tool requires three arguments: code, language and format. The first two are self-explanatory.
`format` is the output format of the syntax tree.
use `format=cst` to inspect the code's concrete syntax tree structure, useful to debug target code.
use `format=pattern` to inspect how ast-grep interprets a pattern, useful to debug pattern rule.
Internally calls: ast-grep run --pattern <code> --lang <language> --debug-query=<format>find_codetool Find code in a project folder that matches the given ast-grep pattern.ProcessesFilesoutside text
Find code in a project folder that matches the given ast-grep pattern.
Pattern is good for simple and single-AST node result.
For more complex usage, please use YAML by `find_code_by_rule`.
Internally calls: ast-grep run --pattern <pattern> [--json] <project_folder>
Output formats:
- text (default): Compact text format with file:line-range headers and complete match text
Example:
Found 2 matches:
path/to/file.py:10-15
def example_function():
# function body
return result
path/to/file.py:20-22
def another_function():
pass
- json: Full match objects with metadata including ranges, meta-variables, etc.
The max_results parameter limits the number of complete matches returned (not individual lines).
When limited, the header shows "Found X matches (showing first Y of Z)".
Example usage:
find_code(pattern="class $NAME", max_results=20) # Returns text format
find_code(pattern="class $NAME", output_format="json") # Returns JSON with metadatafind_code_by_ruletool Find code using ast-grep's YAML rule in a project folder.Processes
Find code using ast-grep's YAML rule in a project folder.
YAML rule is more powerful than simple pattern and can perform complex search like find AST inside/having another AST.
It is a more advanced search tool than the simple `find_code`.
Tip: When using relational rules (inside/has), add `stopBy: end` to ensure complete traversal.
Internally calls: ast-grep scan --inline-rules <yaml> [--json] <project_folder>
Output formats:
- text (default): Compact text format with file:line-range headers and complete match text
Example:
Found 2 matches:
src/models.py:45-52
class UserModel:
def __init__(self):
self.id = None
self.name = None
src/views.py:12
class SimpleView: pass
- json: Full match objects with metadata including ranges, meta-variables, etc.
The max_results parameter limits the number of complete matches returned (not individual lines).
When limited, the header shows "Found X matches (showing first Y of Z)".
Example usage:
find_code_by_rule(yaml="id: x\\nlanguage: python\\nrule: {pattern: 'class $NAME'}", max_results=20)
find_code_by_rule(yaml="...", output_format="json") # For full metadatatest_match_code_ruletool Test a code against an ast-grep YAML rule.Processes
Test a code against an ast-grep YAML rule.
This is useful to test a rule before using it in a project.
Internally calls: ast-grep scan --inline-rules <yaml> --json --stdinText the model reads (4)
Every tool, prompt and resource description as written in the code: the model sees all of it, the user usually does not.
dump_syntax_tree tool
Dump code's syntax structure or dump a query's pattern structure.
This is useful to discover correct syntax kind and syntax tree structure. Call it when debugging a rule.
The tool requires three arguments: code, language and format. The first two are self-explanatory.
`format` is the output format of the syntax tree.
use `format=cst` to inspect the code's concrete syntax tree structure, useful to debug target code.
use `format=pattern` to inspect how ast-grep interprets a pattern, useful to debug pattern rule.
Internally calls: ast-grep run --pattern <code> --lang <language> --debug-query=<format>test_match_code_rule tool
Test a code against an ast-grep YAML rule.
This is useful to test a rule before using it in a project.
Internally calls: ast-grep scan --inline-rules <yaml> --json --stdinfind_code tool
Find code in a project folder that matches the given ast-grep pattern.
Pattern is good for simple and single-AST node result.
For more complex usage, please use YAML by `find_code_by_rule`.
Internally calls: ast-grep run --pattern <pattern> [--json] <project_folder>
Output formats:
- text (default): Compact text format with file:line-range headers and complete match text
Example:
Found 2 matches:
path/to/file.py:10-15
def example_function():
# function body
return result
path/to/file.py:20-22
def another_function():
pass
- json: Full match objects with metadata including ranges, meta-variables, etc.
The max_results parameter limits the number of complete matches returned (not individual lines).
When limited, the header shows "Found X matches (showing first Y of Z)".
Example usage:
find_code(pattern="class $NAME", max_results=20) # Returns text format
find_code(pattern="class $NAME", output_format="json") # Returns JSON with metadatafind_code_by_rule tool
Find code using ast-grep's YAML rule in a project folder.
YAML rule is more powerful than simple pattern and can perform complex search like find AST inside/having another AST.
It is a more advanced search tool than the simple `find_code`.
Tip: When using relational rules (inside/has), add `stopBy: end` to ensure complete traversal.
Internally calls: ast-grep scan --inline-rules <yaml> [--json] <project_folder>
Output formats:
- text (default): Compact text format with file:line-range headers and complete match text
Example:
Found 2 matches:
src/models.py:45-52
class UserModel:
def __init__(self):
self.id = None
self.name = None
src/views.py:12
class SimpleView: pass
- json: Full match objects with metadata including ranges, meta-variables, etc.
The max_results parameter limits the number of complete matches returned (not individual lines).
When limited, the header shows "Found X matches (showing first Y of Z)".
Example usage:
find_code_by_rule(yaml="id: x\\\\nlanguage: python\\\\nrule: {pattern: 'class $NAME'}", max_results=20)
find_code_by_rule(yaml="...", output_format="json") # For full metadataWhat we checked
The same checks run on every server. Each line below has one of these marks:
- 8 checks: command injection, argument injection, path traversal, server-side request forgery, SQL injection, code execution, unsafe deserialization, template injectionChecked on every scan. Results in this category are published only after a person has verified them.
- Runs programs the caller choosesNo tool runs a command or program the caller supplies — 4 tool handlers traced
- Executes caller-supplied codeNo tool evaluates code the caller supplies — 4 tool handlers traced
- Reads or writes any file pathNo tool works on a file path the caller supplies without a root check — 4 tool handlers traced
- Requests any addressNo tool sends a request to an address the caller supplies — 4 tool handlers traced
- Runs caller-supplied SQLNo tool executes a query the caller supplies — 4 tool handlers traced
- Tools that start processes4 of 4 capabilities start processes
- Tools that touch files2 of 4 capabilities touch files; 2 more call code the scanner could not follow, where it may happen
- Tools that call the networkNot seen in the traced code of 4 capabilities; 4 more call code the scanner could not follow, where it may happen
Where the code is: 4 handlers in 1 file at commit 51d5a23f025c
- 5 checks: tool poisoning, instruction override, hidden content, exfiltration requests, metadata integrityChecked on every scan. Results in this category are published only after a person has verified them.
- Dependency manifests1 manifest: pyproject.toml
- Lockfiles checked against OSV1 file resolved and checked against the OSV database; 1 not resolved: pyproject.toml: dependency ranges declared here were not resolved against a lockfile and were not checked
- Known vulnerabilities in production dependencies CRITICAL2 production packages with known advisories
- Known vulnerabilities in other dependenciesNo package used only for development, tests or examples has a known advisory
- MCP SDK versionNo MCP SDK declared in a manifest
- 3 checks: credential harvesting, undeclared credential access, credentials sent over the networkChecked on every scan. Results in this category are published only after a person has verified them.
- Tools that read credentialsNot seen in the traced code of 4 capabilities; 4 more call code the scanner could not follow, where it may happen
- Authentication declaredNot checked: needs the live server's tools/list (a remote server declares how clients authenticate)
- 3 checks: undeclared network access, undeclared file access, undeclared process executionChecked on every scan. Results in this category are published only after a person has verified them.
- Tool descriptions presentEvery tool has a description the model and the user can read
- Statically known namesEvery tool's name could be read from the code
- Input schemasNot checked: needs the live server's tools/list (every tool declares an input schema)
- Destructive tools annotatedNot checked: needs the live server's tools/list (tools that write, delete or run commands carry destructivehint)
Dependencies with known vulnerabilities (2 in production)
Dependency ranges were not resolved against a lockfile, so the score is capped at 7.
pyjwtPyPI 2.13.0 CRITICAL 29 advisories 2.14.02.15.0
- CRITICALGHSA-ffc3-869f-jxw9 CVE-2026-102268 PYSEC-2026-4145PyJWT: Asymmetric-PEM detection bypass: whitespace/line-ending-mutated public keys skip the HS/asymmetric confusion guard
- HIGHGHSA-w2cx-738m-mc7w CVE-2026-102273 PYSEC-2026-4151PyJWT accepts public JWK containers as HMAC secrets
- HIGHGHSA-9v7f-9g4p-ffgj CVE-2026-102267 PYSEC-2026-4144PyJWT: PyJWKClient follows redirects when fetching JWKS
- HIGHGHSA-p4g4-x82p-q773 CVE-2026-102271 PYSEC-2026-4149PyJWT: Public keys in DER form are accepted as HMAC secrets, bypassing the CVE-2022-29217 guard
- HIGHGHSA-9j54-fg26-wv3r CVE-2026-102266 PYSEC-2026-4143PyJWT: PyJWK accepts empty HMAC keys, bypassing PyJWT's empty-key validation
- HIGHGHSA-pxh4-856f-4h89PyJWT: HS256/384/512 verify accepts empty HMAC key via oct JWK (PyJWK/PyJWKClient) enabling token forgery
- HIGHGHSA-r6x4-923q-g947 CVE-2026-102272 PYSEC-2026-4150PyJWT BOM Bypass
- MEDIUMPYSEC-2026-4151 CVE-2026-102273 GHSA-w2cx-738m-mc7wPyJWT accepts public JWK containers as HMAC secrets
- MEDIUMGHSA-x33g-cr3x-6449 CVE-2026-102275 PYSEC-2026-4183PyJWT accepts inconsistent OKP x/d JWKs, causing public/private key identity confusion
- MEDIUMGHSA-gvp8-978c-rx2q CVE-2026-103001 PYSEC-2026-4146PyJWT.decode() reintroduces options-dict mutation, enabling silent claim-verification bypass on dict reuse
- MEDIUMPYSEC-2026-4150 CVE-2026-102272 GHSA-r6x4-923q-g947PyJWT BOM Bypass
- MEDIUMGHSA-hxm8-2xgr-2p9m CVE-2026-102269 PYSEC-2026-4147PyJWT: Non-canonical signature segments enable raw-token revocation bypass
- MEDIUMGHSA-42vr-xj54-vc7v CVE-2026-101918 PYSEC-2026-4141PyJWT: Unauthenticated RecursionError DoS in pre-verification payload parse (PyJWKClient.get_signing_key_from_jwt / verify_signature=False)
- MEDIUMGHSA-w6j9-cwv2-h6wq CVE-2026-102274 PYSEC-2026-4152PyJWT: Malformed RSA JWK aborts parsing of an entire JWK Set
- MEDIUMPYSEC-2026-4144 CVE-2026-102267 GHSA-9v7f-9g4p-ffgjPyJWT: PyJWKClient follows redirects when fetching JWKS
- MEDIUMPYSEC-2026-4152 CVE-2026-102274 GHSA-w6j9-cwv2-h6wqPyJWT: Malformed RSA JWK aborts parsing of an entire JWK Set
- MEDIUMPYSEC-2026-4183 CVE-2026-102275 GHSA-x33g-cr3x-6449PyJWT is a Python implementation of JSON Web Token standards. From 2.1.0 until 2.15.0, PyJWT OKPAlgorithm.from_jwk in jwt/algorithms.py is affected because private-JWK import path does not compare the public key derived from d with x. This occurs when an OKP private JWK supplies non-corresponding x and d components. As a result, identity derived from x can differ from operations performed with d. Consequently, if an integration also accepts private key parameters from a proof header without rejecting them, an attacker may use a stolen sender-constrained token without the legitimate private key. This issue is fixed in version 2.15.0.
- MEDIUMGHSA-jwrc-g2q2-pq5p CVE-2026-102270 PYSEC-2026-4148PyJWT: ReDoS vulnerability when calling the `is_pem_format` function.
- MEDIUMPYSEC-2026-4147 CVE-2026-102269 GHSA-hxm8-2xgr-2p9mPyJWT: Non-canonical signature segments enable raw-token revocation bypass
- MEDIUMPYSEC-2026-4143 CVE-2026-102266 GHSA-9j54-fg26-wv3rPyJWT: PyJWK accepts empty HMAC keys, bypassing PyJWT's empty-key validation
- MEDIUMPYSEC-2026-4148 CVE-2026-102270 GHSA-jwrc-g2q2-pq5pPyJWT: ReDoS vulnerability when calling the `is_pem_format` function.
- MEDIUMPYSEC-2026-4146 CVE-2026-103001 GHSA-gvp8-978c-rx2qPyJWT.decode() reintroduces options-dict mutation, enabling silent claim-verification bypass on dict reuse
- MEDIUMPYSEC-2026-4149 CVE-2026-102271 GHSA-p4g4-x82p-q773PyJWT: Public keys in DER form are accepted as HMAC secrets, bypassing the CVE-2022-29217 guard
- MEDIUMGHSA-2gx3-rcp4-g85q CVE-2026-101917 PYSEC-2026-4140PyJWT: PyJWKClient still amplifies unauthenticated JWKS fetches on unknown kid values (incomplete fix of CVE-2026-48524)
- MEDIUMPYSEC-2026-4142 CVE-2026-102265 GHSA-8wjv-2p76-3863PyJWT: Uncaught RecursionError in jwt.decode() on deeply nested token header
- MEDIUMPYSEC-2026-4140 CVE-2026-101917 GHSA-2gx3-rcp4-g85qPyJWT: PyJWKClient still amplifies unauthenticated JWKS fetches on unknown kid values (incomplete fix of CVE-2026-48524)
- MEDIUMPYSEC-2026-4141 CVE-2026-101918 GHSA-42vr-xj54-vc7vPyJWT: Unauthenticated RecursionError DoS in pre-verification payload parse (PyJWKClient.get_signing_key_from_jwt / verify_signature=False)
- MEDIUMPYSEC-2026-4145 CVE-2026-102268 GHSA-ffc3-869f-jxw9PyJWT: Asymmetric-PEM detection bypass: whitespace/line-ending-mutated public keys skip the HS/asymmetric confusion guard
- MEDIUMGHSA-8wjv-2p76-3863 CVE-2026-102265 PYSEC-2026-4142PyJWT: Uncaught RecursionError in jwt.decode() on deeply nested token header
opentelemetry-apiPyPI 1.44.0 MEDIUM 2 advisories 1.45.11.45.2
- MEDIUMGHSA-xcq7-p3pf-p88h CVE-2026-114603OpenTelemetry Python: Unbounded tracestate parsing in opentelemetry-api
- MEDIUMGHSA-mf5v-w3w3-f6cg CVE-2026-126360OpenTelemetry Python API: Denial of service through quadratic-time traceparent parsing
Past security advisories
Vulnerabilities published for this server itself, from the GitHub Advisory Database.
No security advisories have been published for this server in the GitHub Advisory Database.
How it runs
| Where it runs | On your machine, started by your MCP client from this repository or its package |
|---|---|
| Transport | SSE, stdio |
| Sign-in | not checked needs the live server |
| Servers in the code | 1 (ast-grep) |
The project's own security
| Security policy | none no SECURITY.md in the repository: report issues privately through GitHub if it is enabled |
|---|---|
| Past advisories | none in the GitHub Advisory Database |
| Last push | 2026-11-14 |
| Signed releases | not checked yet |
Where it is published
| Listed in | 5 catalogs (awesome_tensorblock, github_search, glama, mcp_toplist, mcpservers_org) |
|---|---|
| License | MIT |
| Created | 2025-03-31 |
Attack map
How the server is built and where its risky tools lead: servers, their tools, what the tools' code can do, and the traced route from a declared risky tool's argument to the operation it reaches. Click a node for details.