smart-context-mcp 1.0.0 → 1.0.2

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
@@ -27,6 +27,8 @@ npx smart-context-init --target .
27
27
 
28
28
  That's it. Restart your AI client (Cursor, Codex, Claude Desktop) and the tools are available.
29
29
 
30
+ **Important:** The init command automatically sets the correct `cwd` (working directory) in the generated configs, so the MCP server runs from your project root. This works for standalone projects, monorepos, and nested workspaces.
31
+
30
32
  ## What you get
31
33
 
32
34
  Seven focused tools that work automatically:
@@ -217,6 +219,28 @@ The `intent` parameter in `smart_search` and `smart_context` adjusts ranking and
217
219
 
218
220
  The rules are idempotent — running `smart-context-init` again updates the section without duplicating it. Existing content in `AGENTS.md` and `CLAUDE.md` is preserved.
219
221
 
222
+ ## Use against another repo
223
+
224
+ By default, `devctx` works against the repo where it is installed. You can point it at another repo without modifying that target project:
225
+
226
+ ```bash
227
+ node ./src/mcp-server.js --project-root /path/to/target-repo
228
+ ```
229
+
230
+ or:
231
+
232
+ ```bash
233
+ DEVCTX_PROJECT_ROOT=/path/to/target-repo node ./src/mcp-server.js
234
+ ```
235
+
236
+ or (recommended for MCP clients):
237
+
238
+ ```bash
239
+ MCP_PROJECT_ROOT=/path/to/target-repo node ./src/mcp-server.js
240
+ ```
241
+
242
+ `smart-context-init` automatically sets `MCP_PROJECT_ROOT` in the generated client configs (`.cursor/mcp.json`, `.codex/config.toml`, `.mcp.json`, `.qwen/settings.json`), so the MCP server always launches from the correct project context, even in monorepos or when installed globally.
243
+
220
244
  ## What it is good at
221
245
 
222
246
  | Level | Languages / Stack | Use cases |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-context-mcp",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "MCP server that reduces agent token usage and improves response quality with compact file summaries, ranked code search, and curated context.",
5
5
  "author": "Francisco Caballero Portero <fcp1978@hotmail.com>",
6
6
  "type": "module",
@@ -118,11 +118,14 @@ const writeFile = (filePath, content, dryRun) => {
118
118
  console.log(`updated ${filePath}`);
119
119
  };
120
120
 
121
- const getServerConfig = ({ name, command, args }) => ({
121
+ const getServerConfig = ({ name, command, args, cwd }) => ({
122
122
  name,
123
123
  config: {
124
124
  command,
125
125
  args,
126
+ env: {
127
+ MCP_PROJECT_ROOT: cwd,
128
+ },
126
129
  },
127
130
  });
128
131
 
@@ -130,7 +133,14 @@ const updateCursorConfig = (targetDir, serverConfig, dryRun) => {
130
133
  const filePath = path.join(targetDir, '.cursor', 'mcp.json');
131
134
  const current = readJson(filePath, { mcpServers: {} });
132
135
  current.mcpServers ??= {};
133
- current.mcpServers[serverConfig.name] = serverConfig.config;
136
+ const existing = current.mcpServers[serverConfig.name] || {};
137
+ current.mcpServers[serverConfig.name] = {
138
+ ...serverConfig.config,
139
+ env: {
140
+ ...existing.env,
141
+ ...serverConfig.config.env,
142
+ },
143
+ };
134
144
  writeFile(filePath, `${JSON.stringify(current, null, 2)}\n`, dryRun);
135
145
  };
136
146
 
@@ -138,9 +148,13 @@ const updateClaudeConfig = (targetDir, serverConfig, dryRun) => {
138
148
  const filePath = path.join(targetDir, '.mcp.json');
139
149
  const current = readJson(filePath, { mcpServers: {} });
140
150
  current.mcpServers ??= {};
151
+ const existing = current.mcpServers[serverConfig.name] || {};
141
152
  current.mcpServers[serverConfig.name] = {
142
153
  ...serverConfig.config,
143
- env: current.mcpServers[serverConfig.name]?.env ?? {},
154
+ env: {
155
+ ...existing.env,
156
+ ...serverConfig.config.env,
157
+ },
144
158
  };
145
159
  writeFile(filePath, `${JSON.stringify(current, null, 2)}\n`, dryRun);
146
160
  };
@@ -151,7 +165,14 @@ const updateQwenConfig = (targetDir, serverConfig, dryRun) => {
151
165
  current.mcp ??= {};
152
166
  current.mcp.enabled = true;
153
167
  current.mcpServers ??= {};
154
- current.mcpServers[serverConfig.name] = serverConfig.config;
168
+ const existing = current.mcpServers[serverConfig.name] || {};
169
+ current.mcpServers[serverConfig.name] = {
170
+ ...serverConfig.config,
171
+ env: {
172
+ ...existing.env,
173
+ ...serverConfig.config.env,
174
+ },
175
+ };
155
176
  writeFile(filePath, `${JSON.stringify(current, null, 2)}\n`, dryRun);
156
177
  };
157
178
 
@@ -162,10 +183,17 @@ const buildCodexSection = (serverConfig) => {
162
183
  'required = false',
163
184
  `command = ${JSON.stringify(serverConfig.config.command)}`,
164
185
  `args = [${serverConfig.config.args.map((value) => JSON.stringify(value)).join(', ')}]`,
165
- 'startup_timeout_sec = 15.0',
166
- 'tool_timeout_sec = 30.0',
167
186
  ];
168
187
 
188
+ if (serverConfig.config.env && Object.keys(serverConfig.config.env).length > 0) {
189
+ const envEntries = Object.entries(serverConfig.config.env)
190
+ .map(([key, value]) => ` ${JSON.stringify(key)} = ${JSON.stringify(value)}`)
191
+ .join(',\n');
192
+ body.push(`env = {\n${envEntries}\n}`);
193
+ }
194
+
195
+ body.push('startup_timeout_sec = 15.0', 'tool_timeout_sec = 30.0');
196
+
169
197
  return { header, body };
170
198
  };
171
199
 
@@ -319,6 +347,7 @@ const main = () => {
319
347
  name: options.name,
320
348
  command: options.command,
321
349
  args,
350
+ cwd: targetDir,
322
351
  });
323
352
 
324
353
  const clientSet = new Set(options.clients);
package/src/mcp-server.js CHANGED
@@ -1,3 +1,8 @@
1
+ // Check if MCP_PROJECT_ROOT env var is set (passed by MCP clients via config)
2
+ if (process.env.MCP_PROJECT_ROOT) {
3
+ process.chdir(process.env.MCP_PROJECT_ROOT);
4
+ }
5
+
1
6
  import { runDevctxServer } from './server.js';
2
7
 
3
8
  await runDevctxServer();