Skip to main content
Glama

AST_MCP

Structural code retrieval over MCP. Parses source with tree-sitter and serves symbols instead of files, so an agent asking "what does parse_config do" gets 40 lines rather than 2000.

Read-only. The server never writes to your source — the only file it writes is its own index at .ast_mcp/index.db.

Install

uv tool install ast-mcp

Or run it without installing anything:

uvx ast-mcp --version

Requires Python 3.11 or newer.

Related MCP server: CodeGraphMCPServer

Wire it into Claude Code

From the repository you want indexed:

ast-mcp init

That writes an ast-mcp stanza into <repo>/.mcp.json, adds .ast_mcp/ to .gitignore, and builds the index. Claude Code reads .mcp.json at startup, so the next session in that directory has the tools already connected — no per-session step.

init merges. Every other server in .mcp.json is left exactly as it was, and a file it cannot parse is reported rather than overwritten. Re-running it is a no-op. Pass --dry-run to see the change first.

The stanza it writes carries no absolute paths, so it is safe to commit:

{
  "mcpServers": {
    "ast-mcp": { "command": "ast-mcp", "args": ["serve"] }
  }
}

If ast-mcp is not permanently on PATH it records uvx ast-mcp serve instead. Override either with --command "uv run ast-mcp serve".

CLI

command

what it does

ast-mcp init

register in .mcp.json, ignore the index dir, build the index

ast-mcp index [--rebuild]

build or refresh the index; --rebuild discards it first

ast-mcp status [--json]

file/symbol counts, index size, freshness, registration

ast-mcp languages [--group G]

the language registry — 26 rows, their extensions and profiles

ast-mcp serve

the MCP server over stdio; what Claude Code launches

Every command takes --root PATH. Root resolution is --root, else AST_MCP_ROOT, else the working directory. Bare ast-mcp means ast-mcp serve.

Only init writes anything outside .ast_mcp/, and only .mcp.json and .gitignore. The server itself never writes to your source.

Not every language gets the same treatment

A .py file has functions with signatures and docstrings. A docker-compose.yml has none of that — it has a shape. A README.md has a heading tree. Forcing all three through one symbol model produces garbage for two of them, so there are four extraction profiles:

profile

payload key

what you get

languages

symbols

symbols

signature, docstring, nesting, imports

python, javascript, typescript, tsx, go, lua

defs

symbols

same shape, weaker guarantees — docstrings often null

ruby, perl, r, bash, zsh, css, scss, sql, graphql, proto, terraform, dockerfile

schema

schema

key paths + inferred value types, not funcdefs

json, json5, yaml, toml, xml, csv

outline

outline

heading / section tree

markdown, html

26 languages across six groups: core, web, scripting, data, devops, docs. Every response declares its profile and group before the payload — read that field, don't assume symbols exists.

Kinds never lie about fidelity. A schema node's kind is a value type (object, array, string); an outline node's kind is a document structure (heading, code_block). Nothing outside the symbols/defs profiles ever claims to be a function or a class.

Tools

tool

use it for

file_outline(path, max_depth, include_docstrings)

the Read replacement — a file's shape, bodies elided

get_symbol(name, path, mode)

one definition. name is a symbol name, a key path (services.web.ports), or a heading slug

search_symbols(query, kind, lang, group, path_glob, limit)

find things by name across the repo

get_docstrings(path | symbols)

docs without bodies

list_imports(path)

dependency edges out of a file, plus exports where the language has them

ast_query(path, query, captures)

raw tree-sitter S-expression — the escape hatch

Every tool takes max_tokens (default 4000). An over-budget response is trimmed, flagged truncated: true, and tells you which argument narrows it. Nothing is dropped silently.

get_symbol never guesses. A name matching several symbols returns ambiguous: true with candidates; pass path or a qualified name to resolve.

When to use this vs CCE context_search

They answer different questions and both stay.

  • context_search (CCE) — fuzzy semantic retrieval over embedded chunks. Use for "how does auth work?", "where is rate limiting handled?", and anything where you know the concept but not the name.

  • AST_MCP — exact structural retrieval by name, kind and range. Use for "show me TokenStore.refresh", "what's in this config file?", "list every CREATE TABLE in the repo", and anything where you know the name but not the location.

