mcp-ast-explorer 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_ast_explorer-0.1.0/.github/workflows/ci.yml +21 -0
- mcp_ast_explorer-0.1.0/.gitignore +12 -0
- mcp_ast_explorer-0.1.0/.vscode/settings.json +6 -0
- mcp_ast_explorer-0.1.0/LICENSE +21 -0
- mcp_ast_explorer-0.1.0/PKG-INFO +93 -0
- mcp_ast_explorer-0.1.0/README.md +77 -0
- mcp_ast_explorer-0.1.0/pyproject.toml +45 -0
- mcp_ast_explorer-0.1.0/pyrightconfig.json +16 -0
- mcp_ast_explorer-0.1.0/server.json +21 -0
- mcp_ast_explorer-0.1.0/src/mcp_ast_explorer/__init__.py +1 -0
- mcp_ast_explorer-0.1.0/src/mcp_ast_explorer/backends.py +72 -0
- mcp_ast_explorer-0.1.0/src/mcp_ast_explorer/indexer.py +320 -0
- mcp_ast_explorer-0.1.0/src/mcp_ast_explorer/models.py +86 -0
- mcp_ast_explorer-0.1.0/src/mcp_ast_explorer/schemas.py +97 -0
- mcp_ast_explorer-0.1.0/src/mcp_ast_explorer/server.py +237 -0
- mcp_ast_explorer-0.1.0/tests/test_backends.py +32 -0
- mcp_ast_explorer-0.1.0/tests/test_indexer.py +286 -0
- mcp_ast_explorer-0.1.0/tests/test_server.py +346 -0
- mcp_ast_explorer-0.1.0/uv.lock +1760 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ["main"]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: actions/setup-python@v5
|
|
15
|
+
with:
|
|
16
|
+
python-version: "3.11"
|
|
17
|
+
- uses: astral-sh/setup-uv@v5
|
|
18
|
+
- run: uv sync --extra dev
|
|
19
|
+
- run: uv run ruff check .
|
|
20
|
+
- run: uv run mypy
|
|
21
|
+
- run: uv run pytest
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Haichuan Zhou
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcp-ast-explorer
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server for Python AST/CST symbol exploration.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Requires-Dist: fastmcp>=2.0
|
|
9
|
+
Requires-Dist: libcst>=1.0
|
|
10
|
+
Requires-Dist: pydantic>=2.0
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
13
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
14
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# mcp-ast-explorer
|
|
18
|
+
|
|
19
|
+
<!-- mcp-name: io.github.LovRanRan/mcp-ast-explorer -->
|
|
20
|
+
|
|
21
|
+
MCP server for deterministic Python codebase symbol exploration.
|
|
22
|
+
|
|
23
|
+
`mcp-ast-explorer` indexes Python source files with LibCST and exposes focused MCP tools for codebase onboarding: definition lookup, function signatures, local references, direct call chains, and simple class hierarchy queries.
|
|
24
|
+
|
|
25
|
+
## Codebase Onboarding Stack
|
|
26
|
+
|
|
27
|
+
`mcp-ast-explorer` is the semantic symbol layer in a three-server MCP tool stack for Project 6 `wayfinder`, a codebase onboarding agent.
|
|
28
|
+
|
|
29
|
+
- [`mcp-repo-mapper`](https://github.com/LovRanRan/mcp-repo-mapper) maps repository structure, languages, entry points, framework evidence, and Python dependency edges.
|
|
30
|
+
- [`mcp-ast-explorer`](https://github.com/LovRanRan/mcp-ast-explorer) provides symbol-grounded Python definition, signature, reference, call-chain, and class-hierarchy lookups.
|
|
31
|
+
- [`mcp-test-runner`](https://github.com/LovRanRan/mcp-test-runner) runs local pytest/Jest checks and coverage summaries so agent claims can be verified against execution.
|
|
32
|
+
|
|
33
|
+
In `wayfinder`, this server feeds entry-point and symbol explanation while refusing to invent missing symbols.
|
|
34
|
+
|
|
35
|
+
## Status
|
|
36
|
+
|
|
37
|
+
This is a Python-only v1. TypeScript is registered as an unsupported backend placeholder so the server has an explicit extension point, but TypeScript analysis is not implemented yet.
|
|
38
|
+
|
|
39
|
+
The server does not use an LLM for symbol lookup. If a requested symbol or class is not present in the parsed index, tools return a structured not-found result instead of inventing an answer.
|
|
40
|
+
|
|
41
|
+
## Tools
|
|
42
|
+
|
|
43
|
+
| Tool | Purpose |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| `health()` | Returns `ok` for smoke checks. |
|
|
46
|
+
| `find_definition(path, symbol, language="python")` | Finds a module, class, function, or method definition. |
|
|
47
|
+
| `function_signature(path, symbol, language="python")` | Returns the signature for a function or method symbol. |
|
|
48
|
+
| `find_references(path, symbol, language="python")` | Returns same-module CST name references for an existing symbol. |
|
|
49
|
+
| `call_chain(path, from_symbol, depth=2, language="python")` | Returns direct callers detected from local references. |
|
|
50
|
+
| `class_hierarchy(path, class_name, language="python")` | Returns direct subclasses detected from simple base-class names. |
|
|
51
|
+
|
|
52
|
+
## Supported Scope
|
|
53
|
+
|
|
54
|
+
- Python files parsed by LibCST.
|
|
55
|
+
- Symbol kinds: modules, classes, functions, and methods.
|
|
56
|
+
- Same-module reference lookup for simple names.
|
|
57
|
+
- Direct caller detection from function or method containers.
|
|
58
|
+
- Direct subclass detection for simple `class Child(Base):` inheritance.
|
|
59
|
+
- Structured error responses for unsupported languages and missing symbols.
|
|
60
|
+
|
|
61
|
+
## Current Limitations
|
|
62
|
+
|
|
63
|
+
- Cross-file imports and package-wide resolution are out of scope for v1.
|
|
64
|
+
- Aliases, star imports, dynamic attribute access, and qualified references are not resolved.
|
|
65
|
+
- `call_chain` currently returns direct callers only; recursive multi-hop expansion is not implemented.
|
|
66
|
+
- `class_hierarchy` currently returns direct subclasses only and handles simple base names.
|
|
67
|
+
- TypeScript is intentionally unsupported in v1.
|
|
68
|
+
|
|
69
|
+
## Local Development
|
|
70
|
+
|
|
71
|
+
Install dependencies:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
uv sync --extra dev
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Run the MCP server:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
uv run mcp-ast-explorer
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Run verification:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
uv run ruff check .
|
|
87
|
+
uv run mypy
|
|
88
|
+
uv run pytest
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
MIT
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# mcp-ast-explorer
|
|
2
|
+
|
|
3
|
+
<!-- mcp-name: io.github.LovRanRan/mcp-ast-explorer -->
|
|
4
|
+
|
|
5
|
+
MCP server for deterministic Python codebase symbol exploration.
|
|
6
|
+
|
|
7
|
+
`mcp-ast-explorer` indexes Python source files with LibCST and exposes focused MCP tools for codebase onboarding: definition lookup, function signatures, local references, direct call chains, and simple class hierarchy queries.
|
|
8
|
+
|
|
9
|
+
## Codebase Onboarding Stack
|
|
10
|
+
|
|
11
|
+
`mcp-ast-explorer` is the semantic symbol layer in a three-server MCP tool stack for Project 6 `wayfinder`, a codebase onboarding agent.
|
|
12
|
+
|
|
13
|
+
- [`mcp-repo-mapper`](https://github.com/LovRanRan/mcp-repo-mapper) maps repository structure, languages, entry points, framework evidence, and Python dependency edges.
|
|
14
|
+
- [`mcp-ast-explorer`](https://github.com/LovRanRan/mcp-ast-explorer) provides symbol-grounded Python definition, signature, reference, call-chain, and class-hierarchy lookups.
|
|
15
|
+
- [`mcp-test-runner`](https://github.com/LovRanRan/mcp-test-runner) runs local pytest/Jest checks and coverage summaries so agent claims can be verified against execution.
|
|
16
|
+
|
|
17
|
+
In `wayfinder`, this server feeds entry-point and symbol explanation while refusing to invent missing symbols.
|
|
18
|
+
|
|
19
|
+
## Status
|
|
20
|
+
|
|
21
|
+
This is a Python-only v1. TypeScript is registered as an unsupported backend placeholder so the server has an explicit extension point, but TypeScript analysis is not implemented yet.
|
|
22
|
+
|
|
23
|
+
The server does not use an LLM for symbol lookup. If a requested symbol or class is not present in the parsed index, tools return a structured not-found result instead of inventing an answer.
|
|
24
|
+
|
|
25
|
+
## Tools
|
|
26
|
+
|
|
27
|
+
| Tool | Purpose |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| `health()` | Returns `ok` for smoke checks. |
|
|
30
|
+
| `find_definition(path, symbol, language="python")` | Finds a module, class, function, or method definition. |
|
|
31
|
+
| `function_signature(path, symbol, language="python")` | Returns the signature for a function or method symbol. |
|
|
32
|
+
| `find_references(path, symbol, language="python")` | Returns same-module CST name references for an existing symbol. |
|
|
33
|
+
| `call_chain(path, from_symbol, depth=2, language="python")` | Returns direct callers detected from local references. |
|
|
34
|
+
| `class_hierarchy(path, class_name, language="python")` | Returns direct subclasses detected from simple base-class names. |
|
|
35
|
+
|
|
36
|
+
## Supported Scope
|
|
37
|
+
|
|
38
|
+
- Python files parsed by LibCST.
|
|
39
|
+
- Symbol kinds: modules, classes, functions, and methods.
|
|
40
|
+
- Same-module reference lookup for simple names.
|
|
41
|
+
- Direct caller detection from function or method containers.
|
|
42
|
+
- Direct subclass detection for simple `class Child(Base):` inheritance.
|
|
43
|
+
- Structured error responses for unsupported languages and missing symbols.
|
|
44
|
+
|
|
45
|
+
## Current Limitations
|
|
46
|
+
|
|
47
|
+
- Cross-file imports and package-wide resolution are out of scope for v1.
|
|
48
|
+
- Aliases, star imports, dynamic attribute access, and qualified references are not resolved.
|
|
49
|
+
- `call_chain` currently returns direct callers only; recursive multi-hop expansion is not implemented.
|
|
50
|
+
- `class_hierarchy` currently returns direct subclasses only and handles simple base names.
|
|
51
|
+
- TypeScript is intentionally unsupported in v1.
|
|
52
|
+
|
|
53
|
+
## Local Development
|
|
54
|
+
|
|
55
|
+
Install dependencies:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
uv sync --extra dev
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Run the MCP server:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
uv run mcp-ast-explorer
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Run verification:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
uv run ruff check .
|
|
71
|
+
uv run mypy
|
|
72
|
+
uv run pytest
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[tool.hatch.build.targets.wheel]
|
|
6
|
+
packages = ["src/mcp_ast_explorer"]
|
|
7
|
+
|
|
8
|
+
[project]
|
|
9
|
+
name = "mcp-ast-explorer"
|
|
10
|
+
version = "0.1.0"
|
|
11
|
+
description = "MCP server for Python AST/CST symbol exploration."
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
license = "MIT"
|
|
14
|
+
requires-python = ">=3.11"
|
|
15
|
+
dependencies = [
|
|
16
|
+
"fastmcp>=2.0",
|
|
17
|
+
"libcst>=1.0",
|
|
18
|
+
"pydantic>=2.0",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
dev = [
|
|
23
|
+
"mypy>=1.10",
|
|
24
|
+
"pytest>=8.0",
|
|
25
|
+
"ruff>=0.5",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.scripts]
|
|
29
|
+
mcp-ast-explorer = "mcp_ast_explorer.server:main"
|
|
30
|
+
|
|
31
|
+
[tool.ruff]
|
|
32
|
+
line-length = 100
|
|
33
|
+
|
|
34
|
+
[tool.ruff.lint]
|
|
35
|
+
select = ["E", "F", "I", "UP", "B", "SIM"]
|
|
36
|
+
|
|
37
|
+
[tool.mypy]
|
|
38
|
+
python_version = "3.11"
|
|
39
|
+
strict = true
|
|
40
|
+
mypy_path = "src"
|
|
41
|
+
packages = ["mcp_ast_explorer"]
|
|
42
|
+
|
|
43
|
+
[tool.pytest.ini_options]
|
|
44
|
+
testpaths = ["tests"]
|
|
45
|
+
pythonpath = ["src"]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.LovRanRan/mcp-ast-explorer",
|
|
4
|
+
"title": "MCP AST Explorer",
|
|
5
|
+
"description": "Python symbol exploration for codebase onboarding agents.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"url": "https://github.com/LovRanRan/mcp-ast-explorer",
|
|
8
|
+
"source": "github"
|
|
9
|
+
},
|
|
10
|
+
"version": "0.1.0",
|
|
11
|
+
"packages": [
|
|
12
|
+
{
|
|
13
|
+
"registryType": "pypi",
|
|
14
|
+
"identifier": "mcp-ast-explorer",
|
|
15
|
+
"version": "0.1.0",
|
|
16
|
+
"transport": {
|
|
17
|
+
"type": "stdio"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Python AST/CST exploration MCP server."""
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from typing import Protocol
|
|
2
|
+
|
|
3
|
+
PYTHON_ONLY_ERROR = "Only Python is supported in v1."
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class LanguageBackend(Protocol):
|
|
7
|
+
@property
|
|
8
|
+
def language(self) -> str: ...
|
|
9
|
+
|
|
10
|
+
@property
|
|
11
|
+
def display_name(self) -> str: ...
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def is_supported(self) -> bool: ...
|
|
15
|
+
|
|
16
|
+
def unsupported_error(self) -> str | None: ...
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class PythonLanguageBackend:
|
|
20
|
+
@property
|
|
21
|
+
def language(self) -> str:
|
|
22
|
+
return "python"
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def display_name(self) -> str:
|
|
26
|
+
return "Python"
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def is_supported(self) -> bool:
|
|
30
|
+
return True
|
|
31
|
+
|
|
32
|
+
def unsupported_error(self) -> str | None:
|
|
33
|
+
return None
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class TypeScriptLanguageBackend:
|
|
37
|
+
@property
|
|
38
|
+
def language(self) -> str:
|
|
39
|
+
return "typescript"
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def display_name(self) -> str:
|
|
43
|
+
return "TypeScript"
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def is_supported(self) -> bool:
|
|
47
|
+
return False
|
|
48
|
+
|
|
49
|
+
def unsupported_error(self) -> str | None:
|
|
50
|
+
return PYTHON_ONLY_ERROR
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
_BACKENDS: dict[str, LanguageBackend] = {
|
|
54
|
+
"python": PythonLanguageBackend(),
|
|
55
|
+
"typescript": TypeScriptLanguageBackend(),
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def get_language_backend(language: str) -> LanguageBackend | None:
|
|
60
|
+
return _BACKENDS.get(language.lower())
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def is_supported_language(language: str) -> bool:
|
|
64
|
+
backend = get_language_backend(language)
|
|
65
|
+
return backend is not None and backend.is_supported
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def unsupported_language_error(language: str) -> str:
|
|
69
|
+
backend = get_language_backend(language)
|
|
70
|
+
if backend is None:
|
|
71
|
+
return PYTHON_ONLY_ERROR
|
|
72
|
+
return backend.unsupported_error() or PYTHON_ONLY_ERROR
|