@magicsword-io/magicsword-mcp 0.1.0 → 0.1.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 +123 -21
- package/dist/client-setup.js +119 -0
- package/dist/client-setup.js.map +1 -0
- package/dist/configure.js +81 -99
- package/dist/configure.js.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,48 +14,149 @@ the user's machine, holds an `msk_…` API key, and speaks MCP over stdio.
|
|
|
14
14
|
> the server returns a clear "this MagicSword org needs the Enterprise plan
|
|
15
15
|
> to use MCP" message; nothing else works until the org is upgraded.
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## Quick start
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Requires **Node.js 22+**, an installed MCP client, and a MagicSword Enterprise
|
|
20
|
+
API key from **Magic Portal → Settings → API Keys**.
|
|
21
|
+
|
|
22
|
+
**Recommended: install and connect your client in one command.** Setup prompts
|
|
23
|
+
for your key privately and lets you choose Claude Desktop, Codex, Claude Code,
|
|
24
|
+
or Cursor:
|
|
20
25
|
|
|
21
26
|
```sh
|
|
22
|
-
npm install -g @magicsword-io/magicsword-mcp
|
|
27
|
+
npm install -g @magicsword-io/magicsword-mcp && magicsword-mcp configure
|
|
23
28
|
```
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
Registry can discover this server as
|
|
27
|
-
`io.github.magicsword-io/magicsword-mcp`. Homebrew, winget, and curl packaging
|
|
28
|
-
can follow if demand justifies maintaining signed platform artifacts.
|
|
30
|
+
Already know your client? Run the matching one-liner:
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
| Client | Install and configure |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| Claude Desktop | `npm install -g @magicsword-io/magicsword-mcp && magicsword-mcp configure --client claude-desktop` |
|
|
35
|
+
| Cursor | `npm install -g @magicsword-io/magicsword-mcp && magicsword-mcp configure --client cursor` |
|
|
36
|
+
| Claude Code | `npm install -g @magicsword-io/magicsword-mcp && magicsword-mcp configure --client claude-code` |
|
|
37
|
+
| OpenAI Codex | `npm install -g @magicsword-io/magicsword-mcp && magicsword-mcp configure --client codex` |
|
|
38
|
+
|
|
39
|
+
Prefer your client's own registration command? After saving your key locally,
|
|
40
|
+
these also work without a global server install:
|
|
31
41
|
|
|
32
42
|
```sh
|
|
33
|
-
magicsword-mcp
|
|
43
|
+
codex mcp add magicsword --env MAGICSWORD_BASE_URL=https://www.magicsword.io -- npx -y @magicsword-io/magicsword-mcp
|
|
44
|
+
claude mcp add --scope user --transport stdio magicsword --env MAGICSWORD_BASE_URL=https://www.magicsword.io -- npx -y @magicsword-io/magicsword-mcp
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
These are also a fallback when automatic registration cannot launch a client's
|
|
48
|
+
CLI on Windows. Desktop launch still requires Node/npx to be available to that
|
|
49
|
+
client; the recommended setup uses absolute paths instead.
|
|
50
|
+
|
|
51
|
+
### Install buttons: Cursor and VS Code
|
|
52
|
+
|
|
53
|
+
**First save your API key locally** (once per machine):
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
npm install -g @magicsword-io/magicsword-mcp && magicsword-mcp configure --client manual
|
|
34
57
|
```
|
|
35
58
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
59
|
+
Then click your client's button and approve its installation prompt:
|
|
60
|
+
|
|
61
|
+
[](https://cursor.com/en/install-mcp?name=magicsword&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBtYWdpY3N3b3JkLWlvL21hZ2ljc3dvcmQtbWNwIl0sImVudiI6eyJNQUdJQ1NXT1JEX0JBU0VfVVJMIjoiaHR0cHM6Ly93d3cubWFnaWNzd29yZC5pbyJ9fQ%3D%3D)
|
|
62
|
+
[](https://vscode.dev/redirect/mcp/install?name=magicsword&config=%7B%22type%22%3A%22stdio%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40magicsword-io%2Fmagicsword-mcp%22%5D%2C%22env%22%3A%7B%22MAGICSWORD_BASE_URL%22%3A%22https%3A%2F%2Fwww.magicsword.io%22%7D%7D)
|
|
63
|
+
[](https://insiders.vscode.dev/redirect/mcp/install?name=magicsword&config=%7B%22type%22%3A%22stdio%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40magicsword-io%2Fmagicsword-mcp%22%5D%2C%22env%22%3A%7B%22MAGICSWORD_BASE_URL%22%3A%22https%3A%2F%2Fwww.magicsword.io%22%7D%7D&quality=insiders)
|
|
64
|
+
|
|
65
|
+
These buttons register a local `npx` server pointing at production. They contain
|
|
66
|
+
no API key; the server reads `~/.magicsword/mcp.json`. They require `npx` on the
|
|
67
|
+
client's PATH. If a desktop app cannot find Node or npx, use the recommended
|
|
68
|
+
setup above for absolute launch paths, or copy the absolute `command` and
|
|
69
|
+
`args` printed by `configure --client manual` into its configuration.
|
|
40
70
|
|
|
41
|
-
|
|
42
|
-
- Linux: `~/.config/Claude/claude_desktop_config.json`
|
|
43
|
-
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
71
|
+
### Manual JSON fallback
|
|
44
72
|
|
|
45
|
-
|
|
73
|
+
After saving your key above, merge this entry into Claude Desktop's
|
|
74
|
+
`claude_desktop_config.json` or Cursor's `~/.cursor/mcp.json`, preserving your
|
|
75
|
+
other servers:
|
|
46
76
|
|
|
47
77
|
```json
|
|
48
78
|
{
|
|
49
79
|
"mcpServers": {
|
|
50
80
|
"magicsword": {
|
|
51
|
-
"command": "
|
|
81
|
+
"command": "npx",
|
|
82
|
+
"args": [
|
|
83
|
+
"-y",
|
|
84
|
+
"@magicsword-io/magicsword-mcp"
|
|
85
|
+
],
|
|
86
|
+
"env": {
|
|
87
|
+
"MAGICSWORD_BASE_URL": "https://www.magicsword.io"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
For **VS Code / Insiders**, run **MCP: Open User Configuration** and merge this
|
|
95
|
+
configuration (VS Code uses `servers`, not `mcpServers`):
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"servers": {
|
|
100
|
+
"magicsword": {
|
|
101
|
+
"type": "stdio",
|
|
102
|
+
"command": "npx",
|
|
103
|
+
"args": [
|
|
104
|
+
"-y",
|
|
105
|
+
"@magicsword-io/magicsword-mcp"
|
|
106
|
+
],
|
|
107
|
+
"env": {
|
|
108
|
+
"MAGICSWORD_BASE_URL": "https://www.magicsword.io"
|
|
109
|
+
}
|
|
52
110
|
}
|
|
53
111
|
}
|
|
54
112
|
}
|
|
55
113
|
```
|
|
56
114
|
|
|
57
|
-
Restart
|
|
58
|
-
|
|
115
|
+
Restart your client or start a new session, then ask it to call `whoami` and
|
|
116
|
+
`list_endpoints`. Both must succeed to verify authentication and read access.
|
|
117
|
+
|
|
118
|
+
The official MCP Registry identifier is
|
|
119
|
+
`io.github.magicsword-io/magicsword-mcp`. Client-specific details follow below.
|
|
120
|
+
|
|
121
|
+
## Configure
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
magicsword-mcp configure
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Setup asks for an API key with hidden input (mint one in **Magic Portal →
|
|
128
|
+
Settings → API Keys**) and which client to connect: Claude Desktop, Codex,
|
|
129
|
+
Claude Code, Cursor, or manual configuration. It saves the key only in
|
|
130
|
+
`~/.magicsword/mcp.json` (mode 600). The Portal defaults to
|
|
131
|
+
`https://www.magicsword.io`, replacing any saved preview origin. A custom
|
|
132
|
+
origin requires an explicit `--base-url` option.
|
|
133
|
+
|
|
134
|
+
Setup registers the selected client at its standard user-level location,
|
|
135
|
+
preserves other servers and settings, and creates a private backup of existing
|
|
136
|
+
client configuration. It updates an existing `magicsword` entry for JSON clients
|
|
137
|
+
and Codex. Claude Code requires that name to be available; use its own MCP
|
|
138
|
+
commands to remove an old registration before retrying. Codex and Claude Code
|
|
139
|
+
registration require their respective CLIs to be installed.
|
|
140
|
+
|
|
141
|
+
To choose a client directly, or reuse a saved key without prompting:
|
|
142
|
+
|
|
143
|
+
```sh
|
|
144
|
+
magicsword-mcp configure --client codex
|
|
145
|
+
magicsword-mcp configure --non-interactive --client claude-desktop
|
|
146
|
+
magicsword-mcp configure --client cursor --client-config /path/to/mcp.json
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The launch entry uses absolute Node and installed server paths so desktop apps
|
|
150
|
+
can start it without inheriting your terminal's PATH. Re-run setup if you move
|
|
151
|
+
your Node installation or install the package under a different Node version.
|
|
152
|
+
Manual setup prints a credential-free launch entry for other local stdio MCP
|
|
153
|
+
clients. Unattended setup without `--client` writes only the MagicSword file.
|
|
154
|
+
|
|
155
|
+
Restart the selected client or start a new session to load `magicsword` and its
|
|
156
|
+
21 tools. Ask it to call `whoami` and then `list_endpoints` to verify access;
|
|
157
|
+
discovery alone does not verify API-key scopes. Claude Desktop logs are at
|
|
158
|
+
`~/Library/Logs/Claude/mcp*.log` on macOS. Browser-only clients require a remote
|
|
159
|
+
MCP transport; this package provides a local stdio server.
|
|
59
160
|
|
|
60
161
|
If you need a per-client override instead of `~/.magicsword/mcp.json`, set
|
|
61
162
|
`MAGICSWORD_API_KEY` and optionally `MAGICSWORD_BASE_URL` in that MCP host's
|
|
@@ -165,7 +266,8 @@ npm run release:verify
|
|
|
165
266
|
node dist/index.js --version
|
|
166
267
|
```
|
|
167
268
|
|
|
168
|
-
Tests validate `--help`, `--version`,
|
|
269
|
+
Tests validate `--help`, `--version`, production-default migration, private client
|
|
270
|
+
registration, preservation and rollback, configure validation, secret redaction,
|
|
169
271
|
modern and legacy MCP startup, focused mutation confirmation, retry and timeout
|
|
170
272
|
semantics, response-size bounds, malformed responses, write non-retry behavior,
|
|
171
273
|
and npm pack contents. `test:package` installs a production-only tarball and
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { homedir, platform } from 'node:os';
|
|
4
|
+
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { spawnSync } from 'node:child_process';
|
|
7
|
+
export const CLIENTS = ['claude-desktop', 'codex', 'claude-code', 'cursor', 'manual'];
|
|
8
|
+
export function serverDefinition(credentialPath, baseUrl) {
|
|
9
|
+
return {
|
|
10
|
+
command: process.execPath,
|
|
11
|
+
args: [fileURLToPath(new URL('./index.js', import.meta.url))],
|
|
12
|
+
env: { MAGICSWORD_CONFIG: resolve(credentialPath), MAGICSWORD_BASE_URL: baseUrl },
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function clientConfigPath(client) {
|
|
16
|
+
if (client === 'cursor')
|
|
17
|
+
return join(homedir(), '.cursor', 'mcp.json');
|
|
18
|
+
if (client === 'codex')
|
|
19
|
+
return join(process.env.CODEX_HOME ?? join(homedir(), '.codex'), 'config.toml');
|
|
20
|
+
if (client === 'claude-code')
|
|
21
|
+
return process.env.CLAUDE_CONFIG_DIR ? join(process.env.CLAUDE_CONFIG_DIR, '.claude.json') : join(homedir(), '.claude.json');
|
|
22
|
+
if (platform() === 'darwin')
|
|
23
|
+
return join(homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
|
|
24
|
+
if (platform() === 'win32')
|
|
25
|
+
return join(process.env.APPDATA ?? join(homedir(), 'AppData', 'Roaming'), 'Claude', 'claude_desktop_config.json');
|
|
26
|
+
return join(homedir(), '.config', 'Claude', 'claude_desktop_config.json');
|
|
27
|
+
}
|
|
28
|
+
export function atomicPrivateWrite(target, contents) {
|
|
29
|
+
mkdirSync(dirname(target), { recursive: true, mode: 0o700 });
|
|
30
|
+
const temporary = `${target}.${randomUUID()}.tmp`;
|
|
31
|
+
try {
|
|
32
|
+
writeFileSync(temporary, contents, { encoding: 'utf8', flag: 'wx', mode: 0o600 });
|
|
33
|
+
renameSync(temporary, target);
|
|
34
|
+
if (platform() !== 'win32')
|
|
35
|
+
chmodSync(target, 0o600);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
rmSync(temporary, { force: true });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function object(value) {
|
|
42
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
43
|
+
}
|
|
44
|
+
function existingFile(target) {
|
|
45
|
+
if (!existsSync(target))
|
|
46
|
+
return undefined;
|
|
47
|
+
if (!lstatSync(target).isFile())
|
|
48
|
+
throw new Error('Client configuration must be a regular file.');
|
|
49
|
+
return readFileSync(target, 'utf8');
|
|
50
|
+
}
|
|
51
|
+
function backup(target, contents) {
|
|
52
|
+
if (contents !== undefined)
|
|
53
|
+
atomicPrivateWrite(`${target}.magicsword-backup.${randomUUID()}`, contents);
|
|
54
|
+
}
|
|
55
|
+
export function registerClient(client, definition, customPath) {
|
|
56
|
+
if (client === 'manual')
|
|
57
|
+
return undefined;
|
|
58
|
+
const target = customPath ? resolve(customPath) : clientConfigPath(client);
|
|
59
|
+
const old = existingFile(target);
|
|
60
|
+
let claudeConfig;
|
|
61
|
+
if (client === 'claude-code' && old !== undefined) {
|
|
62
|
+
let parsed;
|
|
63
|
+
try {
|
|
64
|
+
parsed = JSON.parse(old);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
throw new Error('Client configuration contains invalid JSON; no client settings were changed.');
|
|
68
|
+
}
|
|
69
|
+
if (!object(parsed) || (parsed.mcpServers !== undefined && !object(parsed.mcpServers))) {
|
|
70
|
+
throw new Error('Client configuration must contain an object with an optional mcpServers object.');
|
|
71
|
+
}
|
|
72
|
+
claudeConfig = parsed;
|
|
73
|
+
}
|
|
74
|
+
if (client === 'claude-desktop' || client === 'cursor') {
|
|
75
|
+
let parsed;
|
|
76
|
+
try {
|
|
77
|
+
parsed = old === undefined ? {} : JSON.parse(old);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
throw new Error('Client configuration contains invalid JSON; no client settings were changed.');
|
|
81
|
+
}
|
|
82
|
+
if (!object(parsed) || (parsed.mcpServers !== undefined && !object(parsed.mcpServers))) {
|
|
83
|
+
throw new Error('Client configuration must contain an object with an optional mcpServers object.');
|
|
84
|
+
}
|
|
85
|
+
backup(target, old);
|
|
86
|
+
atomicPrivateWrite(target, `${JSON.stringify({ ...parsed, mcpServers: { ...(parsed.mcpServers ?? {}), magicsword: definition } }, null, 2)}\n`);
|
|
87
|
+
return target;
|
|
88
|
+
}
|
|
89
|
+
backup(target, old);
|
|
90
|
+
const envArgs = Object.entries(definition.env).flatMap(([key, value]) => ['--env', `${key}=${value}`]);
|
|
91
|
+
const cli = client === 'codex' ? 'codex' : 'claude';
|
|
92
|
+
const args = client === 'codex'
|
|
93
|
+
? ['mcp', 'add', 'magicsword', ...envArgs, '--', definition.command, ...definition.args]
|
|
94
|
+
: ['mcp', 'add', '--scope', 'user', '--transport', 'stdio', 'magicsword', ...envArgs, '--', definition.command, ...definition.args];
|
|
95
|
+
// Never forward CLI output: it can contain existing configuration or secrets.
|
|
96
|
+
const result = spawnSync(cli, args, { encoding: 'utf8', timeout: 30_000, windowsHide: true, maxBuffer: 1024 * 1024 });
|
|
97
|
+
if (result.status !== 0) {
|
|
98
|
+
if (old !== undefined)
|
|
99
|
+
atomicPrivateWrite(target, old);
|
|
100
|
+
else
|
|
101
|
+
rmSync(target, { force: true });
|
|
102
|
+
throw new Error(`Could not register with ${client}. Ensure its CLI is installed and the magicsword name is available, then retry. Existing client settings were restored.`);
|
|
103
|
+
}
|
|
104
|
+
if (client === 'claude-code' && claudeConfig) {
|
|
105
|
+
// Preserve unrelated fields that the CLI may otherwise discard during migration.
|
|
106
|
+
try {
|
|
107
|
+
const updated = JSON.parse(readFileSync(target, 'utf8'));
|
|
108
|
+
if (!object(updated) || !object(updated.mcpServers) || !object(updated.mcpServers.magicsword))
|
|
109
|
+
throw new Error('Invalid CLI registration.');
|
|
110
|
+
atomicPrivateWrite(target, `${JSON.stringify({ ...updated, ...claudeConfig, mcpServers: { ...(claudeConfig.mcpServers ?? {}), magicsword: updated.mcpServers.magicsword } }, null, 2)}\n`);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
atomicPrivateWrite(target, old);
|
|
114
|
+
throw new Error('Could not verify Claude Code registration; existing client settings were restored.');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return target;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=client-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-setup.js","sourceRoot":"","sources":["../src/client-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACvH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,gBAAgB,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAI/F,MAAM,UAAU,gBAAgB,CAAC,cAAsB,EAAE,OAAe;IACtE,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,QAAQ;QACzB,IAAI,EAAE,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,C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,107 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { dirname, join } from 'node:path';
|
|
3
|
-
import { homedir, platform } from 'node:os';
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
4
2
|
import { createInterface } from 'node:readline/promises';
|
|
3
|
+
import { Writable } from 'node:stream';
|
|
5
4
|
import { stdin, stdout } from 'node:process';
|
|
6
|
-
import { configPath, DEFAULT_BASE_URL, isValidMagicSwordApiKey, normalizeBaseUrl
|
|
5
|
+
import { configPath, DEFAULT_BASE_URL, isValidMagicSwordApiKey, normalizeBaseUrl } from './config.js';
|
|
6
|
+
import { atomicPrivateWrite, CLIENTS, registerClient, serverDefinition } from './client-setup.js';
|
|
7
7
|
function parseArgs(args) {
|
|
8
8
|
const opts = {};
|
|
9
9
|
for (let i = 0; i < args.length; i += 1) {
|
|
10
10
|
const a = args[i];
|
|
11
|
+
if (a === '--non-interactive' || a === '-n') {
|
|
12
|
+
opts.nonInteractive = true;
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (!['--api-key', '-k', '--base-url', '-u', '--client', '--client-config'].includes(a))
|
|
16
|
+
throw new Error('Unknown configure option. Run magicsword-mcp --help.');
|
|
17
|
+
const value = args[++i];
|
|
18
|
+
if (!value || value.startsWith('--'))
|
|
19
|
+
throw new Error('Configure option requires a value.');
|
|
11
20
|
if (a === '--api-key' || a === '-k')
|
|
12
|
-
opts.apiKey =
|
|
21
|
+
opts.apiKey = value;
|
|
13
22
|
else if (a === '--base-url' || a === '-u')
|
|
14
|
-
opts.baseUrl =
|
|
15
|
-
else if (a === '--
|
|
16
|
-
opts.
|
|
23
|
+
opts.baseUrl = value;
|
|
24
|
+
else if (a === '--client-config')
|
|
25
|
+
opts.clientConfig = value;
|
|
26
|
+
else {
|
|
27
|
+
if (!CLIENTS.includes(value))
|
|
28
|
+
throw new Error(`Client must be one of: ${CLIENTS.join(', ')}.`);
|
|
29
|
+
opts.client = value;
|
|
30
|
+
}
|
|
17
31
|
}
|
|
32
|
+
if (opts.clientConfig && opts.client !== 'claude-desktop' && opts.client !== 'cursor')
|
|
33
|
+
throw new Error('--client-config requires --client claude-desktop or cursor.');
|
|
18
34
|
return opts;
|
|
19
35
|
}
|
|
20
|
-
async function prompt(question,
|
|
21
|
-
|
|
22
|
-
const
|
|
36
|
+
async function prompt(question, hidden = false) {
|
|
37
|
+
stdout.write(`${question}: `);
|
|
38
|
+
const muted = new Writable({ write(_chunk, _encoding, callback) { callback(); } });
|
|
39
|
+
const rl = createInterface({ input: stdin, output: hidden ? muted : stdout, terminal: Boolean(stdin.isTTY) });
|
|
23
40
|
try {
|
|
24
|
-
|
|
25
|
-
|
|
41
|
+
return (await new Promise((resolve, reject) => {
|
|
42
|
+
rl.once('SIGINT', () => { reject(new Error('Setup cancelled.')); rl.close(); });
|
|
43
|
+
rl.once('close', () => reject(new Error('Setup cancelled.')));
|
|
44
|
+
rl.question('').then(resolve, reject);
|
|
45
|
+
})).trim();
|
|
26
46
|
}
|
|
27
47
|
finally {
|
|
28
48
|
rl.close();
|
|
49
|
+
muted.destroy();
|
|
50
|
+
if (hidden)
|
|
51
|
+
stdout.write('\n');
|
|
29
52
|
}
|
|
30
53
|
}
|
|
31
|
-
function claudeDesktopConfigPath() {
|
|
32
|
-
// macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
|
|
33
|
-
// Linux: ~/.config/Claude/claude_desktop_config.json
|
|
34
|
-
// Windows: %APPDATA%\Claude\claude_desktop_config.json
|
|
35
|
-
const os = platform();
|
|
36
|
-
if (os === 'darwin') {
|
|
37
|
-
return join(homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
|
|
38
|
-
}
|
|
39
|
-
if (os === 'win32') {
|
|
40
|
-
return join(process.env.APPDATA ?? join(homedir(), 'AppData', 'Roaming'), 'Claude', 'claude_desktop_config.json');
|
|
41
|
-
}
|
|
42
|
-
return join(homedir(), '.config', 'Claude', 'claude_desktop_config.json');
|
|
43
|
-
}
|
|
44
|
-
function writeConfig(cfg) {
|
|
45
|
-
const target = configPath();
|
|
46
|
-
mkdirSync(dirname(target), { recursive: true, mode: 0o700 });
|
|
47
|
-
const temporary = `${target}.${process.pid}.tmp`;
|
|
48
|
-
try {
|
|
49
|
-
writeFileSync(temporary, `${JSON.stringify(cfg, null, 2)}\n`, {
|
|
50
|
-
encoding: 'utf8',
|
|
51
|
-
flag: 'wx',
|
|
52
|
-
mode: 0o600,
|
|
53
|
-
});
|
|
54
|
-
renameSync(temporary, target);
|
|
55
|
-
if (platform() !== 'win32') {
|
|
56
|
-
chmodSync(target, 0o600);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
finally {
|
|
60
|
-
rmSync(temporary, { force: true });
|
|
61
|
-
}
|
|
62
|
-
return target;
|
|
63
|
-
}
|
|
64
|
-
function snippetForClaudeDesktop() {
|
|
65
|
-
return JSON.stringify({
|
|
66
|
-
mcpServers: {
|
|
67
|
-
magicsword: {
|
|
68
|
-
command: 'magicsword-mcp',
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
}, null, 2);
|
|
72
|
-
}
|
|
73
54
|
export async function runConfigure(rawArgs) {
|
|
74
|
-
const opts = parseArgs(rawArgs);
|
|
75
|
-
let existingApiKey;
|
|
76
|
-
let existingBaseUrl;
|
|
77
55
|
try {
|
|
78
|
-
const
|
|
79
|
-
existingApiKey
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
let apiKey = opts.apiKey;
|
|
86
|
-
let baseUrl = opts.baseUrl;
|
|
87
|
-
if (!opts.nonInteractive) {
|
|
88
|
-
if (!apiKey) {
|
|
89
|
-
const suffix = existingApiKey ? ` (press Enter to keep current ${existingApiKey.slice(0, 8)}...)` : '';
|
|
90
|
-
const answered = await prompt(`MagicSword API key${suffix}`);
|
|
91
|
-
apiKey = answered.trim() || existingApiKey;
|
|
56
|
+
const opts = parseArgs(rawArgs);
|
|
57
|
+
let existingApiKey;
|
|
58
|
+
try {
|
|
59
|
+
const existing = JSON.parse(readFileSync(configPath(), 'utf8'));
|
|
60
|
+
if (typeof existing?.apiKey === 'string')
|
|
61
|
+
existingApiKey = existing.apiKey;
|
|
92
62
|
}
|
|
93
|
-
|
|
94
|
-
|
|
63
|
+
catch { /* Missing credentials can be supplied below. */ }
|
|
64
|
+
let apiKey = opts.apiKey ?? process.env.MAGICSWORD_API_KEY;
|
|
65
|
+
let client = opts.client;
|
|
66
|
+
if (!opts.nonInteractive) {
|
|
67
|
+
if (!apiKey) {
|
|
68
|
+
if (!stdin.isTTY)
|
|
69
|
+
throw new Error('Interactive setup requires a terminal. Use --non-interactive with MAGICSWORD_API_KEY instead.');
|
|
70
|
+
apiKey = await prompt(`MagicSword API key (hidden${existingApiKey ? '; Enter keeps saved key' : ''})`, true) || existingApiKey;
|
|
71
|
+
}
|
|
72
|
+
if (!client) {
|
|
73
|
+
stdout.write('\nWhere should MagicSword be connected?\n 1. Claude Desktop\n 2. Codex (app / CLI / IDE)\n 3. Claude Code\n 4. Cursor\n 5. Manual configuration\n');
|
|
74
|
+
const choice = await prompt('Choose 1–5');
|
|
75
|
+
const index = Number(choice) - 1;
|
|
76
|
+
if (!Number.isInteger(index) || index < 0 || index >= CLIENTS.length)
|
|
77
|
+
throw new Error('Choose a client from 1 to 5, or use --client.');
|
|
78
|
+
client = CLIENTS[index];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else
|
|
82
|
+
apiKey ??= existingApiKey;
|
|
83
|
+
if (!isValidMagicSwordApiKey(apiKey))
|
|
84
|
+
throw new Error('A valid MagicSword API key (starting with msk_) is required. Mint one in Magic Portal → Settings → API Keys.');
|
|
85
|
+
const baseUrl = normalizeBaseUrl(opts.baseUrl ?? DEFAULT_BASE_URL);
|
|
86
|
+
const path = configPath();
|
|
87
|
+
const cfg = { apiKey: apiKey.trim(), baseUrl };
|
|
88
|
+
atomicPrivateWrite(path, `${JSON.stringify(cfg, null, 2)}\n`);
|
|
89
|
+
stdout.write(`\nSaved private MagicSword credentials to ${path} (mode 600).\n`);
|
|
90
|
+
if (!opts.baseUrl)
|
|
91
|
+
stdout.write(`Portal: ${DEFAULT_BASE_URL}\n`);
|
|
92
|
+
const definition = serverDefinition(path, baseUrl);
|
|
93
|
+
const target = registerClient(client ?? 'manual', definition, opts.clientConfig);
|
|
94
|
+
if (target) {
|
|
95
|
+
stdout.write(`Registered magicsword with ${client} in ${target}.\nRestart the client or start a new session to load its 21 tools.\n`);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
stdout.write('\nChoose --client claude-desktop, codex, claude-code, or cursor to register automatically.\nFor another local stdio MCP client, merge this entry into its configuration:\n');
|
|
99
|
+
stdout.write(`${JSON.stringify({ mcpServers: { magicsword: definition } }, null, 2)}\n`);
|
|
95
100
|
}
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
apiKey = apiKey ?? existingApiKey;
|
|
99
|
-
baseUrl = baseUrl ?? existingBaseUrl ?? DEFAULT_BASE_URL;
|
|
100
|
-
}
|
|
101
|
-
if (!isValidMagicSwordApiKey(apiKey)) {
|
|
102
|
-
process.stderr.write('A valid MagicSword API key (starting with msk_) is required.\n' +
|
|
103
|
-
'Mint one in Magic Portal → Settings → API Keys.\n');
|
|
104
|
-
process.exit(2);
|
|
105
|
-
}
|
|
106
|
-
let normalizedBaseUrl;
|
|
107
|
-
try {
|
|
108
|
-
normalizedBaseUrl = normalizeBaseUrl(baseUrl || DEFAULT_BASE_URL);
|
|
109
101
|
}
|
|
110
102
|
catch (error) {
|
|
111
|
-
process.stderr.write(`${error instanceof Error ? error.message :
|
|
112
|
-
process.
|
|
103
|
+
process.stderr.write(`${error instanceof Error ? error.message : 'Setup failed.'}\n`);
|
|
104
|
+
process.exitCode = 2;
|
|
113
105
|
}
|
|
114
|
-
const cfg = {
|
|
115
|
-
apiKey: apiKey.trim(),
|
|
116
|
-
baseUrl: normalizedBaseUrl,
|
|
117
|
-
};
|
|
118
|
-
const path = writeConfig(cfg);
|
|
119
|
-
process.stdout.write(`\nWrote ${path} (mode 600)\n\n`);
|
|
120
|
-
process.stdout.write('Add this block to your Claude Desktop config:\n');
|
|
121
|
-
process.stdout.write(` ${claudeDesktopConfigPath()}\n\n`);
|
|
122
|
-
process.stdout.write(`${snippetForClaudeDesktop()}\n\n`);
|
|
123
|
-
process.stdout.write('Then restart Claude Desktop. The MCP server will appear as "magicsword" with 21 tools.\n');
|
|
124
106
|
}
|
|
125
107
|
//# sourceMappingURL=configure.js.map
|
package/dist/configure.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,gBAAgB,EAA+B,MAAM,aAAa,CAAC;AACnI,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AAUpH,SAAS,SAAS,CAAC,IAAc;IAC/B,MAAM,IAAI,GAAqB,EAAE,CAAC;IAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,IAAI,CAAC,KAAK,mBAAmB,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAAC,IAAI,CAAC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,OAAO,CAAC,CAAC,CAAC,eAAe,IAAI,CAAC,CAAC;QACtF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,11 @@ function printHelp() {
|
|
|
26
26
|
'',
|
|
27
27
|
'Usage:',
|
|
28
28
|
' magicsword-mcp Start the MCP server over stdio (for Claude Desktop, Cursor, etc.)',
|
|
29
|
-
' magicsword-mcp configure
|
|
29
|
+
' magicsword-mcp configure Save private credentials and choose an MCP client',
|
|
30
|
+
' --client <name> claude-desktop, codex, claude-code, cursor, or manual',
|
|
31
|
+
' --client-config <path> Custom JSON config path (Claude Desktop / Cursor)',
|
|
32
|
+
' --base-url <origin> Explicit custom Portal origin; setup defaults to production',
|
|
33
|
+
' --non-interactive Use saved key or MAGICSWORD_API_KEY without prompting',
|
|
30
34
|
' magicsword-mcp --version Print version',
|
|
31
35
|
' magicsword-mcp --help Print this help',
|
|
32
36
|
'',
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEhE,SAAS,kBAAkB;IACzB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YA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C;IACpG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicsword-io/magicsword-mcp",
|
|
3
3
|
"mcpName": "io.github.magicsword-io/magicsword-mcp",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"description": "MagicSword MCP server — manage MagicSword conversationally from Claude Desktop, Cursor, or any MCP-aware client.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"build": "tsc -p tsconfig.json && node scripts/postbuild.mjs",
|
|
24
24
|
"start": "node dist/index.js",
|
|
25
25
|
"configure": "node dist/index.js configure",
|
|
26
|
-
"test": "npm run build && node --test scripts/verify-release.test.mjs && node scripts/client.mjs && node scripts/smoke.mjs",
|
|
26
|
+
"test": "npm run build && node --test scripts/verify-release.test.mjs scripts/configure.test.mjs scripts/install-links.test.mjs && node scripts/client.mjs && node scripts/smoke.mjs",
|
|
27
27
|
"test:package": "npm run build && node scripts/package-smoke.mjs",
|
|
28
28
|
"version": "node scripts/sync-registry-version.mjs",
|
|
29
29
|
"release:sync": "node scripts/sync-registry-version.mjs",
|