Rough rule: describing behaviour → context_search. Naming a thing → AST_MCP.

What it costs

The saving grows with file size — the response envelope is fixed cost, so small files benefit least. Measured on this codebase:

file

lines

full read

outline

saving

ast_mcp/render.py

94

789 tok

352 tok

2.2x

ast_mcp/index.py

428

3994 tok

967 tok

4.1x

ast_mcp/tools.py

457

3882 tok

690 tok

5.6x

Below roughly 100 lines it is about break-even against Read. Above that it pays, and get_symbol on a single definition pays regardless.

A 5000-row CSV or JSON array costs the same as a 3-row one: homogeneous repeats collapse to one node carrying children_count.

Freshness

The SQLite index is a cache, never an oracle. Every path in a response was stat-checked against its recorded (mtime_ns, size) during that same call, and reparsed if it moved. There is no watcher daemon and no stale window.

Development

git clone https://github.com/matthew-brough/AST_MCP && cd AST_MCP
uv sync --all-groups
uv run --group dev pytest -q

The suite runs on 3.11 through 3.14. uv build produces the wheel; the .scm query files ship inside it, and CI fails the build if any are missing.

SPEC.md is the contract: §V invariants, §I interfaces, §T tasks, §B the log of what went wrong and what changed because of it.

Available Tools

6 tools
ast_queryA

Run a raw tree-sitter S-expression query against one file.

The escape hatch for anything the five typed tools flatten away.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes
queryYes
capturesNo
max_tokensNo

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full behavioral disclosure burden. It only says what the tool does, not whether it is read-only, what the output looks like, whether the file can be modified, or any error/edge-case behavior. The word 'query' hints at a read operation, but this is not explicit.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with no fluff. The primary action is front-loaded, and the second sentence adds valuable positioning as an escape hatch. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, no annotations, and 0% schema description coverage, the description is insufficient for a 4-parameter tool. It does not mention return format, capture behavior, token limits, or how this low-level query relates to the typed tools beyond being a fallback. Agents would likely need extra probing to use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It indirectly explains 'path' ('against one file') and 'query' ('raw tree-sitter S-expression query'), but gives no guidance on 'captures' or 'max_tokens' semantics, defaults, or usage. With 4 parameters and no schema descriptions, this leaves significant ambiguity.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific action: 'Run a raw tree-sitter S-expression query against one file.' This clearly identifies the verb, resource, and scope. It also differentiates itself from siblings by calling itself 'the escape hatch for anything the five typed tools flatten away,' signaling it is the lower-level fallback.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides clear context by positioning the tool as an escape hatch, implying it should be used when the five typed tools (search_symbols, get_docstrings, file_outline, get_symbol, list_imports) cannot express the desired query. It does not name specific sibling alternatives or give explicit when-not-to-use conditions, but the context is actionable.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

file_outlineA

Outline one file: definitions, key paths or headings, bodies elided.

Use this instead of reading a file to find out what is in it.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes
max_depthNo
max_tokensNo
include_docstringsNo

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the behavioral disclosure burden. It does disclose a key behavioral trait: bodies are elided, so the output is a structural outline rather than full content. It does not mention output limits, token truncation, or depth semantics, but for a read-only outline tool the disclosed behavior is the most important part.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two short sentences front-load the core purpose and immediately add usage context. There is no redundant or filler content; every sentence contributes to effective tool invocation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is sufficient for a basic call (path) and tells the agent why to use it, but it omits parameter semantics and does not define the output format beyond 'definitions, key paths or headings, bodies elided.' With no output schema or annotations, the description leaves moderate gaps in what an agent can expect and how to tune the call.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% and the description says nothing about max_depth, max_tokens, or include_docstrings. The parameter names and defaults are somewhat self-explanatory, but the description does not compensate for the schema's lack of textual explanation, leaving the agent to infer how these parameters affect the outline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb-resource pair ('Outline one file') and specifies what the result contains: definitions, key paths or headings, with bodies elided. It does not explicitly differentiate itself from sibling tools like search_symbols or get_symbol, but the whole-file-overview scope makes its purpose clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives a clear when-to-use directive: use this tool instead of reading a file to find out what is in it. It does not, however, name sibling alternatives or state when to choose them, so the guidance is clear but not exhaustive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_docstringsB

