@nanogpt/mcp 1.0.0
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/activeRequests.d.ts +26 -0
- package/dist/activeRequests.d.ts.map +1 -0
- package/dist/activeRequests.js +39 -0
- package/dist/activeRequests.js.map +1 -0
- package/dist/config.d.ts +35 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +136 -0
- package/dist/config.js.map +1 -0
- package/dist/httpClient.d.ts +36 -0
- package/dist/httpClient.d.ts.map +1 -0
- package/dist/httpClient.js +211 -0
- package/dist/httpClient.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +168 -0
- package/dist/index.js.map +1 -0
- package/dist/resources.d.ts +68 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +198 -0
- package/dist/resources.js.map +1 -0
- package/dist/toolUtils.d.ts +115 -0
- package/dist/toolUtils.d.ts.map +1 -0
- package/dist/toolUtils.js +369 -0
- package/dist/toolUtils.js.map +1 -0
- package/dist/tools/balance.d.ts +48 -0
- package/dist/tools/balance.d.ts.map +1 -0
- package/dist/tools/balance.js +78 -0
- package/dist/tools/balance.js.map +1 -0
- package/dist/tools/chat.d.ts +89 -0
- package/dist/tools/chat.d.ts.map +1 -0
- package/dist/tools/chat.js +125 -0
- package/dist/tools/chat.js.map +1 -0
- package/dist/tools/imageGenerate.d.ts +116 -0
- package/dist/tools/imageGenerate.d.ts.map +1 -0
- package/dist/tools/imageGenerate.js +220 -0
- package/dist/tools/imageGenerate.js.map +1 -0
- package/dist/tools/index.d.ts +11 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +11 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/listModels.d.ts +149 -0
- package/dist/tools/listModels.d.ts.map +1 -0
- package/dist/tools/listModels.js +224 -0
- package/dist/tools/listModels.js.map +1 -0
- package/dist/tools/scrapeUrls.d.ts +51 -0
- package/dist/tools/scrapeUrls.d.ts.map +1 -0
- package/dist/tools/scrapeUrls.js +100 -0
- package/dist/tools/scrapeUrls.js.map +1 -0
- package/dist/tools/webSearch.d.ts +69 -0
- package/dist/tools/webSearch.d.ts.map +1 -0
- package/dist/tools/webSearch.js +120 -0
- package/dist/tools/webSearch.js.map +1 -0
- package/dist/tools/youtubeTranscribe.d.ts +45 -0
- package/dist/tools/youtubeTranscribe.d.ts.map +1 -0
- package/dist/tools/youtubeTranscribe.js +88 -0
- package/dist/tools/youtubeTranscribe.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common utilities for tool handlers
|
|
3
|
+
*
|
|
4
|
+
* WARNING: The zodTypeToJsonSchema function accesses Zod internal structures (_def)
|
|
5
|
+
* which are not part of Zod's public API and may break with Zod updates.
|
|
6
|
+
* Consider switching to a maintained converter like 'zod-to-json-schema' package
|
|
7
|
+
* for production use with full Zod type coverage.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
|
|
11
|
+
import { isHttpError, formatErrorMessage } from './httpClient.js';
|
|
12
|
+
import { getConfig } from './config.js';
|
|
13
|
+
import { putRawText } from './resources.js';
|
|
14
|
+
/**
|
|
15
|
+
* Map HTTP error to MCP error
|
|
16
|
+
*/
|
|
17
|
+
export function httpErrorToMcpError(err) {
|
|
18
|
+
const message = formatErrorMessage(err);
|
|
19
|
+
switch (err.status) {
|
|
20
|
+
case 400:
|
|
21
|
+
return new McpError(ErrorCode.InvalidParams, message);
|
|
22
|
+
case 401:
|
|
23
|
+
case 402:
|
|
24
|
+
case 403:
|
|
25
|
+
return new McpError(ErrorCode.InvalidRequest, message);
|
|
26
|
+
case 429:
|
|
27
|
+
// MCP SDK doesn't have RateLimited, use InvalidRequest
|
|
28
|
+
return new McpError(ErrorCode.InvalidRequest, message);
|
|
29
|
+
case 408:
|
|
30
|
+
case 499:
|
|
31
|
+
case 504:
|
|
32
|
+
return new McpError(ErrorCode.InternalError, message);
|
|
33
|
+
default:
|
|
34
|
+
// 4xx client errors -> InvalidRequest, 5xx server errors -> InternalError
|
|
35
|
+
return new McpError(err.status >= 400 && err.status < 500 ? ErrorCode.InvalidRequest : ErrorCode.InternalError, message);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Handle errors in tool handlers.
|
|
40
|
+
*
|
|
41
|
+
* This function ALWAYS throws and never returns (return type: never).
|
|
42
|
+
* Use as: `return handleToolError(err)` in catch blocks to make control flow
|
|
43
|
+
* explicit and satisfy TypeScript's type checker.
|
|
44
|
+
*/
|
|
45
|
+
export function handleToolError(err) {
|
|
46
|
+
if (err instanceof McpError) {
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
if (isHttpError(err)) {
|
|
50
|
+
throw httpErrorToMcpError(err);
|
|
51
|
+
}
|
|
52
|
+
if (err instanceof z.ZodError) {
|
|
53
|
+
const messages = err.errors.map((e) => `${e.path.join('.')}: ${e.message}`);
|
|
54
|
+
throw new McpError(ErrorCode.InvalidParams, `Validation error: ${messages.join(', ')}`);
|
|
55
|
+
}
|
|
56
|
+
if (err instanceof Error) {
|
|
57
|
+
throw new McpError(ErrorCode.InternalError, err.message);
|
|
58
|
+
}
|
|
59
|
+
throw new McpError(ErrorCode.InternalError, 'Unknown error occurred');
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Type guard to check if raw value is an error
|
|
63
|
+
*/
|
|
64
|
+
export function isRawResponseError(value) {
|
|
65
|
+
return typeof value === 'object' && value !== null && 'error' in value && typeof value.error === 'string';
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Type guard to check if raw value is a URI string
|
|
69
|
+
*/
|
|
70
|
+
export function isRawResponseUri(value) {
|
|
71
|
+
return typeof value === 'string';
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Type guard to check if raw value is an inline RawResponse
|
|
75
|
+
*/
|
|
76
|
+
export function isRawResponseInline(value) {
|
|
77
|
+
return typeof value === 'object' && value !== null && 'status' in value;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Process raw response - inline if small, store as resource if large
|
|
81
|
+
*
|
|
82
|
+
* @returns Object with:
|
|
83
|
+
* - raw: Either the inline RawResponse, a URI string to stored resource, or an error object
|
|
84
|
+
* - resourceLink: Present only when response was stored as a resource
|
|
85
|
+
*/
|
|
86
|
+
export function processRawResponse(response, includeRaw) {
|
|
87
|
+
if (!includeRaw) {
|
|
88
|
+
return {};
|
|
89
|
+
}
|
|
90
|
+
const config = getConfig();
|
|
91
|
+
const jsonStr = JSON.stringify(response);
|
|
92
|
+
if (jsonStr.length <= config.maxInlineJsonChars) {
|
|
93
|
+
return { raw: response };
|
|
94
|
+
}
|
|
95
|
+
// Store as resource
|
|
96
|
+
const result = putRawText(jsonStr, 'application/json');
|
|
97
|
+
if (!result) {
|
|
98
|
+
// Too large to store
|
|
99
|
+
return { raw: { error: 'Response too large to store' } };
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
raw: result.uri,
|
|
103
|
+
resourceLink: {
|
|
104
|
+
type: 'resource_link',
|
|
105
|
+
uri: result.uri,
|
|
106
|
+
name: 'Raw response',
|
|
107
|
+
mimeType: 'application/json',
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Build content array with text and optional resource link
|
|
113
|
+
*/
|
|
114
|
+
export function buildContent(text, resourceLink) {
|
|
115
|
+
const content = [{ type: 'text', text }];
|
|
116
|
+
if (resourceLink) {
|
|
117
|
+
content.push(resourceLink);
|
|
118
|
+
}
|
|
119
|
+
return content;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Common input schema for include_raw parameter
|
|
123
|
+
*/
|
|
124
|
+
export const includeRawSchema = z.boolean().optional().default(false);
|
|
125
|
+
/**
|
|
126
|
+
* Zod to JSON Schema converter (simplified)
|
|
127
|
+
*
|
|
128
|
+
* WARNING: This function accesses Zod internal structures (_def) which are not
|
|
129
|
+
* part of Zod's public API. This implementation:
|
|
130
|
+
* - May break with future Zod versions
|
|
131
|
+
* - Does not support all Zod types (see UNSUPPORTED_ZOD_TYPES)
|
|
132
|
+
* - Uses defensive checks but may still fail on edge cases
|
|
133
|
+
*
|
|
134
|
+
* For production use with full Zod type coverage, consider using the
|
|
135
|
+
* 'zod-to-json-schema' package instead.
|
|
136
|
+
*/
|
|
137
|
+
export function zodToJsonSchema(schema) {
|
|
138
|
+
return zodTypeToJsonSchema(schema);
|
|
139
|
+
}
|
|
140
|
+
/** Zod types that are explicitly not supported by this converter */
|
|
141
|
+
const UNSUPPORTED_ZOD_TYPES = [
|
|
142
|
+
'ZodIntersection',
|
|
143
|
+
'ZodTuple',
|
|
144
|
+
'ZodNativeEnum',
|
|
145
|
+
'ZodBigInt',
|
|
146
|
+
'ZodNaN',
|
|
147
|
+
'ZodDate',
|
|
148
|
+
'ZodSymbol',
|
|
149
|
+
'ZodUndefined',
|
|
150
|
+
'ZodVoid',
|
|
151
|
+
'ZodNever',
|
|
152
|
+
'ZodFunction',
|
|
153
|
+
'ZodLazy',
|
|
154
|
+
'ZodPromise',
|
|
155
|
+
'ZodBranded',
|
|
156
|
+
'ZodPipeline',
|
|
157
|
+
'ZodReadonly',
|
|
158
|
+
'ZodCatch',
|
|
159
|
+
'ZodDiscriminatedUnion',
|
|
160
|
+
'ZodEffects',
|
|
161
|
+
'ZodMap',
|
|
162
|
+
'ZodSet',
|
|
163
|
+
];
|
|
164
|
+
/**
|
|
165
|
+
* Safely get the Zod definition object
|
|
166
|
+
*/
|
|
167
|
+
function getZodDef(schema) {
|
|
168
|
+
try {
|
|
169
|
+
const schemaAny = schema;
|
|
170
|
+
if (!schemaAny._def || typeof schemaAny._def !== 'object') {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
const def = schemaAny._def;
|
|
174
|
+
if (typeof def.typeName !== 'string') {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
return def;
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Safely get checks array from a Zod definition
|
|
185
|
+
*/
|
|
186
|
+
function getChecks(def) {
|
|
187
|
+
if (!def.checks || !Array.isArray(def.checks)) {
|
|
188
|
+
return [];
|
|
189
|
+
}
|
|
190
|
+
return def.checks.filter((c) => typeof c === 'object' && c !== null && typeof c.kind === 'string');
|
|
191
|
+
}
|
|
192
|
+
function zodTypeToJsonSchema(schema) {
|
|
193
|
+
const def = getZodDef(schema);
|
|
194
|
+
if (!def) {
|
|
195
|
+
// Cannot access Zod internals, return permissive schema
|
|
196
|
+
return {};
|
|
197
|
+
}
|
|
198
|
+
const typeName = def.typeName;
|
|
199
|
+
// Check for explicitly unsupported types
|
|
200
|
+
if (UNSUPPORTED_ZOD_TYPES.includes(typeName)) {
|
|
201
|
+
throw new Error(`Unsupported Zod type: ${typeName}. Consider using 'zod-to-json-schema' package for full support.`);
|
|
202
|
+
}
|
|
203
|
+
switch (typeName) {
|
|
204
|
+
case 'ZodString': {
|
|
205
|
+
const strSchema = { type: 'string' };
|
|
206
|
+
const checks = getChecks(def);
|
|
207
|
+
for (const check of checks) {
|
|
208
|
+
if (check.kind === 'min' && typeof check.value === 'number') {
|
|
209
|
+
strSchema.minLength = check.value;
|
|
210
|
+
}
|
|
211
|
+
if (check.kind === 'max' && typeof check.value === 'number') {
|
|
212
|
+
strSchema.maxLength = check.value;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return strSchema;
|
|
216
|
+
}
|
|
217
|
+
case 'ZodNumber': {
|
|
218
|
+
const numSchema = { type: 'number' };
|
|
219
|
+
const checks = getChecks(def);
|
|
220
|
+
for (const check of checks) {
|
|
221
|
+
if (check.kind === 'min' && typeof check.value === 'number') {
|
|
222
|
+
numSchema.minimum = check.value;
|
|
223
|
+
}
|
|
224
|
+
if (check.kind === 'max' && typeof check.value === 'number') {
|
|
225
|
+
numSchema.maximum = check.value;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return numSchema;
|
|
229
|
+
}
|
|
230
|
+
case 'ZodBoolean':
|
|
231
|
+
return { type: 'boolean' };
|
|
232
|
+
case 'ZodArray': {
|
|
233
|
+
// Safely access array item type
|
|
234
|
+
const itemType = def.type;
|
|
235
|
+
if (!itemType) {
|
|
236
|
+
return { type: 'array' };
|
|
237
|
+
}
|
|
238
|
+
const arraySchema = {
|
|
239
|
+
type: 'array',
|
|
240
|
+
items: zodTypeToJsonSchema(itemType),
|
|
241
|
+
};
|
|
242
|
+
// Safely access length constraints
|
|
243
|
+
const minLen = def.minLength;
|
|
244
|
+
const maxLen = def.maxLength;
|
|
245
|
+
if (minLen && typeof minLen.value === 'number') {
|
|
246
|
+
arraySchema.minItems = minLen.value;
|
|
247
|
+
}
|
|
248
|
+
if (maxLen && typeof maxLen.value === 'number') {
|
|
249
|
+
arraySchema.maxItems = maxLen.value;
|
|
250
|
+
}
|
|
251
|
+
return arraySchema;
|
|
252
|
+
}
|
|
253
|
+
case 'ZodObject': {
|
|
254
|
+
// Safely access shape
|
|
255
|
+
const shapeFn = def.shape;
|
|
256
|
+
if (typeof shapeFn !== 'function') {
|
|
257
|
+
return { type: 'object' };
|
|
258
|
+
}
|
|
259
|
+
let shape;
|
|
260
|
+
try {
|
|
261
|
+
shape = shapeFn();
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
return { type: 'object' };
|
|
265
|
+
}
|
|
266
|
+
const properties = {};
|
|
267
|
+
const required = [];
|
|
268
|
+
for (const [key, value] of Object.entries(shape)) {
|
|
269
|
+
properties[key] = zodTypeToJsonSchema(value);
|
|
270
|
+
if (!isZodOptional(value)) {
|
|
271
|
+
required.push(key);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const objSchema = {
|
|
275
|
+
type: 'object',
|
|
276
|
+
properties,
|
|
277
|
+
additionalProperties: false,
|
|
278
|
+
};
|
|
279
|
+
if (required.length > 0) {
|
|
280
|
+
objSchema.required = required;
|
|
281
|
+
}
|
|
282
|
+
return objSchema;
|
|
283
|
+
}
|
|
284
|
+
case 'ZodOptional':
|
|
285
|
+
case 'ZodDefault':
|
|
286
|
+
case 'ZodNullable': {
|
|
287
|
+
// Safely access inner type
|
|
288
|
+
const innerType = def.innerType;
|
|
289
|
+
if (!innerType) {
|
|
290
|
+
return {};
|
|
291
|
+
}
|
|
292
|
+
const innerSchema = zodTypeToJsonSchema(innerType);
|
|
293
|
+
// For ZodNullable, wrap the type to allow null
|
|
294
|
+
if (typeName === 'ZodNullable') {
|
|
295
|
+
if (typeof innerSchema.type === 'string') {
|
|
296
|
+
return { ...innerSchema, type: [innerSchema.type, 'null'] };
|
|
297
|
+
}
|
|
298
|
+
// Complex inner type - use oneOf
|
|
299
|
+
return { oneOf: [innerSchema, { type: 'null' }] };
|
|
300
|
+
}
|
|
301
|
+
return innerSchema;
|
|
302
|
+
}
|
|
303
|
+
case 'ZodEnum': {
|
|
304
|
+
const values = def.values;
|
|
305
|
+
if (!Array.isArray(values)) {
|
|
306
|
+
return { type: 'string' };
|
|
307
|
+
}
|
|
308
|
+
return {
|
|
309
|
+
type: 'string',
|
|
310
|
+
enum: values,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
case 'ZodUnion': {
|
|
314
|
+
const options = def.options;
|
|
315
|
+
if (!Array.isArray(options) || options.length === 0) {
|
|
316
|
+
return {};
|
|
317
|
+
}
|
|
318
|
+
// Map options to schemas, handling undefined types gracefully
|
|
319
|
+
const schemas = options.map((o) => zodTypeToJsonSchema(o));
|
|
320
|
+
// Check for simple nullable union (Type | null)
|
|
321
|
+
if (schemas.length === 2) {
|
|
322
|
+
const nullIndex = schemas.findIndex((s) => s.type === 'null');
|
|
323
|
+
if (nullIndex !== -1) {
|
|
324
|
+
const otherSchema = schemas[1 - nullIndex];
|
|
325
|
+
const otherType = otherSchema.type;
|
|
326
|
+
// Only combine if the other type is a simple string type
|
|
327
|
+
if (typeof otherType === 'string' && otherType !== 'null') {
|
|
328
|
+
return { ...otherSchema, type: [otherType, 'null'] };
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
// General union - use oneOf
|
|
333
|
+
return { oneOf: schemas };
|
|
334
|
+
}
|
|
335
|
+
case 'ZodNull':
|
|
336
|
+
return { type: 'null' };
|
|
337
|
+
case 'ZodLiteral': {
|
|
338
|
+
const value = def.value;
|
|
339
|
+
if (value === undefined) {
|
|
340
|
+
return {};
|
|
341
|
+
}
|
|
342
|
+
return { const: value };
|
|
343
|
+
}
|
|
344
|
+
case 'ZodRecord': {
|
|
345
|
+
// ZodRecord is a dynamic object with unknown keys
|
|
346
|
+
// Optionally we could handle valueType for additionalProperties
|
|
347
|
+
return { type: 'object' };
|
|
348
|
+
}
|
|
349
|
+
case 'ZodUnknown':
|
|
350
|
+
case 'ZodAny':
|
|
351
|
+
// These types accept any value - return empty schema (permissive)
|
|
352
|
+
return {};
|
|
353
|
+
default:
|
|
354
|
+
// Unknown type - return empty schema (permissive)
|
|
355
|
+
// This is safer than throwing for forward compatibility
|
|
356
|
+
return {};
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Check if a Zod schema is optional (wrapped in ZodOptional or ZodDefault)
|
|
361
|
+
*/
|
|
362
|
+
function isZodOptional(schema) {
|
|
363
|
+
const def = getZodDef(schema);
|
|
364
|
+
if (!def)
|
|
365
|
+
return false;
|
|
366
|
+
const typeName = def.typeName;
|
|
367
|
+
return typeName === 'ZodOptional' || typeName === 'ZodDefault';
|
|
368
|
+
}
|
|
369
|
+
//# sourceMappingURL=toolUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolUtils.js","sourceRoot":"","sources":["../src/toolUtils.ts"],"names":[],"mapp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Q,CAAC;IAC9B,OAAO,QAAQ,KAAK,aAAa,IAAI,QAAQ,KAAK,YAAY,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nanogpt_get_balance tool
|
|
3
|
+
*
|
|
4
|
+
* Check the current account balance (USD and Nano).
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export declare const inputSchema: z.ZodObject<{
|
|
8
|
+
include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
include_raw: boolean;
|
|
11
|
+
}, {
|
|
12
|
+
include_raw?: boolean | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const outputSchema: z.ZodObject<{
|
|
15
|
+
usd_balance: z.ZodNumber;
|
|
16
|
+
nano_balance: z.ZodNumber;
|
|
17
|
+
nano_deposit_address: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
18
|
+
receivable: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
raw: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
usd_balance: number;
|
|
22
|
+
nano_balance: number;
|
|
23
|
+
raw?: string | Record<string, unknown> | undefined;
|
|
24
|
+
nano_deposit_address?: string | null | undefined;
|
|
25
|
+
receivable?: number | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
usd_balance: number;
|
|
28
|
+
nano_balance: number;
|
|
29
|
+
raw?: string | Record<string, unknown> | undefined;
|
|
30
|
+
nano_deposit_address?: string | null | undefined;
|
|
31
|
+
receivable?: number | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const inputJsonSchema: import("../toolUtils.js").JsonSchema;
|
|
34
|
+
export declare const outputJsonSchema: import("../toolUtils.js").JsonSchema;
|
|
35
|
+
export declare const name = "nanogpt_get_balance";
|
|
36
|
+
export declare const description = "Check the current account balance (USD and Nano). Use before expensive operations to verify sufficient funds.";
|
|
37
|
+
export declare const annotations: {
|
|
38
|
+
readOnlyHint: boolean;
|
|
39
|
+
openWorldHint: boolean;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Handler for nanogpt_get_balance
|
|
43
|
+
*/
|
|
44
|
+
export declare function handler(args: unknown): Promise<{
|
|
45
|
+
content: import("../toolUtils.js").ContentItem[];
|
|
46
|
+
structuredContent: Record<string, unknown>;
|
|
47
|
+
}>;
|
|
48
|
+
//# sourceMappingURL=balance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../src/tools/balance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,WAAW;;;;;;EAEtB,CAAC;AAGH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;EAMvB,CAAC;AAGH,eAAO,MAAM,eAAe,sCAA+B,CAAC;AAC5D,eAAO,MAAM,gBAAgB,sCAAgC,CAAC;AAG9D,eAAO,MAAM,IAAI,wBAAwB,CAAC;AAC1C,eAAO,MAAM,WAAW,kHACyF,CAAC;AAGlH,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AASF;;GAEG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,OAAO;;;GAqD1C"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nanogpt_get_balance tool
|
|
3
|
+
*
|
|
4
|
+
* Check the current account balance (USD and Nano).
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { requestJson } from '../httpClient.js';
|
|
8
|
+
import { handleToolError, processRawResponse, buildContent, zodToJsonSchema } from '../toolUtils.js';
|
|
9
|
+
// Input schema
|
|
10
|
+
export const inputSchema = z.object({
|
|
11
|
+
include_raw: z.boolean().optional().default(false),
|
|
12
|
+
});
|
|
13
|
+
// Output schema
|
|
14
|
+
export const outputSchema = z.object({
|
|
15
|
+
usd_balance: z.number(),
|
|
16
|
+
nano_balance: z.number(),
|
|
17
|
+
nano_deposit_address: z.union([z.string(), z.null()]).optional(),
|
|
18
|
+
receivable: z.number().optional(),
|
|
19
|
+
raw: z.union([z.record(z.unknown()), z.string()]).optional(),
|
|
20
|
+
});
|
|
21
|
+
// JSON Schemas for MCP registration
|
|
22
|
+
export const inputJsonSchema = zodToJsonSchema(inputSchema);
|
|
23
|
+
export const outputJsonSchema = zodToJsonSchema(outputSchema);
|
|
24
|
+
// Tool metadata
|
|
25
|
+
export const name = 'nanogpt_get_balance';
|
|
26
|
+
export const description = 'Check the current account balance (USD and Nano). Use before expensive operations to verify sufficient funds.';
|
|
27
|
+
// Annotations
|
|
28
|
+
export const annotations = {
|
|
29
|
+
readOnlyHint: true,
|
|
30
|
+
openWorldHint: false,
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Handler for nanogpt_get_balance
|
|
34
|
+
*/
|
|
35
|
+
export async function handler(args) {
|
|
36
|
+
try {
|
|
37
|
+
// Validate input
|
|
38
|
+
const input = inputSchema.parse(args);
|
|
39
|
+
// Call NanoGPT API
|
|
40
|
+
const response = await requestJson({
|
|
41
|
+
method: 'POST',
|
|
42
|
+
path: '/api/check-balance',
|
|
43
|
+
});
|
|
44
|
+
const data = response.json;
|
|
45
|
+
// Parse balance values
|
|
46
|
+
const usdBalance = parseFloat(data.usd_balance);
|
|
47
|
+
const nanoBalance = parseFloat(data.nano_balance);
|
|
48
|
+
if (isNaN(usdBalance) || isNaN(nanoBalance)) {
|
|
49
|
+
throw new Error('Invalid balance values received from API');
|
|
50
|
+
}
|
|
51
|
+
// Build output
|
|
52
|
+
const output = {
|
|
53
|
+
usd_balance: usdBalance,
|
|
54
|
+
nano_balance: nanoBalance,
|
|
55
|
+
};
|
|
56
|
+
if (data.nanoDepositAddress) {
|
|
57
|
+
output.nano_deposit_address = data.nanoDepositAddress;
|
|
58
|
+
}
|
|
59
|
+
if (data.receivable !== undefined) {
|
|
60
|
+
output.receivable = data.receivable;
|
|
61
|
+
}
|
|
62
|
+
// Process raw response
|
|
63
|
+
const { raw, resourceLink } = processRawResponse({ status: response.status, headers: response.headers, body: data }, input.include_raw);
|
|
64
|
+
if (raw !== undefined) {
|
|
65
|
+
output.raw = raw;
|
|
66
|
+
}
|
|
67
|
+
// Build human-readable content
|
|
68
|
+
const displayText = `Balance: $${usdBalance.toFixed(2)} USD, ${nanoBalance.toFixed(6)} XNO`;
|
|
69
|
+
return {
|
|
70
|
+
content: buildContent(displayText, resourceLink),
|
|
71
|
+
structuredContent: output,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
return handleToolError(err);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=balance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/tools/balance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAErG,eAAe;AACf,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACnD,CAAC,CAAC;AAEH,gBAAgB;AAChB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,YAAY,EAAE,CAAC,CAAC,M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
+
*
|
|
4
|
+
* Send a chat completion request to an AI model.
|
|
5
|
+
* Non-streaming only for MCP v1.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export declare const inputSchema: z.ZodObject<{
|
|
9
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
10
|
+
role: z.ZodEnum<["system", "user", "assistant"]>;
|
|
11
|
+
content: z.ZodString;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
role: "system" | "user" | "assistant";
|
|
14
|
+
content: string;
|
|
15
|
+
}, {
|
|
16
|
+
role: "system" | "user" | "assistant";
|
|
17
|
+
content: string;
|
|
18
|
+
}>, "many">;
|
|
19
|
+
model: z.ZodOptional<z.ZodString>;
|
|
20
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
include_usage: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
reasoning: z.ZodOptional<z.ZodObject<{
|
|
24
|
+
exclude: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
exclude?: boolean | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
exclude?: boolean | undefined;
|
|
29
|
+
}>>;
|
|
30
|
+
include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
include_raw: boolean;
|
|
33
|
+
messages: {
|
|
34
|
+
role: "system" | "user" | "assistant";
|
|
35
|
+
content: string;
|
|
36
|
+
}[];
|
|
37
|
+
model?: string | undefined;
|
|
38
|
+
temperature?: number | undefined;
|
|
39
|
+
max_tokens?: number | undefined;
|
|
40
|
+
include_usage?: boolean | undefined;
|
|
41
|
+
reasoning?: {
|
|
42
|
+
exclude?: boolean | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
messages: {
|
|
46
|
+
role: "system" | "user" | "assistant";
|
|
47
|
+
content: string;
|
|
48
|
+
}[];
|
|
49
|
+
include_raw?: boolean | undefined;
|
|
50
|
+
model?: string | undefined;
|
|
51
|
+
temperature?: number | undefined;
|
|
52
|
+
max_tokens?: number | undefined;
|
|
53
|
+
include_usage?: boolean | undefined;
|
|
54
|
+
reasoning?: {
|
|
55
|
+
exclude?: boolean | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
}>;
|
|
58
|
+
export declare const outputSchema: z.ZodObject<{
|
|
59
|
+
content: z.ZodString;
|
|
60
|
+
message: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
61
|
+
usage: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
62
|
+
raw: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
63
|
+
}, "strip", z.ZodTypeAny, {
|
|
64
|
+
message: Record<string, unknown>;
|
|
65
|
+
content: string;
|
|
66
|
+
raw?: string | Record<string, unknown> | undefined;
|
|
67
|
+
usage?: Record<string, unknown> | undefined;
|
|
68
|
+
}, {
|
|
69
|
+
message: Record<string, unknown>;
|
|
70
|
+
content: string;
|
|
71
|
+
raw?: string | Record<string, unknown> | undefined;
|
|
72
|
+
usage?: Record<string, unknown> | undefined;
|
|
73
|
+
}>;
|
|
74
|
+
export declare const inputJsonSchema: import("../toolUtils.js").JsonSchema;
|
|
75
|
+
export declare const outputJsonSchema: import("../toolUtils.js").JsonSchema;
|
|
76
|
+
export declare const name = "nanogpt_chat";
|
|
77
|
+
export declare const description = "Send a chat completion request to an AI model. Returns the assistant's response. Non-streaming.";
|
|
78
|
+
export declare const annotations: {
|
|
79
|
+
readOnlyHint: boolean;
|
|
80
|
+
openWorldHint: boolean;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Handler for nanogpt_chat
|
|
84
|
+
*/
|
|
85
|
+
export declare function handler(args: unknown): Promise<{
|
|
86
|
+
content: import("../toolUtils.js").ContentItem[];
|
|
87
|
+
structuredContent: Record<string, unknown>;
|
|
88
|
+
}>;
|
|
89
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/tools/chat.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYtB,CAAC;AAGH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;EAKvB,CAAC;AAGH,eAAO,MAAM,eAAe,sCAA+B,CAAC;AAC5D,eAAO,MAAM,gBAAgB,sCAAgC,CAAC;AAG9D,eAAO,MAAM,IAAI,iBAAiB,CAAC;AACnC,eAAO,MAAM,WAAW,oGAC2E,CAAC;AAGpG,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAaF;;GAEG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,OAAO;;;GAuF1C"}
|