finhay-mcp-server 1.1.0 → 1.1.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/dist/install.js +31 -17
- package/package.json +1 -1
package/dist/install.js
CHANGED
|
@@ -123,13 +123,17 @@ function updateClaudeConfig() {
|
|
|
123
123
|
args: ['-y', 'finhay-mcp-server'],
|
|
124
124
|
};
|
|
125
125
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
|
|
126
|
-
|
|
126
|
+
return configPath;
|
|
127
127
|
}
|
|
128
128
|
async function main() {
|
|
129
129
|
console.log('\n Finhay MCP Server — Cai dat cho Claude Desktop\n');
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
// --- Step 1: Node.js — checked by the wrapper / npx; nothing to do here ---
|
|
131
|
+
// --- Step 2: Claude Desktop config ---
|
|
132
|
+
const configPath = updateClaudeConfig();
|
|
133
|
+
console.log();
|
|
134
|
+
console.log(`Cai dat config Finhay MCP Claude Desktop thanh cong ${configPath}`);
|
|
135
|
+
console.log();
|
|
136
|
+
let credsAction = 'create';
|
|
133
137
|
if (fs.existsSync(CREDENTIALS_PATH)) {
|
|
134
138
|
const content = fs.readFileSync(CREDENTIALS_PATH, 'utf-8');
|
|
135
139
|
const keyMatch = content.match(/FINHAY_API_KEY=(.+)/);
|
|
@@ -138,23 +142,24 @@ async function main() {
|
|
|
138
142
|
const maskedKey = keyMatch[1].trim().slice(0, 8) + '***';
|
|
139
143
|
console.log(` Tim thay credentials tai ${CREDENTIALS_PATH}`);
|
|
140
144
|
console.log(` API Key: ${maskedKey}\n`);
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
apiKey = keyMatch[1].trim();
|
|
144
|
-
apiSecret = secretMatch[1].trim();
|
|
145
|
-
}
|
|
145
|
+
const replace = await ask('Ban co muon thay the khong? (y/n): ');
|
|
146
|
+
credsAction = replace.toLowerCase() === 'y' ? 'update' : 'reuse';
|
|
146
147
|
console.log();
|
|
147
148
|
}
|
|
148
149
|
}
|
|
149
|
-
if (
|
|
150
|
-
apiKey =
|
|
150
|
+
if (credsAction === 'create' || credsAction === 'update') {
|
|
151
|
+
const apiKey = credsAction === 'update'
|
|
152
|
+
? await ask('Nhap API Key moi: ')
|
|
153
|
+
: await ask('Nhap API Key: ');
|
|
151
154
|
if (!apiKey) {
|
|
152
155
|
console.error('\n Loi: API Key khong duoc de trong.\n');
|
|
153
156
|
process.exit(1);
|
|
154
157
|
}
|
|
155
|
-
apiSecret =
|
|
158
|
+
const apiSecret = credsAction === 'update'
|
|
159
|
+
? await askMasked('Nhap Secret Key moi: ')
|
|
160
|
+
: await askMasked('Nhap Secret Key: ');
|
|
156
161
|
if (!apiSecret) {
|
|
157
|
-
console.error('\n Loi:
|
|
162
|
+
console.error('\n Loi: Secret Key khong duoc de trong.\n');
|
|
158
163
|
process.exit(1);
|
|
159
164
|
}
|
|
160
165
|
upsertEnvFile(CREDENTIALS_PATH, {
|
|
@@ -162,11 +167,20 @@ async function main() {
|
|
|
162
167
|
FINHAY_API_SECRET: apiSecret,
|
|
163
168
|
FINHAY_BASE_URL: 'https://open-api.fhsc.com.vn',
|
|
164
169
|
});
|
|
165
|
-
console.log(`\n Credentials: ${CREDENTIALS_PATH} (permission: 600)\n`);
|
|
166
170
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
console.log();
|
|
172
|
+
if (credsAction === 'create') {
|
|
173
|
+
console.log(`Tao Credentials thanh cong tai ${CREDENTIALS_PATH}`);
|
|
174
|
+
}
|
|
175
|
+
else if (credsAction === 'update') {
|
|
176
|
+
console.log(`Cap nhat Credentials thanh cong tai ${CREDENTIALS_PATH}`);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
console.log(`Su dung credentials hien co tai ${CREDENTIALS_PATH}`);
|
|
180
|
+
}
|
|
181
|
+
console.log();
|
|
182
|
+
console.log('Hay khoi dong lai ung dung de su dung');
|
|
183
|
+
console.log();
|
|
170
184
|
}
|
|
171
185
|
export const run = main().catch((err) => {
|
|
172
186
|
console.error('Loi:', err.message);
|