Documentation without bodies. Pass exactly one of path or symbols.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathNo
symbolsNo
max_tokensNo

TDQS

B3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral disclosure burden. It does reveal the key output trait ('without bodies') and a strict input requirement, but it does not explain what happens if both path and symbols are provided, how max_tokens affects results, or what the return structure looks like.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is short, front-loaded, and free of filler, which is good. However, the brevity crosses into under-specification: two sentence fragments cannot adequately cover three parameters, the mutual-exclusion rule, and tool-selection context.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given three parameters, no annotations, and no output schema, the description is incomplete. It does not explain accepted path or symbol formats, mention max_tokens at all, or describe the output beyond 'documentation,' so an agent must infer too much to invoke the tool confidently.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for missing parameter meaning. It adds the useful 'exactly one of path or symbols' constraint, but it never defines what path should point to, what symbols should contain, or what max_tokens controls. This leaves significant semantic ambiguity for three parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The phrase 'Documentation without bodies' combined with the tool name get_docstrings identifies a specific resource (docstrings) and a distinctive scope (no function bodies), which helps distinguish it from sibling tools like get_symbol or file_outline. It stops short of an explicit imperative statement such as 'Returns docstrings for a path or symbols,' so clarity is good but not maximal.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The instruction 'Pass exactly one of path or symbols' is a clear invocation rule and implies the tool is for retrieving documentation rather than symbol bodies. However, the description never names alternative tools or states explicit when-to-use versus when-not-to-use conditions, leaving sibling differentiation mostly implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_symbolB

Fetch definitions by name, key path, or heading slug.

mode: "source" (default) returns the body, "signature" and "doc" omit it. A name matching several different symbols returns candidates rather than guessing. A name matching several definitions of the same thing — many Lua listeners on one event — returns all of them in "symbols". line: pick one definition by the start_line a candidate reported.

ParametersJSON Schema
NameRequiredDescriptionDefault
lineNo
modeNosource
nameYes
pathNo
max_tokensNo

TDQS

B3.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the behavioral burden and does substantial work: it explains mode behavior ('source' returns the body, 'signature' and 'doc' omit it), ambiguity resolution (returns candidates rather than guessing), and line-based disambiguation by start_line. It does not cover errors, permissions, or max_tokens effects, but the core selection behavior is transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded with the main purpose. The mode and line notes are dense but scannable. It avoids filler, though the ambiguity discussion could be tightened slightly without losing value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a moderate-complexity tool with five parameters and no output schema, the description covers the primary ambiguity-handling behavior and mode semantics. It does not explain max_tokens, the exact meaning of path, or how the returned candidates/symbols are structured. It is adequate for basic use but incomplete for full confident invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must add parameter meaning. It explains mode values and the line parameter, and mentions lookup by name, key path, or heading slug. However, it does not map 'key path' and 'heading slug' to specific parameters, and it leaves max_tokens entirely undocumented. Partial compensation, but with real gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The first sentence states a clear action and resource: 'Fetch definitions by name, key path, or heading slug.' It conveys the tool's core function and gives some sense of the lookup keys. It does not explicitly contrast with sibling tools like search_symbols, but the specificity of fetching definitions rather than searching or outlining is enough to distinguish it.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance is given about when to prefer get_symbol over siblings such as search_symbols, get_docstrings, or ast_query. The mode and line details are usage-related, but they explain how to call the tool, not when it should be selected. The description leaves alternatives and exclusions to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_importsC

Dependency edges out of one file, plus exports where the language has them.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes
max_tokensNo

TDQS

