smart-coding-mcp 1.1.0 → 1.2.1

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/README.md CHANGED
@@ -30,36 +30,90 @@ This MCP server solves that by indexing your codebase with AI embeddings. Your A
30
30
 
31
31
  ## Installation
32
32
 
33
- ### Prerequisites
33
+ Install globally via npm:
34
34
 
35
- - Node.js 18 or higher
36
- - npm or yarn
35
+ ```bash
36
+ npm install -g smart-coding-mcp
37
+ ```
37
38
 
38
- ### Setup
39
+ ## Configuration
39
40
 
40
- 1. Install dependencies:
41
+ Add to your MCP configuration file (e.g., `~/.config/claude/mcp.json` or similar):
41
42
 
42
- ```bash
43
- npm install
43
+ ### Option 1: Specific Project (Recommended)
44
+
45
+ ```json
46
+ {
47
+ "mcpServers": {
48
+ "smart-coding-mcp": {
49
+ "command": "smart-coding-mcp",
50
+ "args": ["--workspace", "/absolute/path/to/your/project"]
51
+ }
52
+ }
53
+ }
44
54
  ```
45
55
 
46
- 2. Add to your MCP configuration file:
56
+ ### Option 2: Multi-Project Support
57
+
58
+ ```json
59
+ {
60
+ "mcpServers": {
61
+ "smart-coding-mcp-project-a": {
62
+ "command": "smart-coding-mcp",
63
+ "args": ["--workspace", "/path/to/project-a"]
64
+ },
65
+ "smart-coding-mcp-project-b": {
66
+ "command": "smart-coding-mcp",
67
+ "args": ["--workspace", "/path/to/project-b"]
68
+ }
69
+ }
70
+ }
71
+ ```
72
+
73
+ ### Option 3: Auto-Detect Current Directory
47
74
 
48
75
  ```json
49
76
  {
50
77
  "mcpServers": {
51
78
  "smart-coding-mcp": {
52
- "command": "node",
53
- "args": ["/path/to/smart-coding-mcp/index.js"],
54
- "cwd": "/path/to/smart-coding-mcp"
79
+ "command": "smart-coding-mcp"
55
80
  }
56
81
  }
57
82
  }
58
83
  ```
59
84
 
60
- 3. Restart your AI assistant
85
+ ## Environment Variables
86
+
87
+ Override configuration settings via environment variables in your MCP config:
88
+
89
+ | Variable | Type | Default | Description |
90
+ | ----------------------------- | ------- | --------- | ------------------------------ |
91
+ | `SMART_CODING_VERBOSE` | boolean | `false` | Enable detailed logging |
92
+ | `SMART_CODING_BATCH_SIZE` | number | `100` | Files to process in parallel |
93
+ | `SMART_CODING_MAX_FILE_SIZE` | number | `1048576` | Max file size in bytes (1MB) |
94
+ | `SMART_CODING_CHUNK_SIZE` | number | `15` | Lines of code per chunk |
95
+ | `SMART_CODING_MAX_RESULTS` | number | `5` | Max search results |
96
+ | `SMART_CODING_SMART_INDEXING` | boolean | `true` | Enable smart project detection |
97
+
98
+ **Example with environment variables:**
99
+
100
+ ```json
101
+ {
102
+ "mcpServers": {
103
+ "smart-coding-mcp": {
104
+ "command": "smart-coding-mcp",
105
+ "args": ["--workspace", "/path/to/project"],
106
+ "env": {
107
+ "SMART_CODING_VERBOSE": "true",
108
+ "SMART_CODING_BATCH_SIZE": "200",
109
+ "SMART_CODING_MAX_FILE_SIZE": "2097152"
110
+ }
111
+ }
112
+ }
113
+ }
114
+ ```
61
115
 
62
- The server will automatically index your codebase on first run.
116
+ **Note**: The server starts instantly and indexes in the background, so your IDE won't be blocked waiting for indexing to complete.
63
117
 
64
118
  ## Available Tools
65
119
 
@@ -119,7 +173,7 @@ This typically reduces indexed file count by 100x. A project with 50,000 files (
119
173
 
120
174
  ## Configuration
121
175
 
122
- The server works out of the box with sensible defaults. Create a `config.json` file to customize:
176
+ The server works out of the box with sensible defaults. Create a `config.json` file in your workspace to customize:
123
177
 
124
178
  ```json
