Skip to content

Commit 10faca8

Browse files
pirumuclaude
andcommitted
fix(mcp): write task manager MCP config to .mcp.json instead of settings.json
Claude Code reads MCP servers from .mcp.json at project root, not settings.json. Bumps version to 0.1.2. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 37fced8 commit 10faca8

8 files changed

Lines changed: 48 additions & 21 deletions

File tree

bin/install

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ function resolvePlatformBinary(wantMedia = false) {
8888
const platform = process.platform; // 'darwin', 'linux', 'win32'
8989
const arch = process.arch; // 'x64', 'arm64'
9090
const ext = platform === "win32" ? ".exe" : "";
91-
const binaryName = wantMedia ? `hoangsa-cli-media${ext}` : `hoangsa-cli${ext}`;
91+
const binaryName = wantMedia
92+
? `hoangsa-cli-media${ext}`
93+
: `hoangsa-cli${ext}`;
9294
const fallbackName = `hoangsa-cli${ext}`; // if media binary not found, fall back to default
9395

9496
// Only x64 and arm64 have published packages
@@ -176,6 +178,20 @@ function writeSettings(settingsPath, settings) {
176178
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
177179
}
178180

181+
/** Read and parse .mcp.json; return { mcpServers: {} } on missing/invalid. */
182+
function readMcpJson(mcpJsonPath) {
183+
try {
184+
return JSON.parse(fs.readFileSync(mcpJsonPath, "utf8"));
185+
} catch {
186+
return { mcpServers: {} };
187+
}
188+
}
189+
190+
/** Write .mcp.json with 2-space indentation. */
191+
function writeMcpJson(mcpJsonPath, data) {
192+
fs.writeFileSync(mcpJsonPath, JSON.stringify(data, null, 2) + "\n");
193+
}
194+
179195
/** Get commit attribution from global settings: null=remove, undefined=default, string=custom. */
180196
function getCommitAttribution() {
181197
const { attribution } = readSettings(
@@ -681,7 +697,9 @@ function ensureHoangsaHooks(settings, targetDir) {
681697
},
682698
],
683699
});
684-
console.log(` ${green}${reset} Installed Stop hook (workflow completion guard)`);
700+
console.log(
701+
` ${green}${reset} Installed Stop hook (workflow completion guard)`,
702+
);
685703

686704
// --- PostToolUse auto-compact hook (periodic thoth compact of MEMORY + LESSONS) ---
687705
if (!settings.hooks.PostToolUse) settings.hooks.PostToolUse = [];
@@ -699,7 +717,9 @@ function ensureHoangsaHooks(settings, targetDir) {
699717
],
700718
matcher: "Bash|Write|Edit|NotebookEdit",
701719
});
702-
console.log(` ${green}${reset} Installed auto-compact hook (periodic thoth compact)`);
720+
console.log(
721+
` ${green}${reset} Installed auto-compact hook (periodic thoth compact)`,
722+
);
703723

704724
// --- PreToolUse lesson-guard hook (surfaces relevant lessons before edits) ---
705725
if (!settings.hooks.PreToolUse) settings.hooks.PreToolUse = [];
@@ -717,7 +737,9 @@ function ensureHoangsaHooks(settings, targetDir) {
717737
],
718738
matcher: "Edit|Write",
719739
});
720-
console.log(` ${green}${reset} Installed lesson-guard hook (recalls lessons before edits)`);
740+
console.log(
741+
` ${green}${reset} Installed lesson-guard hook (recalls lessons before edits)`,
742+
);
721743

