langchain-mcp 1.0.1 → 1.0.3
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/bin/cli.js +60 -14
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -6,6 +6,24 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
|
6
6
|
import { loadConfig, saveConfig, deleteConfig, getConfigPath, DEFAULT_API_URL } from '../src/config.js';
|
|
7
7
|
import { APIClient } from '../src/api-client.js';
|
|
8
8
|
import { createServer } from '../src/server.js';
|
|
9
|
+
// ASCII Art Banner - Generated with oh-my-logo (shade style)
|
|
10
|
+
function printBanner() {
|
|
11
|
+
const green = '\x1b[32m';
|
|
12
|
+
const reset = '\x1b[0m';
|
|
13
|
+
console.log(`
|
|
14
|
+
${green}░█░░░░░██░░█░░█░░███░████░█░░█░░██░░███░█░░█░░░░░░█░░█░████░███░
|
|
15
|
+
░█░░░░█ █░██░█░█ ░█ ░█░░█░█ █░ █ ░██░█░░░░░░████░█ ░█ █
|
|
16
|
+
░█░░░░████░█ ██░█░██░█░░░░████░████░░█░░█ ██░████░█ █░█░░░░███░
|
|
17
|
+
░█░░░░█ █░█░ █░█░ █░█░░░░█ █░█ █░░█░░█░ █░ ░█░░█░█░░░░█░░░
|
|
18
|
+
░████░█░░█░█░░█░███░░████░█░░█░█░░█░███░█░░█░░░░░░█░░█░████░█░░░${reset}
|
|
19
|
+
`);
|
|
20
|
+
}
|
|
21
|
+
function printDivider(char = '─', length = 70) {
|
|
22
|
+
console.log('\x1b[90m' + char.repeat(length) + '\x1b[0m');
|
|
23
|
+
}
|
|
24
|
+
function printSection(title) {
|
|
25
|
+
console.log(`\n\x1b[1m\x1b[33m${title}\x1b[0m`); // Bold yellow
|
|
26
|
+
}
|
|
9
27
|
const program = new Command();
|
|
10
28
|
program
|
|
11
29
|
.name('langchain-mcp')
|
|
@@ -82,9 +100,20 @@ async function loginWithWebFlow(apiUrl, provider, openBrowser) {
|
|
|
82
100
|
api_url: apiUrl,
|
|
83
101
|
user,
|
|
84
102
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
console.log(
|
|
103
|
+
printBanner();
|
|
104
|
+
printDivider();
|
|
105
|
+
console.log('\n \x1b[32m✓ Login Successful!\x1b[0m\n');
|
|
106
|
+
printSection('👤 User');
|
|
107
|
+
console.log(` Name: ${user.name || 'N/A'}`);
|
|
108
|
+
console.log(` Email: ${user.email}`);
|
|
109
|
+
printSection('💰 Credits');
|
|
110
|
+
const creditColor = user.credits > 5 ? '\x1b[32m' : user.credits > 1 ? '\x1b[33m' : '\x1b[31m';
|
|
111
|
+
console.log(` Remaining: ${creditColor}$${user.credits.toFixed(2)}\x1b[0m`);
|
|
112
|
+
printSection('⚙️ Config');
|
|
113
|
+
console.log(` Saved to: ${getConfigPath()}`);
|
|
114
|
+
console.log('');
|
|
115
|
+
printDivider();
|
|
116
|
+
console.log('');
|
|
88
117
|
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
89
118
|
res.end(`
|
|
90
119
|
<!DOCTYPE html>
|
|
@@ -160,26 +189,43 @@ program
|
|
|
160
189
|
.description('Show current login status and usage')
|
|
161
190
|
.action(async () => {
|
|
162
191
|
const config = loadConfig();
|
|
192
|
+
printBanner();
|
|
193
|
+
printDivider();
|
|
163
194
|
if (!config) {
|
|
164
|
-
console.log('
|
|
165
|
-
console.log('Run
|
|
195
|
+
console.log('\n \x1b[31m✗ Not logged in\x1b[0m');
|
|
196
|
+
console.log(' Run \x1b[36mlangchain-mcp login\x1b[0m to get started.\n');
|
|
166
197
|
return;
|
|
167
198
|
}
|
|
168
|
-
|
|
169
|
-
|
|
199
|
+
// User Info Section
|
|
200
|
+
printSection('👤 User');
|
|
201
|
+
console.log(` Name: ${config.user?.name || 'N/A'}`);
|
|
202
|
+
console.log(` Email: ${config.user?.email || 'Unknown'}`);
|
|
203
|
+
console.log(` ID: ${config.user?.id || 'N/A'}`);
|
|
170
204
|
try {
|
|
171
205
|
const client = new APIClient(config.api_url, config.api_key);
|
|
172
206
|
const usage = await client.getUsage();
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
console.log(`
|
|
207
|
+
// Credits Section
|
|
208
|
+
printSection('💰 Credits');
|
|
209
|
+
const remaining = usage.credits.remaining;
|
|
210
|
+
const creditColor = remaining > 5 ? '\x1b[32m' : remaining > 1 ? '\x1b[33m' : '\x1b[31m';
|
|
211
|
+
console.log(` Remaining: ${creditColor}$${remaining.toFixed(2)}\x1b[0m`);
|
|
212
|
+
// Token Usage Section
|
|
213
|
+
printSection('📊 Token Usage');
|
|
214
|
+
console.log(` Today: ${usage.usage.today.tokens.toLocaleString().padStart(12)} tokens (${usage.usage.today.requests} requests)`);
|
|
215
|
+
console.log(` This Month: ${usage.usage.this_month.tokens.toLocaleString().padStart(12)} tokens (${usage.usage.this_month.requests} requests)`);
|
|
216
|
+
console.log(` All Time: ${usage.usage.all_time.tokens.toLocaleString().padStart(12)} tokens (${usage.usage.all_time.requests} requests)`);
|
|
217
|
+
// Config Section
|
|
218
|
+
printSection('⚙️ Config');
|
|
219
|
+
console.log(` Path: ${getConfigPath()}`);
|
|
220
|
+
console.log(` API: ${config.api_url}`);
|
|
178
221
|
}
|
|
179
222
|
catch (error) {
|
|
180
|
-
console.log(`\n⚠️ Could not fetch usage: ${error.message}`);
|
|
181
|
-
console.log('Your API key may be invalid. Run
|
|
223
|
+
console.log(`\n \x1b[33m⚠️ Could not fetch usage: ${error.message}\x1b[0m`);
|
|
224
|
+
console.log(' Your API key may be invalid. Run \x1b[36mlangchain-mcp login\x1b[0m again.');
|
|
182
225
|
}
|
|
226
|
+
console.log('');
|
|
227
|
+
printDivider();
|
|
228
|
+
console.log('');
|
|
183
229
|
});
|
|
184
230
|
/**
|
|
185
231
|
* Logout command - remove local credentials
|