inistate-mcp 1.0.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/LICENSE +190 -0
- package/README.md +255 -0
- package/build/activity-guard.js +261 -0
- package/build/api.js +181 -0
- package/build/context.js +2 -0
- package/build/http.js +146 -0
- package/build/index.js +21 -0
- package/build/mode-store.js +25 -0
- package/build/oauth-provider.js +237 -0
- package/build/prompts.js +172 -0
- package/build/resources.js +104 -0
- package/build/schema.js +505 -0
- package/build/server.js +76 -0
- package/build/setup.js +233 -0
- package/build/tools.js +988 -0
- package/package.json +77 -0
- package/server.json +42 -0
package/build/setup.js
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import readline from "node:readline/promises";
|
|
2
|
+
import { stdin, stdout } from "node:process";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
function getClients() {
|
|
7
|
+
const home = os.homedir();
|
|
8
|
+
const platform = process.platform;
|
|
9
|
+
const appData = process.env.APPDATA ?? path.join(home, "AppData", "Roaming");
|
|
10
|
+
const xdgConfig = process.env.XDG_CONFIG_HOME ?? path.join(home, ".config");
|
|
11
|
+
let claudeDesktopPath;
|
|
12
|
+
let vscodeUserDir;
|
|
13
|
+
if (platform === "win32") {
|
|
14
|
+
claudeDesktopPath = path.join(appData, "Claude", "claude_desktop_config.json");
|
|
15
|
+
vscodeUserDir = path.join(appData, "Code", "User");
|
|
16
|
+
}
|
|
17
|
+
else if (platform === "darwin") {
|
|
18
|
+
claudeDesktopPath = path.join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json");
|
|
19
|
+
vscodeUserDir = path.join(home, "Library", "Application Support", "Code", "User");
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
claudeDesktopPath = path.join(xdgConfig, "Claude", "claude_desktop_config.json");
|
|
23
|
+
vscodeUserDir = path.join(xdgConfig, "Code", "User");
|
|
24
|
+
}
|
|
25
|
+
const clinePath = path.join(vscodeUserDir, "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json");
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
id: "claude",
|
|
29
|
+
label: "Claude Desktop",
|
|
30
|
+
configPath: claudeDesktopPath,
|
|
31
|
+
configKey: "mcpServers",
|
|
32
|
+
postInstallNote: "Restart Claude Desktop to load the server.",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "claude-code",
|
|
36
|
+
label: "Claude Code (global)",
|
|
37
|
+
configPath: path.join(home, ".claude.json"),
|
|
38
|
+
configKey: "mcpServers",
|
|
39
|
+
postInstallNote: "Run `claude` to start a session with the new server.",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "claude-code-local",
|
|
43
|
+
label: "Claude Code (project .mcp.json)",
|
|
44
|
+
configPath: path.join(process.cwd(), ".mcp.json"),
|
|
45
|
+
configKey: "mcpServers",
|
|
46
|
+
postInstallNote: "Commit .mcp.json to share with your team.",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "cursor",
|
|
50
|
+
label: "Cursor",
|
|
51
|
+
configPath: path.join(home, ".cursor", "mcp.json"),
|
|
52
|
+
configKey: "mcpServers",
|
|
53
|
+
postInstallNote: "Restart Cursor to load the server.",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "windsurf",
|
|
57
|
+
label: "Windsurf",
|
|
58
|
+
configPath: path.join(home, ".codeium", "windsurf", "mcp_config.json"),
|
|
59
|
+
configKey: "mcpServers",
|
|
60
|
+
postInstallNote: "Restart Windsurf to load the server.",
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: "codex",
|
|
64
|
+
label: "Codex CLI",
|
|
65
|
+
configPath: path.join(process.env.CODEX_HOME ?? path.join(home, ".codex"), "config.toml"),
|
|
66
|
+
configKey: "mcp_servers",
|
|
67
|
+
format: "toml",
|
|
68
|
+
postInstallNote: "Restart Codex to load the server.",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: "vscode",
|
|
72
|
+
label: "VS Code (user profile)",
|
|
73
|
+
configPath: path.join(vscodeUserDir, "mcp.json"),
|
|
74
|
+
configKey: "servers",
|
|
75
|
+
postInstallNote: "VS Code picks up changes automatically. Run \"MCP: List Servers\" to verify.",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "vscode-workspace",
|
|
79
|
+
label: "VS Code (workspace .vscode/mcp.json)",
|
|
80
|
+
configPath: path.join(process.cwd(), ".vscode", "mcp.json"),
|
|
81
|
+
configKey: "servers",
|
|
82
|
+
postInstallNote: "Commit .vscode/mcp.json to share with your team. Open the workspace in VS Code to load it.",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "cline",
|
|
86
|
+
label: "Cline (VS Code extension)",
|
|
87
|
+
configPath: clinePath,
|
|
88
|
+
configKey: "mcpServers",
|
|
89
|
+
postInstallNote: "Reload the Cline panel in VS Code to pick up the new server.",
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: "gemini-cli",
|
|
93
|
+
label: "Gemini CLI (global)",
|
|
94
|
+
configPath: path.join(home, ".gemini", "settings.json"),
|
|
95
|
+
configKey: "mcpServers",
|
|
96
|
+
postInstallNote: "Restart Gemini CLI to load the server.",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: "gemini-cli-workspace",
|
|
100
|
+
label: "Gemini CLI (workspace .gemini/settings.json)",
|
|
101
|
+
configPath: path.join(process.cwd(), ".gemini", "settings.json"),
|
|
102
|
+
configKey: "mcpServers",
|
|
103
|
+
postInstallNote: "Commit .gemini/settings.json to share with your team.",
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
async function readClientConfig(client) {
|
|
108
|
+
if (!fs.existsSync(client.configPath))
|
|
109
|
+
return {};
|
|
110
|
+
const raw = fs.readFileSync(client.configPath, "utf8");
|
|
111
|
+
try {
|
|
112
|
+
if (client.format === "toml") {
|
|
113
|
+
const TOML = await import("@iarna/toml");
|
|
114
|
+
return TOML.parse(raw);
|
|
115
|
+
}
|
|
116
|
+
return JSON.parse(raw);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async function writeClientConfig(client, config) {
|
|
123
|
+
let body;
|
|
124
|
+
if (client.format === "toml") {
|
|
125
|
+
const TOML = await import("@iarna/toml");
|
|
126
|
+
body = TOML.stringify(config);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
body = `${JSON.stringify(config, null, 2)}\n`;
|
|
130
|
+
}
|
|
131
|
+
fs.writeFileSync(client.configPath, body);
|
|
132
|
+
}
|
|
133
|
+
async function ask(rl, prompt, fallback) {
|
|
134
|
+
const suffix = fallback ? ` [${fallback}]` : "";
|
|
135
|
+
const answer = (await rl.question(`${prompt}${suffix}: `)).trim();
|
|
136
|
+
return answer || fallback || "";
|
|
137
|
+
}
|
|
138
|
+
function yes(answer) {
|
|
139
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
140
|
+
}
|
|
141
|
+
export async function runSetup() {
|
|
142
|
+
const rl = readline.createInterface({ input: stdin, output: stdout });
|
|
143
|
+
console.log();
|
|
144
|
+
console.log("Inistate MCP — interactive setup");
|
|
145
|
+
console.log("──────────────────────────────────");
|
|
146
|
+
console.log();
|
|
147
|
+
try {
|
|
148
|
+
let token = process.env.INISTATE_API_TOKEN ?? "";
|
|
149
|
+
if (token) {
|
|
150
|
+
const masked = token.length > 8
|
|
151
|
+
? `${token.slice(0, 4)}…${token.slice(-4)}`
|
|
152
|
+
: "***";
|
|
153
|
+
const reuse = await ask(rl, `Existing INISTATE_API_TOKEN detected (${masked}). Use it? (y/n)`, "y");
|
|
154
|
+
if (!yes(reuse))
|
|
155
|
+
token = "";
|
|
156
|
+
}
|
|
157
|
+
while (!token) {
|
|
158
|
+
token = (await rl.question("Enter your Inistate API token: ")).trim();
|
|
159
|
+
if (!token)
|
|
160
|
+
console.log(" Token cannot be empty.");
|
|
161
|
+
}
|
|
162
|
+
const apiBase = await ask(rl, "API base URL", process.env.INISTATE_API_BASE ?? "https://api.inistate.com");
|
|
163
|
+
const clients = getClients();
|
|
164
|
+
console.log();
|
|
165
|
+
console.log("Choose an MCP client to configure:");
|
|
166
|
+
clients.forEach((c, i) => console.log(` ${i + 1}. ${c.label}`));
|
|
167
|
+
console.log(` ${clients.length + 1}. Print config only (don't write)`);
|
|
168
|
+
console.log();
|
|
169
|
+
const rawChoice = await ask(rl, "Select", "1");
|
|
170
|
+
const choice = Number.parseInt(rawChoice, 10);
|
|
171
|
+
if (Number.isNaN(choice) ||
|
|
172
|
+
choice < 1 ||
|
|
173
|
+
choice > clients.length + 1) {
|
|
174
|
+
console.error("Invalid choice.");
|
|
175
|
+
process.exitCode = 1;
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const env = { INISTATE_API_TOKEN: token };
|
|
179
|
+
if (apiBase && apiBase !== "https://api.inistate.com") {
|
|
180
|
+
env.INISTATE_API_BASE = apiBase;
|
|
181
|
+
}
|
|
182
|
+
const serverEntry = {
|
|
183
|
+
command: "npx",
|
|
184
|
+
args: ["-y", "inistate-mcp"],
|
|
185
|
+
env,
|
|
186
|
+
};
|
|
187
|
+
if (choice === clients.length + 1) {
|
|
188
|
+
console.log();
|
|
189
|
+
console.log("Add this block to your client's MCP config:");
|
|
190
|
+
console.log();
|
|
191
|
+
console.log(JSON.stringify({ mcpServers: { inistate: serverEntry } }, null, 2));
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const client = clients[choice - 1];
|
|
195
|
+
const configDir = path.dirname(client.configPath);
|
|
196
|
+
if (!fs.existsSync(configDir)) {
|
|
197
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
198
|
+
}
|
|
199
|
+
let config = await readClientConfig(client);
|
|
200
|
+
if (config === null) {
|
|
201
|
+
const overwrite = await ask(rl, `Could not parse ${client.configPath}. Overwrite? (y/n)`, "n");
|
|
202
|
+
if (!yes(overwrite)) {
|
|
203
|
+
console.error("Aborting — fix the config file and re-run setup.");
|
|
204
|
+
process.exitCode = 1;
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
config = {};
|
|
208
|
+
}
|
|
209
|
+
let servers = config[client.configKey];
|
|
210
|
+
if (!servers || typeof servers !== "object") {
|
|
211
|
+
servers = {};
|
|
212
|
+
config[client.configKey] = servers;
|
|
213
|
+
}
|
|
214
|
+
const serversObj = servers;
|
|
215
|
+
if (serversObj.inistate) {
|
|
216
|
+
const overwrite = await ask(rl, `An "inistate" entry already exists in ${client.label}. Overwrite? (y/n)`, "y");
|
|
217
|
+
if (!yes(overwrite)) {
|
|
218
|
+
console.log("Aborted — existing entry kept.");
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
serversObj.inistate = serverEntry;
|
|
223
|
+
await writeClientConfig(client, config);
|
|
224
|
+
console.log();
|
|
225
|
+
console.log(`Wrote ${client.configPath}`);
|
|
226
|
+
if (client.postInstallNote) {
|
|
227
|
+
console.log(client.postInstallNote);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
finally {
|
|
231
|
+
rl.close();
|
|
232
|
+
}
|
|
233
|
+
}
|