722744
return true;
723745
}
@@ -776,7 +798,7 @@ function install(isGlobal) {
776798
console.log(` ${green}${reset} thoth already installed`);
777799
} catch {
778800
try {
779-
execSync("npx @unknownstudio/thoth", { stdio: "pipe" });
801+
execSync("npm i -g @unknownstudio/thoth", { stdio: "pipe" });
780802
console.log(` ${green}${reset} Installed thoth`);
781803
} catch (e) {
782804
console.log(` ${yellow}${reset} Could not install thoth: ${e.message}`);
@@ -796,8 +818,9 @@ function install(isGlobal) {
796818
return { settingsPath, settings };
797819
}
798820

799-
/** Prompt user to configure a task manager MCP server (ClickUp/Asana), or skip. */
800-
function handleTaskManager(settings, isInteractive, callback) {
821+
/** Prompt user to configure a task manager MCP server (ClickUp/Asana), or skip.
822+
* Reads/writes .mcp.json at mcpJsonPath (Claude Code only reads MCP from .mcp.json, not settings.json). */
823+
function handleTaskManager(mcpJsonPath, isInteractive, callback) {
801824
const TASK_MANAGER_MCP = {
802825
clickup: {
803826
label: "ClickUp",
@@ -816,10 +839,11 @@ function handleTaskManager(settings, isInteractive, callback) {
816839
docUrl: "https://github.com/roychri/mcp-server-asana",
817840
},
818841
};
819-
// Skip if already configured
842+
// Skip if already configured in .mcp.json
843+
const existingMcp = readMcpJson(mcpJsonPath);
820844
if (
821-
settings.mcpServers &&
822-
Object.keys(settings.mcpServers).some((k) =>
845+
existingMcp.mcpServers &&
846+
Object.keys(existingMcp.mcpServers).some((k) =>
823847
["clickup", "asana"].some((p) => k.toLowerCase().includes(p)),
824848
)
825849
) {
@@ -863,18 +887,20 @@ function handleTaskManager(settings, isInteractive, callback) {
863887
const provider = providers[idx];
864888
const mcpConfig = TASK_MANAGER_MCP[provider];
865889

866-
if (!settings.mcpServers) settings.mcpServers = {};
867-
settings.mcpServers[provider] =
890+
const mcpData = readMcpJson(mcpJsonPath);
891+
if (!mcpData.mcpServers) mcpData.mcpServers = {};
892+
mcpData.mcpServers[provider] =
868893
mcpConfig.transport === "http"
869894
? { type: "http", url: mcpConfig.url }
870895
: {
871896
command: mcpConfig.command,
872897
args: mcpConfig.args,
873898
env: mcpConfig.env,
874899
};
900+
writeMcpJson(mcpJsonPath, mcpData);
875901

876902
console.log(
877-
` ${green}${reset} Added ${mcpConfig.label} MCP server to settings`,
903+
` ${green}${reset} Added ${mcpConfig.label} MCP server to .mcp.json`,
878904
);
879905
if (mcpConfig.envHint) {
880906
console.log(` ${yellow}!${reset} Set your API key in settings.json:`);
@@ -897,7 +923,8 @@ function handleTaskManager(settings, isInteractive, callback) {
897923
* Chain: task manager setup → write settings → print completion
898924
*/
899925
function runPostInstall(result, isInteractive) {
900-
handleTaskManager(result.settings, isInteractive, () => {
926+
const mcpJsonPath = path.join(process.cwd(), ".mcp.json");
927+
handleTaskManager(mcpJsonPath, isInteractive, () => {
901928
writeSettings(result.settingsPath, result.settings);
902929
console.log(
903930
`\n ${green}Done!${reset} Start Claude Code and run ${cyan}/hoangsa:menu${reset} to begin.\n`,

npm/cli-darwin-arm64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hoangsa-cc/cli-darwin-arm64",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "A lean 3-phase (menu → prepare → cook) context engineering system for Claude Code by Zan. (macOS arm64)",
55
"author": "Zan",
66
"license": "MIT",

npm/cli-darwin-x64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hoangsa-cc/cli-darwin-x64",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "A lean 3-phase (menu → prepare → cook) context engineering system for Claude Code by Zan. (macOS x64)",
55
"author": "Zan",
66
"license": "MIT",

npm/cli-linux-arm64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hoangsa-cc/cli-linux-arm64",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "A lean 3-phase (menu → prepare → cook) context engineering system for Claude Code by Zan. (Linux arm64)",
55
"author": "Zan",
66
"license": "MIT",

npm/cli-linux-x64-musl/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hoangsa-cc/cli-linux-x64-musl",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "A lean 3-phase (menu → prepare → cook) context engineering system for Claude Code by Zan. (Linux x64 musl)",
55
"author": "Zan",
66
"license": "MIT",

npm/cli-linux-x64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hoangsa-cc/cli-linux-x64",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "A lean 3-phase (menu → prepare → cook) context engineering system for Claude Code by Zan. (Linux x64)",
55
"author": "Zan",
66
"license": "MIT",

npm/cli-windows-x64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hoangsa-cc/cli-windows-x64",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "A lean 3-phase (menu → prepare → cook) context engineering system for Claude Code by Zan. (Windows x64)",
55
"author": "Zan",
66
"license": "MIT",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hoangsa-cc",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"type": "module",
55
"description": "A lean 3-phase (menu → prepare → cook) context engineering system for Claude Code by Zan.",
66
"bin": {

0 commit comments

Comments
 (0)