codesearch-mcp 0.0.14-alpha → 0.0.15-alpha
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.
- package/CHANGELOG.md +13 -0
- package/dist/src/services/McpServer.js +53 -16
- package/package.json +3 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
Format based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
5
|
+
|
|
6
|
+
## [0.0.15-alpha] - 2026-05-02
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
|
|
10
|
+
- **MCP server instructions restructured** — `Step 0` (query classification table) moved before the `Tools` list so it arrives before the truncation threshold and is always visible to the model
|
|
11
|
+
- **Lookup workflow fixed** — corrected order to `find_symbol` first (faster, exact match), `search_codebase` as fallback
|
|
12
|
+
- **Path distinction clarified** — `read_file_range` (relative path) and `read_file` (absolute path) now labelled directly in the Tools list, reducing wrong-path errors
|
|
13
|
+
- **Threshold contradiction resolved** — removed conflicting `0.35` example from Lookup/Conceptual workflow; canonical threshold guidance kept only in Relevance scores section
|
|
@@ -48,29 +48,65 @@ const PKG_VERSION = (() => {
|
|
|
48
48
|
return '0.0.0';
|
|
49
49
|
}
|
|
50
50
|
})();
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
function buildInstructions(t) {
|
|
52
|
+
return `
|
|
53
|
+
You have access to a local code intelligence server. Use these tools to search codebases by meaning, navigate import graphs, look up symbol definitions, and read source files.
|
|
54
|
+
|
|
55
|
+
## Step 0 — Classify your query before starting
|
|
56
|
+
|
|
57
|
+
Pick one workflow based on what you need:
|
|
58
|
+
|
|
59
|
+
| Type | Signals | Workflow |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| **Lookup** | "where is X defined", "find Y" | find_symbol (if name known) → search_codebase (if not found) |
|
|
62
|
+
| **Conceptual** | "how does X work", "what is Y" | search_codebase → read_file_range |
|
|
63
|
+
| **Flow audit** | "how does X connect to Y", "audit this flow", "trace the path" | search_codebase → **get_dependencies + get_dependents** → Grep |
|
|
64
|
+
| **Impact** | "what would break if I change X", "what uses Z" | get_dependents → search_codebase for context |
|
|
53
65
|
|
|
54
66
|
## Tools
|
|
55
67
|
|
|
56
68
|
- **list_projects** — call this first to see what projects are indexed and their exact names.
|
|
57
69
|
- **search_codebase** — semantic search across indexed source files. Returns file path, line number, and a code chunk.
|
|
58
|
-
- **read_file_range** — read a specific line range from any indexed file.
|
|
70
|
+
- **read_file_range** — read a specific line range from any indexed file. Expects a **relative path** as returned by search_codebase.
|
|
59
71
|
- **get_dependencies** — show what files a given file imports (direct or transitive). Use to understand what a file depends on.
|
|
60
72
|
- **get_dependents** — show which files import a given file (reverse graph). Use before refactoring to find all callers.
|
|
61
73
|
- **find_symbol** — find where a symbol (function, class, type, interface, variable, method) is defined by exact name. Faster than semantic search when you know the name.
|
|
62
74
|
- **list_files** — browse the directory tree of a project path. Use to understand project structure before reading files.
|
|
63
|
-
- **read_file** — read a complete file by absolute path with line numbers. Truncates at max_lines with a hint to continue.
|
|
75
|
+
- **read_file** — read a complete file by **absolute path** with line numbers. Truncates at max_lines with a hint to continue.
|
|
64
76
|
|
|
65
77
|
## Recommended workflow
|
|
66
78
|
|
|
79
|
+
### Lookup / Conceptual
|
|
67
80
|
1. Use \`list_projects\` to discover available projects before filtering by \`project\`.
|
|
68
|
-
2.
|
|
69
|
-
3.
|
|
70
|
-
4.
|
|
71
|
-
5. Use \`find_symbol\` when you know the exact name
|
|
72
|
-
6. Use \`list_files\` to explore project structure
|
|
73
|
-
|
|
81
|
+
2. Use \`search_codebase\` to find relevant code by meaning. If your query uses an ambiguous term (e.g. "subscription" could mean pub/sub or billing), pass a lower \`threshold\` (e.g. \`0.40–0.45\`) to filter out weak matches.
|
|
82
|
+
3. If a result looks **truncated or incomplete**, call \`read_file_range\` with the returned \`file_path\` and \`start_line\`.
|
|
83
|
+
4. For exploratory searches where results span chunk boundaries, pass \`include_neighbors: true\`.
|
|
84
|
+
5. Use \`find_symbol\` when you know the exact name — faster than semantic search. Use \`kind: "method"\` for class methods — grep matches lines where \`public\`, \`async\`, \`static\`, or \`override\` appears before the name.
|
|
85
|
+
6. Use \`list_files\` to explore project structure before diving into files. Use \`read_file\` to read a complete file by absolute path.
|
|
86
|
+
|
|
87
|
+
### Flow audit (mandatory steps — do not skip 3 and 4)
|
|
88
|
+
1. Use \`list_projects\` to confirm project names.
|
|
89
|
+
2. Use \`search_codebase\` to find the **central file** (entry point of the flow).
|
|
90
|
+
3. **\`get_dependencies(central_file)\`** — what does this file import? Catches configs, loaders, Redis clients, types.
|
|
91
|
+
4. **\`get_dependents(central_file)\`** — who calls this file? Catches resolvers, routes, socket handlers.
|
|
92
|
+
5. For each peripheral file found in steps 3–4: use \`read_file_range\` or \`find_symbol\` to inspect it.
|
|
93
|
+
6. Only after steps 3–4 draw architectural conclusions — \`search_codebase\` alone misses peripheral files because they are semantically thin (configs, types, loaders contain no domain vocabulary).
|
|
94
|
+
|
|
95
|
+
> **Note:** If \`get_dependencies\` / \`get_dependents\` return empty, the file likely uses path aliases (e.g. \`@core/\`, \`@/\`, \`@db/\`). Fall back to \`Grep\` on the symbol name across the project.
|
|
96
|
+
|
|
97
|
+
### Impact analysis
|
|
98
|
+
1. \`get_dependents(target_file)\` — direct callers.
|
|
99
|
+
2. \`get_dependents(target_file, transitive: true)\` — full reverse graph.
|
|
100
|
+
3. \`search_codebase\` for context on unfamiliar dependents.
|
|
101
|
+
|
|
102
|
+
## When to use read_file_range vs include_neighbors
|
|
103
|
+
|
|
104
|
+
- **include_neighbors: true** — good when context is fragmented across chunks (e.g. a class definition split across chunks).
|
|
105
|
+
- **read_file_range** — better for a precise section, or when one result is cut off.
|
|
106
|
+
|
|
107
|
+
## Handling Code Structure
|
|
108
|
+
- **Class/Function limits**: Chunks often end abruptly. Use \`read_file_range\` to find the closing brace or method start.
|
|
109
|
+
- **Cross-file references**: If you see \`this.validator.validate(data)\`, use \`search_codebase\` to find \`validator\`.
|
|
74
110
|
|
|
75
111
|
## Dependency graph
|
|
76
112
|
|
|
@@ -80,8 +116,9 @@ If \`get_dependents\` returns 0 results, add \`symbol\` (the exported name you c
|
|
|
80
116
|
|
|
81
117
|
## Relevance scores
|
|
82
118
|
|
|
83
|
-
Lower score = better match (cosine distance). Results above the configured threshold are filtered out automatically. Pass \`threshold\` to \`search_codebase\` to override per-query
|
|
119
|
+
Lower score = better match (cosine distance). Results above the configured threshold are filtered out automatically. Treat scores above 0.50 as weak hints — verify with \`read_file_range\` or \`Grep\`. Pass \`threshold\` to \`search_codebase\` to override per-query: \`0.40–0.45\` for precise technical queries (known term, exact concept); \`${t}\` default (broad but reliable). Avoid \`0.35\` — too strict for DSL files (GraphQL, Prisma) and infrastructure code.
|
|
84
120
|
`.trim();
|
|
121
|
+
}
|
|
85
122
|
class McpServer {
|
|
86
123
|
searcher;
|
|
87
124
|
config;
|
|
@@ -92,7 +129,7 @@ class McpServer {
|
|
|
92
129
|
this.logger = logger;
|
|
93
130
|
}
|
|
94
131
|
async start(startupError) {
|
|
95
|
-
const server = new index_js_1.Server({ name: 'local-rag', version: PKG_VERSION }, { capabilities: { tools: {} }, instructions:
|
|
132
|
+
const server = new index_js_1.Server({ name: 'local-rag', version: PKG_VERSION }, { capabilities: { tools: {} }, instructions: buildInstructions(this.config.search.similarityThreshold) });
|
|
96
133
|
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
|
|
97
134
|
tools: [
|
|
98
135
|
{
|
|
@@ -105,14 +142,14 @@ class McpServer {
|
|
|
105
142
|
limit: { type: 'number', description: `Max results (default ${this.config.search.defaultLimit}, max ${this.config.search.maxLimit})` },
|
|
106
143
|
project: { type: 'string', description: 'Filter by project name (optional). Use list_projects to see available names.' },
|
|
107
144
|
include_neighbors: { type: 'boolean', description: 'Also include the chunk before and after each result from the same file (Small-to-Big retrieval). Useful when results look truncated.' },
|
|
108
|
-
threshold: { type: 'number', description: `Max cosine distance (0–1). Lower = stricter. Default: ${this.config.search.similarityThreshold}. Use
|
|
145
|
+
threshold: { type: 'number', description: `Max cosine distance (0–1). Lower = stricter. Default: ${this.config.search.similarityThreshold}. Use 0.40–0.45 for precise technical queries, 0.55–0.60 for broad exploration.` },
|
|
109
146
|
},
|
|
110
147
|
required: ['query'],
|
|
111
148
|
},
|
|
112
149
|
},
|
|
113
150
|
{
|
|
114
151
|
name: 'list_projects',
|
|
115
|
-
description: 'List all indexed projects with their chunk counts',
|
|
152
|
+
description: 'List all indexed projects with their chunk counts and metadata (description, stack, notes, relations from .ragmeta.json).',
|
|
116
153
|
inputSchema: { type: 'object', properties: {} },
|
|
117
154
|
},
|
|
118
155
|
{
|
|
@@ -185,11 +222,11 @@ class McpServer {
|
|
|
185
222
|
},
|
|
186
223
|
{
|
|
187
224
|
name: 'read_file',
|
|
188
|
-
description: 'Read a file
|
|
225
|
+
description: 'Read a file by absolute path. Returns contents with line numbers. Truncates at max_lines with a hint to continue with read_file_range.',
|
|
189
226
|
inputSchema: {
|
|
190
227
|
type: 'object',
|
|
191
228
|
properties: {
|
|
192
|
-
file_path: { type: 'string', description: 'Absolute path to the file
|
|
229
|
+
file_path: { type: 'string', description: 'Absolute path to the file. Note: search_codebase returns relative paths — construct the absolute path from your workspace root.' },
|
|
193
230
|
max_lines: { type: 'number', description: 'Maximum lines to return (default 300, max 1000)' },
|
|
194
231
|
},
|
|
195
232
|
required: ['file_path'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codesearch-mcp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15-alpha",
|
|
4
4
|
"description": "Local semantic codebase search via MCP — indexes projects into pgvector, exposes search to Claude",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/app.js",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"dist/",
|
|
14
14
|
"docker/",
|
|
15
|
-
"README.md"
|
|
15
|
+
"README.md",
|
|
16
|
+
"CHANGELOG.md"
|
|
16
17
|
],
|
|
17
18
|
"scripts": {
|
|
18
19
|
"build": "tsc",
|