pocketdex-mcp 0.2.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sujal Kumar
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,226 @@
1
+ Metadata-Version: 2.4
2
+ Name: pocketdex-mcp
3
+ Version: 0.2.0
4
+ Summary: A tiny local code index served over MCP, built on SQLite FTS5
5
+ Author: Sujal Kumar
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/sujalkumar1029-gif/pocketdex-mcp
8
+ Project-URL: Issues, https://github.com/sujalkumar1029-gif/pocketdex-mcp/issues
9
+ Keywords: mcp,code-search,sqlite,fts5,ai-agents,llm
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Software Development :: Libraries
15
+ Classifier: Topic :: Text Processing :: Indexing
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Dynamic: license-file
20
+
21
+ # PocketDex MCP
22
+
23
+ [![tests](https://github.com/sujalkumar1029-gif/pocketdex-mcp/actions/workflows/test.yml/badge.svg)](https://github.com/sujalkumar1029-gif/pocketdex-mcp/actions/workflows/test.yml)
24
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
25
+ [![python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/)
26
+ [![Glama](https://glama.ai/mcp/servers/sujalkumar1029-gif/pocketdex-mcp/badges/score.svg)](https://glama.ai/mcp/servers/sujalkumar1029-gif/pocketdex-mcp)
27
+ [![M8ven Score](https://m8ven.ai/badge/mcp/sujalkumar1029-gif-pocketdex-mcp-93cdxx?v=0e3c1bdd2d4681c1342043dfadede214)](https://m8ven.ai/mcp/sujalkumar1029-gif-pocketdex-mcp-93cdxx?s=readme)
28
+
29
+ A tiny local code index for AI agents, served over MCP. One Python file, no
30
+ dependencies, no background server, no vectors — just SQLite FTS5.
31
+
32
+ Ask an agent *"where are badge rules calculated?"* and it gets a file path, a
33
+ line range, and a short highlighted snippet instead of opening five files.
34
+
35
+ ![PocketDex terminal demo](assets/demo.gif)
36
+
37
+ ## Why
38
+
39
+ An agent exploring a repo opens file after file, and every file costs context.
40
+ PocketDex indexes the folder once, then answers `search` with the passage the
41
+ agent needs.
42
+
43
+ Measured on a 34-file Flask app:
44
+
45
+ | Query | Result size | `app.py` alone |
46
+ |---|---|---|
47
+ | `parse_amount_cents` | ~120 tokens | ~4,442 tokens |
48
+ | `badge rules` | ~69 tokens | ~4,442 tokens |
49
+ | `sqlite connection` | ~285 tokens | ~4,442 tokens |
50
+
51
+ Index time: 0.06 s. Index size: ~0.5 MB. Query latency: 8–29 ms.
52
+ (Token counts are `characters / 4`, an approximation.)
53
+
54
+ ## Why it is different
55
+
56
+ | | PocketDex MCP | Shared code index | `grep` / `rg` |
57
+ |---|---|---|---|
58
+ | Dependencies | None (stdlib only) | Service + client | None |
59
+ | Setup | One file, no install | Install + run server | None |
60
+ | Storage | **One DB per project** | Often one shared index | None |
61
+ | Results | Ranked passages + lines | Ranked passages | Raw matching lines |
62
+ | Context cost | Low | Low | Low, but no ranking |
63
+ | Best at | 20–500 files | Large repos / corpora | One known symbol |
64
+
65
+ The important design choice is **isolation**. Each project gets its own
66
+ database inside PocketDex's folder:
67
+
68
+ ```
69
+ PocketDex/
70
+ ├── pocketdex.py
71
+ ├── data/projects/
72
+ │ ├── my-app-3f2a1b9c.db
73
+ │ └── other-api-7d1e0c44.db
74
+ ├── tests/
75
+ └── ARCHITECTURE.md
76
+ ```
77
+
78
+ - Nothing is written into the project being indexed.
79
+ - Two projects never share a database, so results cannot leak across them.
80
+ - Deleting a `.db` file removes that project's index completely.
81
+ - There is no central registry that can drift out of sync.
82
+
83
+ Override the location with `--data-dir` or `POCKETDEX_DATA`. Run from a clone,
84
+ data stays in `data/projects/` (gitignored). Installed as a package, it falls
85
+ back to `~/.local/share/pocketdex/projects/` because site-packages is not
86
+ writable.
87
+
88
+ `rg` is still the right tool for one known symbol. PocketDex is for exploring
89
+ an unfamiliar repo without paying for whole files.
90
+
91
+ ## Install
92
+
93
+ There is nothing to install. Clone the repo and run it:
94
+
95
+ ```bash
96
+ git clone https://github.com/sujalkumar1029-gif/pocketdex-mcp.git
97
+ cd pocketdex-mcp
98
+ python3 pocketdex.py --help
99
+ ```
100
+
101
+ Or run it straight from Git with `uv`:
102
+
103
+ ```bash
104
+ uvx --from git+https://github.com/sujalkumar1029-gif/pocketdex-mcp pocketdex index ~/Projects/my-app
105
+ ```
106
+
107
+ Requirements: Python 3.10+ and SQLite built with FTS5 (standard in CPython
108
+ builds).
109
+
110
+ ## Docker
111
+
112
+ Build the stdio server into a small image:
113
+
114
+ ```bash
115
+ docker build -t pocketdex-mcp .
116
+ docker run --rm -i pocketdex-mcp
117
+ ```
118
+
119
+ The index lives under `/app/data` inside the container. To keep it between
120
+ runs, use a named volume:
121
+
122
+ ```bash
123
+ docker run --rm -i -v pocketdex-data:/app/data pocketdex-mcp
124
+ ```
125
+
126
+ ## Quick start
127
+
128
+ ```bash
129
+ # index or refresh a project (incremental)
130
+ python3 pocketdex.py index ~/Projects/my-app
131
+
132
+ # search
133
+ python3 pocketdex.py search "parse_amount_cents"
134
+ python3 pocketdex.py search "badge rules" --limit 5
135
+ python3 pocketdex.py search "connect" --path-prefix src/db
136
+
137
+ # inspect every project's separate index
138
+ python3 pocketdex.py stats
139
+
140
+ # MCP server (what the agent runs)
141
+ python3 pocketdex.py serve
142
+ ```
143
+
144
+ `search` without `--project` uses the most recently indexed project. Pass
145
+ `--project ~/Projects/other` when several are indexed.
146
+
147
+ ## MCP configuration
148
+
149
+ Add this to your MCP client's config (for example
150
+ `~/.gemini/config/mcp_config.json` for Antigravity):
151
+
152
+ ```json
153
+ {
154
+ "mcpServers": {
155
+ "pocketdex": {
156
+ "command": "python3",
157
+ "args": ["/absolute/path/to/pocketdex.py", "serve"]
158
+ }
159
+ }
160
+ }
161
+ ```
162
+
163
+ Tools exposed:
164
+
165
+ | Tool | Purpose |
166
+ |---|---|
167
+ | `index_project` | Index or refresh one folder into its own DB. Incremental. |
168
+ | `search` | Keyword/identifier search in one project, with snippets. |
169
+ | `stats` | Every indexed project, its DB path, file/chunk counts, size. |
170
+
171
+ ## Reproduce the numbers
172
+
173
+ ```bash
174
+ python3 benchmark.py ~/Projects/my-app
175
+ ```
176
+
177
+ It indexes the folder, prints index time and database size, then measures the
178
+ approximate token cost of a few queries against the total source size.
179
+
180
+ ## How it works
181
+
182
+ - Walks the folder, skipping `.git`, `node_modules`, `.venv`, `dist`, build
183
+ output, lockfiles, hidden folders, files over 512 KB, and binaries.
184
+ - Splits files into 40-line chunks with 12 lines of overlap.
185
+ - Stores chunks in SQLite FTS5 with `_` as a token character, so
186
+ `parse_amount_cents` stays one searchable token.
187
+ - BM25 ranking, at most two results per file, snippets capped at 12 tokens of
188
+ context.
189
+ - Re-indexing compares `mtime_ns` and size; unchanged files are skipped.
190
+
191
+ `ARCHITECTURE.md` explains the data model, indexing pipeline, ranking, MCP
192
+ lifecycle, failure modes, and extension points.
193
+
194
+ ## Limits (on purpose)
195
+
196
+ - **No embeddings / vector search.** Keyword + prefix matching only. Code
197
+ search is dominated by exact identifiers.
198
+ - **No regex tool.** Add one only if a real need appears.
199
+ - **Small-to-medium projects.** A 20–500 file range is the target; a multi-GB
200
+ monorepo belongs on a dedicated search service.
201
+ - **No file watching.** Call `index_project` after large edits; unchanged
202
+ files are cheap to skip.
203
+ - **Plaintext index.** Treat the data folder with the same care as the source
204
+ it indexes.
205
+
206
+ ## Tests
207
+
208
+ ```bash
209
+ python3 -m pip install pytest
210
+ python3 -m pytest -q
211
+ ```
212
+
213
+ 11 tests: indexing, ignored dirs, binary skip, incremental re-index, deletion,
214
+ path filters, stats, per-project isolation, latest-project selection, and a
215
+ real MCP stdio handshake (initialize → tools/list → tools/call).
216
+
217
+ ## Status
218
+
219
+ Early (0.x). The MCP contract and CLI are stable; internals may change.
220
+ Issues and pull requests are welcome.
221
+
222
+ If PocketDex saves you tokens, a star helps other agent builders find it.
223
+
224
+ ## License
225
+
226
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,206 @@
1
+ # PocketDex MCP
2
+
3
+ [![tests](https://github.com/sujalkumar1029-gif/pocketdex-mcp/actions/workflows/test.yml/badge.svg)](https://github.com/sujalkumar1029-gif/pocketdex-mcp/actions/workflows/test.yml)
4
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
+ [![python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/)
6
+ [![Glama](https://glama.ai/mcp/servers/sujalkumar1029-gif/pocketdex-mcp/badges/score.svg)](https://glama.ai/mcp/servers/sujalkumar1029-gif/pocketdex-mcp)
7
+ [![M8ven Score](https://m8ven.ai/badge/mcp/sujalkumar1029-gif-pocketdex-mcp-93cdxx?v=0e3c1bdd2d4681c1342043dfadede214)](https://m8ven.ai/mcp/sujalkumar1029-gif-pocketdex-mcp-93cdxx?s=readme)
8
+
9
+ A tiny local code index for AI agents, served over MCP. One Python file, no
10
+ dependencies, no background server, no vectors — just SQLite FTS5.
11
+
12
+ Ask an agent *"where are badge rules calculated?"* and it gets a file path, a
13
+ line range, and a short highlighted snippet instead of opening five files.
14
+
15
+ ![PocketDex terminal demo](assets/demo.gif)
16
+
17
+ ## Why
18
+
19
+ An agent exploring a repo opens file after file, and every file costs context.
20
+ PocketDex indexes the folder once, then answers `search` with the passage the
21
+ agent needs.
22
+
23
+ Measured on a 34-file Flask app:
24
+
25
+ | Query | Result size | `app.py` alone |
26
+ |---|---|---|
27
+ | `parse_amount_cents` | ~120 tokens | ~4,442 tokens |
28
+ | `badge rules` | ~69 tokens | ~4,442 tokens |
29
+ | `sqlite connection` | ~285 tokens | ~4,442 tokens |
30
+
31
+ Index time: 0.06 s. Index size: ~0.5 MB. Query latency: 8–29 ms.
32
+ (Token counts are `characters / 4`, an approximation.)
33
+
34
+ ## Why it is different
35
+
36
+ | | PocketDex MCP | Shared code index | `grep` / `rg` |
37
+ |---|---|---|---|
38
+ | Dependencies | None (stdlib only) | Service + client | None |
39
+ | Setup | One file, no install | Install + run server | None |
40
+ | Storage | **One DB per project** | Often one shared index | None |
41
+ | Results | Ranked passages + lines | Ranked passages | Raw matching lines |
42
+ | Context cost | Low | Low | Low, but no ranking |
43
+ | Best at | 20–500 files | Large repos / corpora | One known symbol |
44
+
45
+ The important design choice is **isolation**. Each project gets its own
46
+ database inside PocketDex's folder:
47
+
48
+ ```
49
+ PocketDex/
50
+ ├── pocketdex.py
51
+ ├── data/projects/
52
+ │ ├── my-app-3f2a1b9c.db
53
+ │ └── other-api-7d1e0c44.db
54
+ ├── tests/
55
+ └── ARCHITECTURE.md
56
+ ```
57
+
58
+ - Nothing is written into the project being indexed.
59
+ - Two projects never share a database, so results cannot leak across them.
60
+ - Deleting a `.db` file removes that project's index completely.
61
+ - There is no central registry that can drift out of sync.
62
+
63
+ Override the location with `--data-dir` or `POCKETDEX_DATA`. Run from a clone,
64
+ data stays in `data/projects/` (gitignored). Installed as a package, it falls
65
+ back to `~/.local/share/pocketdex/projects/` because site-packages is not
66
+ writable.
67
+
68
+ `rg` is still the right tool for one known symbol. PocketDex is for exploring
69
+ an unfamiliar repo without paying for whole files.
70
+
71
+ ## Install
72
+
73
+ There is nothing to install. Clone the repo and run it:
74
+
75
+ ```bash
76
+ git clone https://github.com/sujalkumar1029-gif/pocketdex-mcp.git
77
+ cd pocketdex-mcp
78
+ python3 pocketdex.py --help
79
+ ```
80
+
81
+ Or run it straight from Git with `uv`:
82
+
83
+ ```bash
84
+ uvx --from git+https://github.com/sujalkumar1029-gif/pocketdex-mcp pocketdex index ~/Projects/my-app
85
+ ```
86
+
87
+ Requirements: Python 3.10+ and SQLite built with FTS5 (standard in CPython
88
+ builds).
89
+
90
+ ## Docker
91
+
92
+ Build the stdio server into a small image:
93
+
94
+ ```bash
95
+ docker build -t pocketdex-mcp .
96
+ docker run --rm -i pocketdex-mcp
97
+ ```
98
+
99
+ The index lives under `/app/data` inside the container. To keep it between
100
+ runs, use a named volume:
101
+
102
+ ```bash
103
+ docker run --rm -i -v pocketdex-data:/app/data pocketdex-mcp
104
+ ```
105
+
106
+ ## Quick start
107
+
108
+ ```bash
109
+ # index or refresh a project (incremental)
110
+ python3 pocketdex.py index ~/Projects/my-app
111
+
112
+ # search
113
+ python3 pocketdex.py search "parse_amount_cents"
114
+ python3 pocketdex.py search "badge rules" --limit 5
115
+ python3 pocketdex.py search "connect" --path-prefix src/db
116
+
117
+ # inspect every project's separate index
118
+ python3 pocketdex.py stats
119
+
120
+ # MCP server (what the agent runs)
121
+ python3 pocketdex.py serve
122
+ ```
123
+
124
+ `search` without `--project` uses the most recently indexed project. Pass
125
+ `--project ~/Projects/other` when several are indexed.
126
+
127
+ ## MCP configuration
128
+
129
+ Add this to your MCP client's config (for example
130
+ `~/.gemini/config/mcp_config.json` for Antigravity):
131
+
132
+ ```json
133
+ {
134
+ "mcpServers": {
135
+ "pocketdex": {
136
+ "command": "python3",
137
+ "args": ["/absolute/path/to/pocketdex.py", "serve"]
138
+ }
139
+ }
140
+ }
141
+ ```
142
+
143
+ Tools exposed:
144
+
145
+ | Tool | Purpose |
146
+ |---|---|
147
+ | `index_project` | Index or refresh one folder into its own DB. Incremental. |
148
+ | `search` | Keyword/identifier search in one project, with snippets. |
149
+ | `stats` | Every indexed project, its DB path, file/chunk counts, size. |
150
+
151
+ ## Reproduce the numbers
152
+
153
+ ```bash
154
+ python3 benchmark.py ~/Projects/my-app
155
+ ```
156
+
157
+ It indexes the folder, prints index time and database size, then measures the
158
+ approximate token cost of a few queries against the total source size.
159
+
160
+ ## How it works
161
+
162
+ - Walks the folder, skipping `.git`, `node_modules`, `.venv`, `dist`, build
163
+ output, lockfiles, hidden folders, files over 512 KB, and binaries.
164
+ - Splits files into 40-line chunks with 12 lines of overlap.
165
+ - Stores chunks in SQLite FTS5 with `_` as a token character, so
166
+ `parse_amount_cents` stays one searchable token.
167
+ - BM25 ranking, at most two results per file, snippets capped at 12 tokens of
168
+ context.
169
+ - Re-indexing compares `mtime_ns` and size; unchanged files are skipped.
170
+
171
+ `ARCHITECTURE.md` explains the data model, indexing pipeline, ranking, MCP
172
+ lifecycle, failure modes, and extension points.
173
+
174
+ ## Limits (on purpose)
175
+
176
+ - **No embeddings / vector search.** Keyword + prefix matching only. Code
177
+ search is dominated by exact identifiers.
178
+ - **No regex tool.** Add one only if a real need appears.
179
+ - **Small-to-medium projects.** A 20–500 file range is the target; a multi-GB
180
+ monorepo belongs on a dedicated search service.
181
+ - **No file watching.** Call `index_project` after large edits; unchanged
182
+ files are cheap to skip.
183
+ - **Plaintext index.** Treat the data folder with the same care as the source
184
+ it indexes.
185
+
186
+ ## Tests
187
+
188
+ ```bash
189
+ python3 -m pip install pytest
190
+ python3 -m pytest -q
191
+ ```
192
+
193
+ 11 tests: indexing, ignored dirs, binary skip, incremental re-index, deletion,
194
+ path filters, stats, per-project isolation, latest-project selection, and a
195
+ real MCP stdio handshake (initialize → tools/list → tools/call).
196
+
197
+ ## Status
198
+
199
+ Early (0.x). The MCP contract and CLI are stable; internals may change.
200
+ Issues and pull requests are welcome.
201
+
202
+ If PocketDex saves you tokens, a star helps other agent builders find it.
203
+
204
+ ## License
205
+
206
+ MIT — see [LICENSE](LICENSE).