C2.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must carry the transparency burden. It does reveal that the result is scoped to a single file and that exports are included only when the language supports them. It does not state whether the operation is read-only, what the result shape is, or how max_tokens affects output.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is one short sentence with no filler, and the core scope is front-loaded. The language-conditioned export clause is efficient, though slightly cryptic.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, this definition is too thin. An agent is not told what the result looks like, how language detection works, or how max_tokens influences the output, leaving the tool minimally viable at best.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for missing parameter details. It clarifies that 'path' refers to a single file, but it does not describe 'max_tokens,' its truncation behavior, or the expected path format.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description identifies the resource ('dependency edges out of one file') and adds an export edge case, which differentiates it from sibling tools like search_symbols or ast_query. It lacks an explicit verb such as 'lists' or 'returns,' but the tool name and phrasing make the action reasonably clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is given for when to use this tool rather than file_outline, ast_query, or search_symbols. There are no conditions, exclusions, or alternative tool mentions, so an agent must infer the correct usage from the name and the bare description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_symbolsC

Find definitions, key paths and headings by name across the repository.

group is one of core, web, scripting, data, devops, docs.

ParametersJSON Schema
NameRequiredDescriptionDefault
kindNo
langNo
groupNo
limitNo
queryYes
path_globNo
max_tokensNo

TDQS

C2.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It does not mention whether the operation is read-only, how results are returned, matching semantics, pagination, or any other runtime behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is brief and front-loaded with the primary purpose. The second sentence about group adds a useful constraint without padding, so each sentence earns its place. It is concise, though sparse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With 7 parameters, no annotations, and no output schema, this description is not complete enough for an agent to confidently invoke the tool. It lacks information about required query semantics, available filter values for kind and lang, result shape, and how the various filters interact.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, yet the description only explains one parameter: group. It provides no semantics for query, kind, lang, limit, path_glob, or max_tokens, leaving most of the parameter surface undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states a specific action and resource: 'Find definitions, key paths and headings by name across the repository.' This identifies what the tool does and its scope. However, it does not explicitly differentiate from siblings like get_symbol or file_outline, which may overlap in function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives no guidance about when to use search_symbols versus alternatives such as get_symbol, file_outline, or ast_query. The only usage-related hint is the group value enumeration, which is parameter guidance rather than tool-selection guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 6 tool updatesv0.1.0
    • First observedast_query
    • First observedfile_outline
    • First observedget_docstrings
    • First observedget_symbol
    • First observedlist_imports
    • First observedsearch_symbols

TDQS

B3.2/5.0
Disambiguation2/5

search_symbols and get_symbol both describe fetching definitions by name, making their boundary unclear. get_docstrings also overlaps with get_symbol's 'doc' mode, so several tools can be confused despite detailed descriptions.

Naming Consistency4/5

Most tools follow a verb_noun snake_case pattern: search_symbols, get_docstrings, get_symbol, list_imports, file_outline. ast_query breaks the pattern since it reads as noun_noun rather than query_ast.

Tool Count5/5

Six tools is well-scoped for a read-only AST/code-analysis server. Each tool serves a distinct analysis need, and the set does not feel padded or thin.

Completeness4/5

The server covers symbol search, symbol retrieval, docstrings, file outlining, imports, and a raw tree-sitter escape hatch. Minor gaps exist, such as no repo-wide import graph or raw file content access, but agents can usually work around them.

Maintenance

ActivityNo data
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    Standalone MCP server for code structure analysis using tree-sitter. Directory trees, symbol definitions, and call graphs without reading raw source files. Supports Rust, Python, Go, Java, TypeScript, Fortran, JavaScript, C/C++, and C#. Benchmarked up to 68% fewer tokens vs native tools.
    5
    Apache 2.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    A lightweight, zero-configuration MCP server for source code analysis with GraphRAG capabilities, enabling structural understanding and efficient code completion from MCP-compatible AI tools.
    12
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables LLM agents to query a codebase's structural knowledge (symbols, imports, call graphs, etc.) via MCP, reducing tokens and improving correctness compared to raw file access.
    18
    7
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that indexes your codebase using tree-sitter AST parsing and gives AI tools instant access to structural intelligence like dependency graphs, call trees, and dead code detection from a local SQLite database.
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/matthew-brough/AST_MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server