125
179
  {
@@ -132,6 +186,8 @@ The server works out of the box with sensible defaults. Create a `config.json` f
132
186
  "cacheDirectory": "./.smart-coding-cache",
133
187
  "watchFiles": true,
134
188
  "chunkSize": 15,
189
+ "batchSize": 100,
190
+ "maxFileSize": 1048576,
135
191
  "maxResults": 5
136
192
  }
137
193
  ```
@@ -143,6 +199,8 @@ The server works out of the box with sensible defaults. Create a `config.json` f
143
199
  - `watchFiles`: Automatically reindex when files change (default: true)
144
200
  - `enableCache`: Cache embeddings to disk (default: true)
145
201
  - `chunkSize`: Lines of code per chunk - smaller = more precise, larger = more context (default: 15)
202
+ - `batchSize`: Number of files to process in parallel (default: 100)
203
+ - `maxFileSize`: Skip files larger than this size in bytes (default: 1MB)
146
204
 
147
205
  ## Examples
148
206
 
package/index.js CHANGED
@@ -4,6 +4,11 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
4
4
  import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
5
5
  import { pipeline } from "@xenova/transformers";
6
6
  import fs from "fs/promises";
7
+ import { createRequire } from "module";
8
+
9
+ // Import package.json for version
10
+ const require = createRequire(import.meta.url);
11
+ const packageJson = require("./package.json");
7
12
 
8
13
  import { loadConfig } from "./lib/config.js";
9
14
  import { EmbeddingsCache } from "./lib/cache.js";
@@ -110,7 +115,7 @@ async function initialize() {
110
115
  const server = new Server(
111
116
  {
112
117
  name: "smart-coding-mcp",
113
- version: "1.0.0"
118
+ version: packageJson.version
114
119
  },
115
120
  {
116
121
  capabilities: {
package/lib/config.js CHANGED
@@ -136,6 +136,57 @@ export async function loadConfig(workspaceDir = null) {
136
136
  console.error(`[Config] Error: ${error.message}`);
137
137
  }
138
138
 
139
+ // Apply environment variable overrides (prefix: SMART_CODING_) with validation
140
+ if (process.env.SMART_CODING_VERBOSE !== undefined) {
141
+ const value = process.env.SMART_CODING_VERBOSE;
142
+ if (value === 'true' || value === 'false') {
143
+ config.verbose = value === 'true';
144
+ }
145
+ }
146
+
147
+ if (process.env.SMART_CODING_BATCH_SIZE !== undefined) {
148
+ const value = parseInt(process.env.SMART_CODING_BATCH_SIZE, 10);
149
+ if (!isNaN(value) && value > 0 && value <= 1000) {
150
+ config.batchSize = value;
151
+ } else {
152
+ console.error(`[Config] Invalid SMART_CODING_BATCH_SIZE: ${process.env.SMART_CODING_BATCH_SIZE}, using default`);
153
+ }
154
+ }
155
+
156
+ if (process.env.SMART_CODING_MAX_FILE_SIZE !== undefined) {
157
+ const value = parseInt(process.env.SMART_CODING_MAX_FILE_SIZE, 10);
158
+ if (!isNaN(value) && value > 0) {
159
+ config.maxFileSize = value;
160
+ } else {
161
+ console.error(`[Config] Invalid SMART_CODING_MAX_FILE_SIZE: ${process.env.SMART_CODING_MAX_FILE_SIZE}, using default`);
162
+ }
163
+ }
164
+
165
+ if (process.env.SMART_CODING_CHUNK_SIZE !== undefined) {
166
+ const value = parseInt(process.env.SMART_CODING_CHUNK_SIZE, 10);
167
+ if (!isNaN(value) && value > 0 && value <= 100) {
168
+ config.chunkSize = value;
169
+ } else {
170
+ console.error(`[Config] Invalid SMART_CODING_CHUNK_SIZE: ${process.env.SMART_CODING_CHUNK_SIZE}, using default`);
171
+ }
172
+ }
173
+
174
+ if (process.env.SMART_CODING_MAX_RESULTS !== undefined) {
175
+ const value = parseInt(process.env.SMART_CODING_MAX_RESULTS, 10);
176
+ if (!isNaN(value) && value > 0 && value <= 100) {
177
+ config.maxResults = value;
178
+ } else {
179
+ console.error(`[Config] Invalid SMART_CODING_MAX_RESULTS: ${process.env.SMART_CODING_MAX_RESULTS}, using default`);
180
+ }
181
+ }
182
+
183
+ if (process.env.SMART_CODING_SMART_INDEXING !== undefined) {
184
+ const value = process.env.SMART_CODING_SMART_INDEXING;
185
+ if (value === 'true' || value === 'false') {
186
+ config.smartIndexing = value === 'true';
187
+ }
188
+ }
189
+
139
190
  return config;
140
191
  }
141
192
 
package/lib/utils.js CHANGED
@@ -31,14 +31,60 @@ export function smartChunk(content, file, config) {
31
31
 
32
32
  // Language-specific patterns for function/class detection
33
33
  const patterns = {
34
+ // JavaScript/TypeScript
34
35
  js: /^(export\s+)?(async\s+)?(function|class|const|let|var)\s+\w+/,
36
+ jsx: /^(export\s+)?(async\s+)?(function|class|const|let|var)\s+\w+/,
35
37
  ts: /^(export\s+)?(async\s+)?(function|class|const|let|var|interface|type)\s+\w+/,
36
- py: /^(class|def)\s+\w+/,
37
- java: /^(public|private|protected)?\s*(static\s+)?(class|interface|void|int|String|boolean)\s+\w+/,
38
- go: /^func\s+\w+/,
39
- rs: /^(pub\s+)?(fn|struct|enum|trait|impl)\s+\w+/,
38
+ tsx: /^(export\s+)?(async\s+)?(function|class|const|let|var|interface|type)\s+\w+/,
39
+ mjs: /^(export\s+)?(async\s+)?(function|class|const|let|var)\s+\w+/,
40
+ cjs: /^(export\s+)?(async\s+)?(function|class|const|let|var)\s+\w+/,
41
+
42
+ // Python
43
+ py: /^(class|def|async\s+def)\s+\w+/,
44
+ pyw: /^(class|def|async\s+def)\s+\w+/,
45
+
46
+ // Java/Kotlin/Scala
47
+ java: /^(public|private|protected)?\s*(static\s+)?(class|interface|enum|void|int|String|boolean)\s+\w+/,
48
+ kt: /^(class|interface|object|fun|val|var)\s+\w+/,
49
+ kts: /^(class|interface|object|fun|val|var)\s+\w+/,
50
+ scala: /^(class|object|trait|def|val|var)\s+\w+/,
51
+
52
+ // C/C++
53
+ c: /^(struct|enum|union|void|int|char|float|double)\s+\w+/,
54
+ cpp: /^(class|struct|namespace|template|void|int|bool)\s+\w+/,
55
+ cc: /^(class|struct|namespace|template|void|int|bool)\s+\w+/,
56
+ cxx: /^(class|struct|namespace|template|void|int|bool)\s+\w+/,
57
+ h: /^(class|struct|namespace|template|void|int|bool)\s+\w+/,
58
+ hpp: /^(class|struct|namespace|template|void|int|bool)\s+\w+/,
59
+
60
+ // C#
61
+ cs: /^(public|private|protected)?\s*(static\s+)?(class|interface|struct|enum|void|int|string|bool)\s+\w+/,
62
+
63
+ // Go
64
+ go: /^(func|type|const|var)\s+\w+/,
65
+
66
+ // Rust
67
+ rs: /^(pub\s+)?(fn|struct|enum|trait|impl|const|static)\s+\w+/,
68
+
69
+ // PHP
70
+ php: /^(class|interface|trait|function|const)\s+\w+/,
71
+
72
+ // Ruby
73
+ rb: /^(class|module|def)\s+\w+/,
74
+ rake: /^(class|module|def|task)\s+\w+/,
75
+
76
+ // Swift
77
+ swift: /^(class|struct|enum|protocol|func|var|let)\s+\w+/,
78
+
79
+ // R
80
+ r: /^(\w+)\s*<-\s*function/,
81
+ R: /^(\w+)\s*<-\s*function/,
82
+
83
+ // Lua
84
+ lua: /^(function|local\s+function)\s+\w+/,
40
85
  };
41
86
 
87
+
42
88
  const langPattern = patterns[ext.slice(1)] || patterns.js;
43
89
  let currentChunk = [];
44
90
  let chunkStartLine = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-coding-mcp",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "An extensible MCP server that enhances coding productivity with AI-powered features including semantic code search, intelligent indexing, and more, using local LLMs",
5
5
  "type": "module",
6
6
  "main": "index.js",