codemunch-pro 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.
- codemunch_pro-0.1.0/.gitignore +11 -0
- codemunch_pro-0.1.0/LICENSE +21 -0
- codemunch_pro-0.1.0/PKG-INFO +142 -0
- codemunch_pro-0.1.0/README.md +112 -0
- codemunch_pro-0.1.0/pyproject.toml +59 -0
- codemunch_pro-0.1.0/server.json +148 -0
- codemunch_pro-0.1.0/src/codemunch_pro/__init__.py +7 -0
- codemunch_pro-0.1.0/src/codemunch_pro/__main__.py +45 -0
- codemunch_pro-0.1.0/src/codemunch_pro/embedder/__init__.py +5 -0
- codemunch_pro-0.1.0/src/codemunch_pro/embedder/embed.py +71 -0
- codemunch_pro-0.1.0/src/codemunch_pro/parser/__init__.py +13 -0
- codemunch_pro-0.1.0/src/codemunch_pro/parser/call_graph.py +29 -0
- codemunch_pro-0.1.0/src/codemunch_pro/parser/extractor.py +351 -0
- codemunch_pro-0.1.0/src/codemunch_pro/parser/languages.py +206 -0
- codemunch_pro-0.1.0/src/codemunch_pro/parser/symbols.py +35 -0
- codemunch_pro-0.1.0/src/codemunch_pro/security.py +126 -0
- codemunch_pro-0.1.0/src/codemunch_pro/server.py +701 -0
- codemunch_pro-0.1.0/src/codemunch_pro/storage/__init__.py +5 -0
- codemunch_pro-0.1.0/src/codemunch_pro/storage/database.py +592 -0
- codemunch_pro-0.1.0/tests/__init__.py +0 -0
- codemunch_pro-0.1.0/tests/test_parser.py +306 -0
- codemunch_pro-0.1.0/tests/test_server.py +269 -0
- codemunch_pro-0.1.0/tests/test_storage.py +312 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jai Dunlop
|
|
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,142 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codemunch-pro
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Intelligent code indexing MCP server. Tree-sitter AST extraction, hybrid search (FTS5 + vector), call graphs, 10 languages, incremental indexing.
|
|
5
|
+
Project-URL: Homepage, https://github.com/BigJai/codemunch-pro
|
|
6
|
+
Project-URL: Repository, https://github.com/BigJai/codemunch-pro
|
|
7
|
+
Project-URL: Issues, https://github.com/BigJai/codemunch-pro/issues
|
|
8
|
+
Author-email: Jai Dunlop <jaidunlop85@gmail.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ast,call-graph,code-indexing,code-search,developer-tools,mcp,mcp-server,tree-sitter
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: fastembed>=0.6.0
|
|
24
|
+
Requires-Dist: httpx>=0.27.0
|
|
25
|
+
Requires-Dist: mcp[cli]>=1.6.0
|
|
26
|
+
Requires-Dist: pathspec>=0.12.0
|
|
27
|
+
Requires-Dist: sqlite-vec>=0.1.0
|
|
28
|
+
Requires-Dist: tree-sitter-language-pack>=0.7.0
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# CodeMunch Pro
|
|
32
|
+
|
|
33
|
+
Intelligent code indexing MCP server. Tree-sitter AST extraction, hybrid search (FTS5 + vector), call graphs, 10 languages, incremental indexing.
|
|
34
|
+
|
|
35
|
+
**Save 99% of tokens** — get exact function source via byte-offset seek instead of reading entire files.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install codemunch-pro
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Quick Start
|
|
44
|
+
|
|
45
|
+
### Claude Desktop / Cline
|
|
46
|
+
|
|
47
|
+
Add to your MCP client config:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"mcpServers": {
|
|
52
|
+
"codemunch-pro": {
|
|
53
|
+
"command": "codemunch-pro"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### HTTP Server
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
codemunch-pro --transport streamable-http --port 5002
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 13 MCP Tools
|
|
66
|
+
|
|
67
|
+
| Tool | Description |
|
|
68
|
+
|------|-------------|
|
|
69
|
+
| `index_folder` | Index a local directory (incremental, SHA-256 based) |
|
|
70
|
+
| `index_repo` | Index a GitHub/GitLab repo (v1.1) |
|
|
71
|
+
| `list_repos` | List all indexed repositories with stats |
|
|
72
|
+
| `invalidate_cache` | Force re-index a repository |
|
|
73
|
+
| `file_tree` | Get directory tree with file counts |
|
|
74
|
+
| `file_outline` | List symbols in a single file |
|
|
75
|
+
| `repo_outline` | List all symbols in repo (summary) |
|
|
76
|
+
| `get_symbol` | Get full source of one symbol (O(1) byte seek) |
|
|
77
|
+
| `get_symbols` | Batch get multiple symbols |
|
|
78
|
+
| `search_symbols` | Hybrid search (FTS5 + vector RRF) |
|
|
79
|
+
| `search_text` | Full-text search in file contents |
|
|
80
|
+
| `get_callees` | What does this function call? |
|
|
81
|
+
| `get_callers` | Who calls this function? |
|
|
82
|
+
|
|
83
|
+
## 10 Languages
|
|
84
|
+
|
|
85
|
+
Python, JavaScript, TypeScript, Go, Rust, Java, C, C++, C#, Ruby
|
|
86
|
+
|
|
87
|
+
All via [tree-sitter-language-pack](https://pypi.org/project/tree-sitter-language-pack/) — zero compilation, pre-built binaries.
|
|
88
|
+
|
|
89
|
+
## Key Features
|
|
90
|
+
|
|
91
|
+
### O(1) Symbol Retrieval
|
|
92
|
+
Every symbol stores its byte offset and length. `get_symbol` seeks directly to the function source — no reading entire files. A 200-byte function from a 40KB file = **99.5% token savings**.
|
|
93
|
+
|
|
94
|
+
### Incremental Indexing
|
|
95
|
+
Files are hashed (SHA-256). Only changed files are re-parsed. Re-indexing a 10K file repo after changing one file takes milliseconds.
|
|
96
|
+
|
|
97
|
+
### Hybrid Search (FTS5 + Vector)
|
|
98
|
+
Combines BM25 keyword matching with semantic vector similarity using Reciprocal Rank Fusion. Search "authentication middleware" and find `auth_middleware`, `verify_token`, and `login_handler`.
|
|
99
|
+
|
|
100
|
+
### Call Graphs
|
|
101
|
+
Traces function calls through the AST. `get_callees("main")` shows what `main` calls. `get_callers("authenticate")` shows who calls `authenticate`. Supports depth traversal.
|
|
102
|
+
|
|
103
|
+
### Full-Text Content Search
|
|
104
|
+
Search raw file contents — string literals, TODO comments, config values, error messages. Not just symbol names.
|
|
105
|
+
|
|
106
|
+
## How It Works
|
|
107
|
+
|
|
108
|
+
1. **Parse** — tree-sitter builds an AST for each source file
|
|
109
|
+
2. **Extract** — Walk AST to find functions, classes, methods, types, interfaces
|
|
110
|
+
3. **Store** — SQLite database per repo with FTS5 virtual tables
|
|
111
|
+
4. **Embed** — FastEmbed (ONNX, CPU-only) generates 384-dim vectors for semantic search
|
|
112
|
+
5. **Graph** — Call expressions extracted from function bodies, edges stored and resolved
|
|
113
|
+
6. **Serve** — FastMCP exposes 13 tools via stdio or HTTP
|
|
114
|
+
|
|
115
|
+
## Architecture
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
~/.codemunch-pro/
|
|
119
|
+
├── myproject_a1b2c3d4e5f6.db # Per-repo SQLite database
|
|
120
|
+
├── otherproject_7890abcdef.db
|
|
121
|
+
└── ...
|
|
122
|
+
|
|
123
|
+
Each DB contains:
|
|
124
|
+
├── files # Indexed files with SHA-256 hashes
|
|
125
|
+
├── symbols # Functions, classes, methods, types
|
|
126
|
+
├── symbols_fts # FTS5 full-text search index
|
|
127
|
+
├── symbols_vec # sqlite-vec 384-dim vector index
|
|
128
|
+
├── call_edges # Call graph (caller → callee)
|
|
129
|
+
└── file_content_fts # Raw file content search
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Use Cases
|
|
133
|
+
|
|
134
|
+
- **AI Coding Agents**: Give your agent surgical access to codebases without burning context
|
|
135
|
+
- **Code Review**: Find all callers of a function before changing its signature
|
|
136
|
+
- **Onboarding**: Search symbols semantically — "where is error handling?" finds relevant code
|
|
137
|
+
- **Refactoring**: Map call graphs before moving functions between modules
|
|
138
|
+
- **Documentation**: Extract all public APIs with signatures and docstrings
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
MIT
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# CodeMunch Pro
|
|
2
|
+
|
|
3
|
+
Intelligent code indexing MCP server. Tree-sitter AST extraction, hybrid search (FTS5 + vector), call graphs, 10 languages, incremental indexing.
|
|
4
|
+
|
|
5
|
+
**Save 99% of tokens** — get exact function source via byte-offset seek instead of reading entire files.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install codemunch-pro
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### Claude Desktop / Cline
|
|
16
|
+
|
|
17
|
+
Add to your MCP client config:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"mcpServers": {
|
|
22
|
+
"codemunch-pro": {
|
|
23
|
+
"command": "codemunch-pro"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### HTTP Server
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
codemunch-pro --transport streamable-http --port 5002
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 13 MCP Tools
|
|
36
|
+
|
|
37
|
+
| Tool | Description |
|
|
38
|
+
|------|-------------|
|
|
39
|
+
| `index_folder` | Index a local directory (incremental, SHA-256 based) |
|
|
40
|
+
| `index_repo` | Index a GitHub/GitLab repo (v1.1) |
|
|
41
|
+
| `list_repos` | List all indexed repositories with stats |
|
|
42
|
+
| `invalidate_cache` | Force re-index a repository |
|
|
43
|
+
| `file_tree` | Get directory tree with file counts |
|
|
44
|
+
| `file_outline` | List symbols in a single file |
|
|
45
|
+
| `repo_outline` | List all symbols in repo (summary) |
|
|
46
|
+
| `get_symbol` | Get full source of one symbol (O(1) byte seek) |
|
|
47
|
+
| `get_symbols` | Batch get multiple symbols |
|
|
48
|
+
| `search_symbols` | Hybrid search (FTS5 + vector RRF) |
|
|
49
|
+
| `search_text` | Full-text search in file contents |
|
|
50
|
+
| `get_callees` | What does this function call? |
|
|
51
|
+
| `get_callers` | Who calls this function? |
|
|
52
|
+
|
|
53
|
+
## 10 Languages
|
|
54
|
+
|
|
55
|
+
Python, JavaScript, TypeScript, Go, Rust, Java, C, C++, C#, Ruby
|
|
56
|
+
|
|
57
|
+
All via [tree-sitter-language-pack](https://pypi.org/project/tree-sitter-language-pack/) — zero compilation, pre-built binaries.
|
|
58
|
+
|
|
59
|
+
## Key Features
|
|
60
|
+
|
|
61
|
+
### O(1) Symbol Retrieval
|
|
62
|
+
Every symbol stores its byte offset and length. `get_symbol` seeks directly to the function source — no reading entire files. A 200-byte function from a 40KB file = **99.5% token savings**.
|
|
63
|
+
|
|
64
|
+
### Incremental Indexing
|
|
65
|
+
Files are hashed (SHA-256). Only changed files are re-parsed. Re-indexing a 10K file repo after changing one file takes milliseconds.
|
|
66
|
+
|
|
67
|
+
### Hybrid Search (FTS5 + Vector)
|
|
68
|
+
Combines BM25 keyword matching with semantic vector similarity using Reciprocal Rank Fusion. Search "authentication middleware" and find `auth_middleware`, `verify_token`, and `login_handler`.
|
|
69
|
+
|
|
70
|
+
### Call Graphs
|
|
71
|
+
Traces function calls through the AST. `get_callees("main")` shows what `main` calls. `get_callers("authenticate")` shows who calls `authenticate`. Supports depth traversal.
|
|
72
|
+
|
|
73
|
+
### Full-Text Content Search
|
|
74
|
+
Search raw file contents — string literals, TODO comments, config values, error messages. Not just symbol names.
|
|
75
|
+
|
|
76
|
+
## How It Works
|
|
77
|
+
|
|
78
|
+
1. **Parse** — tree-sitter builds an AST for each source file
|
|
79
|
+
2. **Extract** — Walk AST to find functions, classes, methods, types, interfaces
|
|
80
|
+
3. **Store** — SQLite database per repo with FTS5 virtual tables
|
|
81
|
+
4. **Embed** — FastEmbed (ONNX, CPU-only) generates 384-dim vectors for semantic search
|
|
82
|
+
5. **Graph** — Call expressions extracted from function bodies, edges stored and resolved
|
|
83
|
+
6. **Serve** — FastMCP exposes 13 tools via stdio or HTTP
|
|
84
|
+
|
|
85
|
+
## Architecture
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
~/.codemunch-pro/
|
|
89
|
+
├── myproject_a1b2c3d4e5f6.db # Per-repo SQLite database
|
|
90
|
+
├── otherproject_7890abcdef.db
|
|
91
|
+
└── ...
|
|
92
|
+
|
|
93
|
+
Each DB contains:
|
|
94
|
+
├── files # Indexed files with SHA-256 hashes
|
|
95
|
+
├── symbols # Functions, classes, methods, types
|
|
96
|
+
├── symbols_fts # FTS5 full-text search index
|
|
97
|
+
├── symbols_vec # sqlite-vec 384-dim vector index
|
|
98
|
+
├── call_edges # Call graph (caller → callee)
|
|
99
|
+
└── file_content_fts # Raw file content search
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Use Cases
|
|
103
|
+
|
|
104
|
+
- **AI Coding Agents**: Give your agent surgical access to codebases without burning context
|
|
105
|
+
- **Code Review**: Find all callers of a function before changing its signature
|
|
106
|
+
- **Onboarding**: Search symbols semantically — "where is error handling?" finds relevant code
|
|
107
|
+
- **Refactoring**: Map call graphs before moving functions between modules
|
|
108
|
+
- **Documentation**: Extract all public APIs with signatures and docstrings
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
MIT
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "codemunch-pro"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Intelligent code indexing MCP server. Tree-sitter AST extraction, hybrid search (FTS5 + vector), call graphs, 10 languages, incremental indexing."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Jai Dunlop", email = "jaidunlop85@gmail.com" },
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"mcp",
|
|
17
|
+
"mcp-server",
|
|
18
|
+
"code-indexing",
|
|
19
|
+
"tree-sitter",
|
|
20
|
+
"code-search",
|
|
21
|
+
"call-graph",
|
|
22
|
+
"ast",
|
|
23
|
+
"developer-tools",
|
|
24
|
+
]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Development Status :: 4 - Beta",
|
|
27
|
+
"Intended Audience :: Developers",
|
|
28
|
+
"License :: OSI Approved :: MIT License",
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"Programming Language :: Python :: 3.10",
|
|
31
|
+
"Programming Language :: Python :: 3.11",
|
|
32
|
+
"Programming Language :: Python :: 3.12",
|
|
33
|
+
"Programming Language :: Python :: 3.13",
|
|
34
|
+
"Topic :: Software Development :: Libraries",
|
|
35
|
+
"Topic :: Text Processing :: Indexing",
|
|
36
|
+
]
|
|
37
|
+
dependencies = [
|
|
38
|
+
"mcp[cli]>=1.6.0",
|
|
39
|
+
"tree-sitter-language-pack>=0.7.0",
|
|
40
|
+
"httpx>=0.27.0",
|
|
41
|
+
"fastembed>=0.6.0",
|
|
42
|
+
"sqlite-vec>=0.1.0",
|
|
43
|
+
"pathspec>=0.12.0",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[project.scripts]
|
|
47
|
+
codemunch-pro = "codemunch_pro.__main__:main"
|
|
48
|
+
|
|
49
|
+
[project.urls]
|
|
50
|
+
Homepage = "https://github.com/BigJai/codemunch-pro"
|
|
51
|
+
Repository = "https://github.com/BigJai/codemunch-pro"
|
|
52
|
+
Issues = "https://github.com/BigJai/codemunch-pro/issues"
|
|
53
|
+
|
|
54
|
+
[tool.hatch.build.targets.wheel]
|
|
55
|
+
packages = ["src/codemunch_pro"]
|
|
56
|
+
|
|
57
|
+
[tool.pytest.ini_options]
|
|
58
|
+
testpaths = ["tests"]
|
|
59
|
+
asyncio_mode = "auto"
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://cdn.mcpregistry.io/specs/v2025-12-11/server-schema.json",
|
|
3
|
+
"name": "CodeMunch Pro",
|
|
4
|
+
"description": "Intelligent code indexing MCP server. Tree-sitter AST extraction, hybrid search (FTS5 + vector), call graphs, 10 languages, incremental indexing. Save 99% of tokens with O(1) byte-offset symbol retrieval.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"url": "https://github.com/BigJai/codemunch-pro",
|
|
7
|
+
"source": "github",
|
|
8
|
+
"id": "BigJai/codemunch-pro"
|
|
9
|
+
},
|
|
10
|
+
"version_detail": {
|
|
11
|
+
"version": "0.1.0",
|
|
12
|
+
"release_date": "2026-03-02",
|
|
13
|
+
"is_latest": true
|
|
14
|
+
},
|
|
15
|
+
"packages": [
|
|
16
|
+
{
|
|
17
|
+
"registry_name": "pypi",
|
|
18
|
+
"name": "codemunch-pro",
|
|
19
|
+
"version": "0.1.0",
|
|
20
|
+
"runtime": "python",
|
|
21
|
+
"runtime_version": ">=3.10",
|
|
22
|
+
"package_arguments": [],
|
|
23
|
+
"environment_variables": []
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"remotes": [],
|
|
27
|
+
"tools": [
|
|
28
|
+
{
|
|
29
|
+
"name": "index_folder",
|
|
30
|
+
"description": "Index a local directory using tree-sitter AST parsing. Supports 10 languages with incremental indexing.",
|
|
31
|
+
"annotations": {
|
|
32
|
+
"title": "Index Folder",
|
|
33
|
+
"readOnlyHint": false,
|
|
34
|
+
"openWorldHint": false
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "index_repo",
|
|
39
|
+
"description": "Index a GitHub or GitLab repository by cloning it locally.",
|
|
40
|
+
"annotations": {
|
|
41
|
+
"title": "Index Repository",
|
|
42
|
+
"readOnlyHint": false,
|
|
43
|
+
"openWorldHint": true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "list_repos",
|
|
48
|
+
"description": "List all indexed repositories with stats.",
|
|
49
|
+
"annotations": {
|
|
50
|
+
"title": "List Repositories",
|
|
51
|
+
"readOnlyHint": true,
|
|
52
|
+
"openWorldHint": false
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "invalidate_cache",
|
|
57
|
+
"description": "Force re-index a repository by clearing its cache.",
|
|
58
|
+
"annotations": {
|
|
59
|
+
"title": "Invalidate Cache",
|
|
60
|
+
"readOnlyHint": false,
|
|
61
|
+
"openWorldHint": false
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "file_tree",
|
|
66
|
+
"description": "Get directory tree of an indexed repository with file counts.",
|
|
67
|
+
"annotations": {
|
|
68
|
+
"title": "File Tree",
|
|
69
|
+
"readOnlyHint": true,
|
|
70
|
+
"openWorldHint": false
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "file_outline",
|
|
75
|
+
"description": "List all symbols in a single file ordered by line number.",
|
|
76
|
+
"annotations": {
|
|
77
|
+
"title": "File Outline",
|
|
78
|
+
"readOnlyHint": true,
|
|
79
|
+
"openWorldHint": false
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "repo_outline",
|
|
84
|
+
"description": "List all symbols in the repository (summary view).",
|
|
85
|
+
"annotations": {
|
|
86
|
+
"title": "Repository Outline",
|
|
87
|
+
"readOnlyHint": true,
|
|
88
|
+
"openWorldHint": false
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"name": "get_symbol",
|
|
93
|
+
"description": "Get full source code of a symbol via O(1) byte-offset seek. Saves 99% tokens vs reading entire files.",
|
|
94
|
+
"annotations": {
|
|
95
|
+
"title": "Get Symbol",
|
|
96
|
+
"readOnlyHint": true,
|
|
97
|
+
"openWorldHint": false
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"name": "get_symbols",
|
|
102
|
+
"description": "Batch get source code for multiple symbols at once.",
|
|
103
|
+
"annotations": {
|
|
104
|
+
"title": "Get Symbols (Batch)",
|
|
105
|
+
"readOnlyHint": true,
|
|
106
|
+
"openWorldHint": false
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "search_symbols",
|
|
111
|
+
"description": "Hybrid search across symbols using FTS5 keyword + vector semantic similarity with Reciprocal Rank Fusion.",
|
|
112
|
+
"annotations": {
|
|
113
|
+
"title": "Search Symbols",
|
|
114
|
+
"readOnlyHint": true,
|
|
115
|
+
"openWorldHint": false
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"name": "search_text",
|
|
120
|
+
"description": "Full-text search in file contents. Find string literals, comments, config values.",
|
|
121
|
+
"annotations": {
|
|
122
|
+
"title": "Search Text",
|
|
123
|
+
"readOnlyHint": true,
|
|
124
|
+
"openWorldHint": false
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "get_callees",
|
|
129
|
+
"description": "Get what a function calls (outgoing call graph edges) with depth traversal.",
|
|
130
|
+
"annotations": {
|
|
131
|
+
"title": "Get Callees",
|
|
132
|
+
"readOnlyHint": true,
|
|
133
|
+
"openWorldHint": false
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"name": "get_callers",
|
|
138
|
+
"description": "Get who calls a function (incoming call graph edges) with depth traversal.",
|
|
139
|
+
"annotations": {
|
|
140
|
+
"title": "Get Callers",
|
|
141
|
+
"readOnlyHint": true,
|
|
142
|
+
"openWorldHint": false
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"prompts": [],
|
|
147
|
+
"resources": []
|
|
148
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""CLI entry point for CodeMunch Pro."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def main() -> None:
|
|
8
|
+
parser = argparse.ArgumentParser(
|
|
9
|
+
prog='codemunch-pro',
|
|
10
|
+
description='Intelligent code indexing MCP server',
|
|
11
|
+
)
|
|
12
|
+
parser.add_argument(
|
|
13
|
+
'--version', action='version', version=f'%(prog)s 0.1.0',
|
|
14
|
+
)
|
|
15
|
+
parser.add_argument(
|
|
16
|
+
'--transport',
|
|
17
|
+
choices=['stdio', 'streamable-http'],
|
|
18
|
+
default='stdio',
|
|
19
|
+
help='MCP transport (default: stdio)',
|
|
20
|
+
)
|
|
21
|
+
parser.add_argument(
|
|
22
|
+
'--port',
|
|
23
|
+
type=int,
|
|
24
|
+
default=5002,
|
|
25
|
+
help='Port for streamable-http transport (default: 5002)',
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
args = parser.parse_args()
|
|
29
|
+
|
|
30
|
+
from codemunch_pro.server import create_server
|
|
31
|
+
|
|
32
|
+
mcp = create_server(transport=args.transport, port=args.port)
|
|
33
|
+
|
|
34
|
+
if args.transport == 'stdio':
|
|
35
|
+
mcp.run(transport='stdio')
|
|
36
|
+
else:
|
|
37
|
+
mcp.run(
|
|
38
|
+
transport='streamable-http',
|
|
39
|
+
host='0.0.0.0',
|
|
40
|
+
port=args.port,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if __name__ == '__main__':
|
|
45
|
+
main()
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""FastEmbed ONNX embeddings for semantic code search."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from typing import Sequence
|
|
7
|
+
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
MODEL_NAME = 'BAAI/bge-small-en-v1.5'
|
|
11
|
+
EMBEDDING_DIM = 384
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Embedder:
|
|
15
|
+
"""Lazy-loading FastEmbed wrapper for code symbol embeddings."""
|
|
16
|
+
|
|
17
|
+
def __init__(self, model_name: str = MODEL_NAME):
|
|
18
|
+
self.model_name = model_name
|
|
19
|
+
self._model = None
|
|
20
|
+
|
|
21
|
+
@property
|
|
22
|
+
def model(self):
|
|
23
|
+
"""Lazy-load the embedding model on first use."""
|
|
24
|
+
if self._model is None:
|
|
25
|
+
from fastembed import TextEmbedding
|
|
26
|
+
logger.info('Loading embedding model: %s', self.model_name)
|
|
27
|
+
self._model = TextEmbedding(model_name=self.model_name)
|
|
28
|
+
return self._model
|
|
29
|
+
|
|
30
|
+
def embed(self, texts: Sequence[str]) -> list[list[float]]:
|
|
31
|
+
"""Embed a batch of texts.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
texts: Sequence of strings to embed.
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
List of embedding vectors (each is a list of floats).
|
|
38
|
+
"""
|
|
39
|
+
if not texts:
|
|
40
|
+
return []
|
|
41
|
+
return [vec.tolist() for vec in self.model.embed(list(texts))]
|
|
42
|
+
|
|
43
|
+
def embed_one(self, text: str) -> list[float]:
|
|
44
|
+
"""Embed a single text string."""
|
|
45
|
+
results = self.embed([text])
|
|
46
|
+
return results[0] if results else []
|
|
47
|
+
|
|
48
|
+
@staticmethod
|
|
49
|
+
def format_symbol_text(
|
|
50
|
+
name: str,
|
|
51
|
+
kind: str,
|
|
52
|
+
signature: str = '',
|
|
53
|
+
docstring: str = '',
|
|
54
|
+
language: str = '',
|
|
55
|
+
) -> str:
|
|
56
|
+
"""Format a symbol's metadata into a text string for embedding.
|
|
57
|
+
|
|
58
|
+
Creates a semantic representation that captures what the symbol does,
|
|
59
|
+
not just its name.
|
|
60
|
+
"""
|
|
61
|
+
parts = []
|
|
62
|
+
if language:
|
|
63
|
+
parts.append(f'{language}')
|
|
64
|
+
parts.append(f'{kind}: {name}')
|
|
65
|
+
if signature:
|
|
66
|
+
parts.append(signature)
|
|
67
|
+
if docstring:
|
|
68
|
+
# Truncate long docstrings
|
|
69
|
+
doc = docstring[:200]
|
|
70
|
+
parts.append(doc)
|
|
71
|
+
return ' | '.join(parts)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Parser module — tree-sitter AST extraction."""
|
|
2
|
+
|
|
3
|
+
from codemunch_pro.parser.symbols import Symbol, CallEdge
|
|
4
|
+
from codemunch_pro.parser.languages import LANGUAGES, get_language_for_file
|
|
5
|
+
from codemunch_pro.parser.extractor import extract_symbols
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
'Symbol',
|
|
9
|
+
'CallEdge',
|
|
10
|
+
'LANGUAGES',
|
|
11
|
+
'get_language_for_file',
|
|
12
|
+
'extract_symbols',
|
|
13
|
+
]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Call graph utilities — callee/caller traversal with depth control."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class CallGraphNode:
|
|
10
|
+
"""A node in the call graph traversal result."""
|
|
11
|
+
|
|
12
|
+
qualified_name: str
|
|
13
|
+
kind: str
|
|
14
|
+
file_path: str
|
|
15
|
+
line: int
|
|
16
|
+
depth: int
|
|
17
|
+
calls: list[str] = field(default_factory=list)
|
|
18
|
+
called_by: list[str] = field(default_factory=list)
|
|
19
|
+
|
|
20
|
+
def to_dict(self) -> dict:
|
|
21
|
+
return {
|
|
22
|
+
'qualified_name': self.qualified_name,
|
|
23
|
+
'kind': self.kind,
|
|
24
|
+
'file_path': self.file_path,
|
|
25
|
+
'line': self.line,
|
|
26
|
+
'depth': self.depth,
|
|
27
|
+
'calls': self.calls,
|
|
28
|
+
'called_by': self.called_by,
|
|
29
|
+
}
|