@nanogpt/mcp 1.1.5 → 1.3.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.
Files changed (48) hide show
  1. package/dist/config.d.ts +6 -3
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +23 -17
  4. package/dist/config.js.map +1 -1
  5. package/dist/httpClient.d.ts +13 -0
  6. package/dist/httpClient.d.ts.map +1 -1
  7. package/dist/httpClient.js +94 -4
  8. package/dist/httpClient.js.map +1 -1
  9. package/dist/index.d.ts +3 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +49 -3
  12. package/dist/index.js.map +1 -1
  13. package/dist/resources.d.ts +9 -2
  14. package/dist/resources.d.ts.map +1 -1
  15. package/dist/resources.js +14 -5
  16. package/dist/resources.js.map +1 -1
  17. package/dist/tools/applicationScrapers.d.ts +922 -0
  18. package/dist/tools/applicationScrapers.d.ts.map +1 -0
  19. package/dist/tools/applicationScrapers.js +306 -0
  20. package/dist/tools/applicationScrapers.js.map +1 -0
  21. package/dist/tools/chat.d.ts.map +1 -1
  22. package/dist/tools/chat.js +4 -1
  23. package/dist/tools/chat.js.map +1 -1
  24. package/dist/tools/generationExtras.d.ts +432 -0
  25. package/dist/tools/generationExtras.d.ts.map +1 -0
  26. package/dist/tools/generationExtras.js +419 -0
  27. package/dist/tools/generationExtras.js.map +1 -0
  28. package/dist/tools/index.d.ts +4 -0
  29. package/dist/tools/index.d.ts.map +1 -1
  30. package/dist/tools/index.js +4 -0
  31. package/dist/tools/index.js.map +1 -1
  32. package/dist/tools/listModels.d.ts +2 -2
  33. package/dist/tools/listModels.d.ts.map +1 -1
  34. package/dist/tools/listModels.js +41 -2
  35. package/dist/tools/listModels.js.map +1 -1
  36. package/dist/tools/researchTools.d.ts +88 -0
  37. package/dist/tools/researchTools.d.ts.map +1 -0
  38. package/dist/tools/researchTools.js +241 -0
  39. package/dist/tools/researchTools.js.map +1 -0
  40. package/dist/tools/vision.d.ts +78 -0
  41. package/dist/tools/vision.d.ts.map +1 -0
  42. package/dist/tools/vision.js +155 -0
  43. package/dist/tools/vision.js.map +1 -0
  44. package/dist/tools/webSearch.d.ts +102 -7
  45. package/dist/tools/webSearch.d.ts.map +1 -1
  46. package/dist/tools/webSearch.js +143 -8
  47. package/dist/tools/webSearch.js.map +1 -1
  48. package/package.json +14 -8
@@ -0,0 +1,88 @@
1
+ /**
2
+ * NanoGPT research/data tools.
3
+ */
4
+ import { z } from 'zod';
5
+ export declare const xResearchInputSchema: z.ZodObject<{
6
+ endpoint: z.ZodDefault<z.ZodEnum<["endpoints", "search", "search/recent", "search/all", "counts", "counts/recent", "counts/all", "tweet", "tweets", "tweet/quotes", "tweet/retweeted-by", "tweet/liking-users", "user", "users", "user/search", "user/tweets", "user/mentions", "user/liked-tweets", "user/followers", "user/following", "list", "list/tweets", "list/members", "list/followers", "space", "spaces", "spaces/search"]>>;
7
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>>;
8
+ include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ include_raw: boolean;
11
+ endpoint: "user" | "search" | "tweet" | "endpoints" | "search/recent" | "search/all" | "counts" | "counts/recent" | "counts/all" | "tweets" | "tweet/quotes" | "tweet/retweeted-by" | "tweet/liking-users" | "users" | "user/search" | "user/tweets" | "user/mentions" | "user/liked-tweets" | "user/followers" | "user/following" | "list" | "list/tweets" | "list/members" | "list/followers" | "space" | "spaces" | "spaces/search";
12
+ params?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
13
+ }, {
14
+ include_raw?: boolean | undefined;
15
+ params?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
16
+ endpoint?: "user" | "search" | "tweet" | "endpoints" | "search/recent" | "search/all" | "counts" | "counts/recent" | "counts/all" | "tweets" | "tweet/quotes" | "tweet/retweeted-by" | "tweet/liking-users" | "users" | "user/search" | "user/tweets" | "user/mentions" | "user/liked-tweets" | "user/followers" | "user/following" | "list" | "list/tweets" | "list/members" | "list/followers" | "space" | "spaces" | "spaces/search" | undefined;
17
+ }>;
18
+ export declare const hunterInputSchema: z.ZodObject<{
19
+ endpoint: z.ZodDefault<z.ZodEnum<["endpoints", "discover", "domain-search", "email-finder", "email-verifier", "people/find", "email-enrichment", "people-find", "person-enrichment", "companies/find", "company-enrichment", "companies-find", "combined/find", "combined-enrichment", "combined-find", "email-count"]>>;
20
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
21
+ include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
22
+ }, "strip", z.ZodTypeAny, {
23
+ include_raw: boolean;
24
+ endpoint: "endpoints" | "discover" | "domain-search" | "email-finder" | "email-verifier" | "people/find" | "email-enrichment" | "people-find" | "person-enrichment" | "companies/find" | "company-enrichment" | "companies-find" | "combined/find" | "combined-enrichment" | "combined-find" | "email-count";
25
+ params?: Record<string, unknown> | undefined;
26
+ }, {
27
+ include_raw?: boolean | undefined;
28
+ params?: Record<string, unknown> | undefined;
29
+ endpoint?: "endpoints" | "discover" | "domain-search" | "email-finder" | "email-verifier" | "people/find" | "email-enrichment" | "people-find" | "person-enrichment" | "companies/find" | "company-enrichment" | "companies-find" | "combined/find" | "combined-enrichment" | "combined-find" | "email-count" | undefined;
30
+ }>;
31
+ export declare const xResearchInputJsonSchema: import("../toolUtils.js").JsonSchema;
32
+ export declare const hunterInputJsonSchema: import("../toolUtils.js").JsonSchema;
33
+ export declare const outputJsonSchema: import("../toolUtils.js").JsonSchema;
34
+ export declare const xResearch: {
35
+ name: string;
36
+ description: string;
37
+ inputSchema: z.ZodObject<{
38
+ endpoint: z.ZodDefault<z.ZodEnum<["endpoints", "search", "search/recent", "search/all", "counts", "counts/recent", "counts/all", "tweet", "tweets", "tweet/quotes", "tweet/retweeted-by", "tweet/liking-users", "user", "users", "user/search", "user/tweets", "user/mentions", "user/liked-tweets", "user/followers", "user/following", "list", "list/tweets", "list/members", "list/followers", "space", "spaces", "spaces/search"]>>;
39
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>>;
40
+ include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
41
+ }, "strip", z.ZodTypeAny, {
42
+ include_raw: boolean;
43
+ endpoint: "user" | "search" | "tweet" | "endpoints" | "search/recent" | "search/all" | "counts" | "counts/recent" | "counts/all" | "tweets" | "tweet/quotes" | "tweet/retweeted-by" | "tweet/liking-users" | "users" | "user/search" | "user/tweets" | "user/mentions" | "user/liked-tweets" | "user/followers" | "user/following" | "list" | "list/tweets" | "list/members" | "list/followers" | "space" | "spaces" | "spaces/search";
44
+ params?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
45
+ }, {
46
+ include_raw?: boolean | undefined;
47
+ params?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
48
+ endpoint?: "user" | "search" | "tweet" | "endpoints" | "search/recent" | "search/all" | "counts" | "counts/recent" | "counts/all" | "tweets" | "tweet/quotes" | "tweet/retweeted-by" | "tweet/liking-users" | "users" | "user/search" | "user/tweets" | "user/mentions" | "user/liked-tweets" | "user/followers" | "user/following" | "list" | "list/tweets" | "list/members" | "list/followers" | "space" | "spaces" | "spaces/search" | undefined;
49
+ }>;
50
+ inputJsonSchema: import("../toolUtils.js").JsonSchema;
51
+ outputJsonSchema: import("../toolUtils.js").JsonSchema;
52
+ annotations: {
53
+ readOnlyHint: boolean;
54
+ openWorldHint: boolean;
55
+ };
56
+ handler: (args: unknown) => Promise<{
57
+ content: import("../toolUtils.js").ContentItem[];
58
+ structuredContent: Record<string, unknown>;
59
+ }>;
60
+ };
61
+ export declare const hunter: {
62
+ name: string;
63
+ description: string;
64
+ inputSchema: z.ZodObject<{
65
+ endpoint: z.ZodDefault<z.ZodEnum<["endpoints", "discover", "domain-search", "email-finder", "email-verifier", "people/find", "email-enrichment", "people-find", "person-enrichment", "companies/find", "company-enrichment", "companies-find", "combined/find", "combined-enrichment", "combined-find", "email-count"]>>;
66
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
67
+ include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
68
+ }, "strip", z.ZodTypeAny, {
69
+ include_raw: boolean;
70
+ endpoint: "endpoints" | "discover" | "domain-search" | "email-finder" | "email-verifier" | "people/find" | "email-enrichment" | "people-find" | "person-enrichment" | "companies/find" | "company-enrichment" | "companies-find" | "combined/find" | "combined-enrichment" | "combined-find" | "email-count";
71
+ params?: Record<string, unknown> | undefined;
72
+ }, {
73
+ include_raw?: boolean | undefined;
74
+ params?: Record<string, unknown> | undefined;
75
+ endpoint?: "endpoints" | "discover" | "domain-search" | "email-finder" | "email-verifier" | "people/find" | "email-enrichment" | "people-find" | "person-enrichment" | "companies/find" | "company-enrichment" | "companies-find" | "combined/find" | "combined-enrichment" | "combined-find" | "email-count" | undefined;
76
+ }>;
77
+ inputJsonSchema: import("../toolUtils.js").JsonSchema;
78
+ outputJsonSchema: import("../toolUtils.js").JsonSchema;
79
+ annotations: {
80
+ readOnlyHint: boolean;
81
+ openWorldHint: boolean;
82
+ };
83
+ handler: (args: unknown) => Promise<{
84
+ content: import("../toolUtils.js").ContentItem[];
85
+ structuredContent: Record<string, unknown>;
86
+ }>;
87
+ };
88
+ //# sourceMappingURL=researchTools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"researchTools.d.ts","sourceRoot":"","sources":["../../src/tools/researchTools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;EAmC/B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;EAwB5B,CAAC;AAUH,eAAO,MAAM,wBAAwB,sCAAwC,CAAC;AAC9E,eAAO,MAAM,qBAAqB,sCAAqC,CAAC;AACxE,eAAO,MAAM,gBAAgB,sCAAwC,CAAC;AAEtE,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;oBAQE,OAAO;;;;CAoB9B,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;oBAQK,OAAO;;;;CAuB9B,CAAC"}
@@ -0,0 +1,241 @@
1
+ /**
2
+ * NanoGPT research/data tools.
3
+ */
4
+ import { z } from 'zod';
5
+ import { requestJson } from '../httpClient.js';
6
+ import { handleToolError, processRawResponse, buildContent, zodToJsonSchema } from '../toolUtils.js';
7
+ const paramValueSchema = z.union([
8
+ z.string(),
9
+ z.number(),
10
+ z.boolean(),
11
+ z.array(z.union([z.string(), z.number(), z.boolean()])),
12
+ ]);
13
+ const paramsSchema = z.record(paramValueSchema).optional();
14
+ export const xResearchInputSchema = z.object({
15
+ endpoint: z.enum([
16
+ 'endpoints',
17
+ 'search',
18
+ 'search/recent',
19
+ 'search/all',
20
+ 'counts',
21
+ 'counts/recent',
22
+ 'counts/all',
23
+ 'tweet',
24
+ 'tweets',
25
+ 'tweet/quotes',
26
+ 'tweet/retweeted-by',
27
+ 'tweet/liking-users',
28
+ 'user',
29
+ 'users',
30
+ 'user/search',
31
+ 'user/tweets',
32
+ 'user/mentions',
33
+ 'user/liked-tweets',
34
+ 'user/followers',
35
+ 'user/following',
36
+ 'list',
37
+ 'list/tweets',
38
+ 'list/members',
39
+ 'list/followers',
40
+ 'space',
41
+ 'spaces',
42
+ 'spaces/search',
43
+ ]).default('endpoints')
44
+ .describe('X Research endpoint to call. Use endpoints to list supported routes.'),
45
+ params: paramsSchema
46
+ .describe('Query parameters for the selected X endpoint, such as query, username, id, ids, limit, or next_token.'),
47
+ include_raw: z.boolean().optional().default(false)
48
+ .describe('Include the raw NanoGPT API response for debugging. Large raw responses are returned as a resource link.'),
49
+ });
50
+ export const hunterInputSchema = z.object({
51
+ endpoint: z.enum([
52
+ 'endpoints',
53
+ 'discover',
54
+ 'domain-search',
55
+ 'email-finder',
56
+ 'email-verifier',
57
+ 'people/find',
58
+ 'email-enrichment',
59
+ 'people-find',
60
+ 'person-enrichment',
61
+ 'companies/find',
62
+ 'company-enrichment',
63
+ 'companies-find',
64
+ 'combined/find',
65
+ 'combined-enrichment',
66
+ 'combined-find',
67
+ 'email-count',
68
+ ]).default('endpoints')
69
+ .describe('Hunter endpoint to call. Use endpoints to list supported Hunter routes and pricing.'),
70
+ params: z.record(z.unknown()).optional()
71
+ .describe('Parameters for the Hunter endpoint, such as domain, company, email, full_name, first_name, last_name, or linkedin_handle.'),
72
+ include_raw: z.boolean().optional().default(false)
73
+ .describe('Include the raw NanoGPT API response for debugging. Large raw responses are returned as a resource link.'),
74
+ });
75
+ const dataToolOutputSchema = z.object({
76
+ data: z.unknown(),
77
+ billing: z.record(z.unknown()).optional(),
78
+ meta: z.record(z.unknown()).optional(),
79
+ status: z.number().optional(),
80
+ raw: z.union([z.record(z.unknown()), z.string()]).optional(),
81
+ });
82
+ export const xResearchInputJsonSchema = zodToJsonSchema(xResearchInputSchema);
83
+ export const hunterInputJsonSchema = zodToJsonSchema(hunterInputSchema);
84
+ export const outputJsonSchema = zodToJsonSchema(dataToolOutputSchema);
85
+ export const xResearch = {
86
+ name: 'nanogpt_x_research',
87
+ description: 'Retrieve public X data through NanoGPT billing: search, counts, posts, users, timelines, lists, and Spaces.',
88
+ inputSchema: xResearchInputSchema,
89
+ inputJsonSchema: xResearchInputJsonSchema,
90
+ outputJsonSchema,
91
+ annotations: { readOnlyHint: false, openWorldHint: true },
92
+ handler: async (args) => {
93
+ try {
94
+ const input = xResearchInputSchema.parse(args);
95
+ const endpoint = input.endpoint === 'endpoints' ? 'endpoints' : input.endpoint;
96
+ const response = await requestJson({
97
+ method: 'GET',
98
+ path: `/api/v1/x/${endpoint}`,
99
+ query: stringifyParams(input.params),
100
+ });
101
+ return buildDataToolResult({
102
+ label: 'X Research',
103
+ endpoint,
104
+ response,
105
+ includeRaw: input.include_raw,
106
+ });
107
+ }
108
+ catch (err) {
109
+ return handleToolError(err);
110
+ }
111
+ },
112
+ };
113
+ export const hunter = {
114
+ name: 'nanogpt_hunter',
115
+ description: 'Use Hunter.io through NanoGPT billing for domain search, email finding, email verification, enrichment, discovery, and email counts.',
116
+ inputSchema: hunterInputSchema,
117
+ inputJsonSchema: hunterInputJsonSchema,
118
+ outputJsonSchema,
119
+ annotations: { readOnlyHint: false, openWorldHint: true },
120
+ handler: async (args) => {
121
+ try {
122
+ const input = hunterInputSchema.parse(args);
123
+ const endpoint = input.endpoint === 'endpoints' ? '' : input.endpoint;
124
+ const response = await requestJson({
125
+ method: 'POST',
126
+ path: '/api/v1/hunter',
127
+ body: {
128
+ endpoint,
129
+ params: input.params || {},
130
+ },
131
+ });
132
+ return buildDataToolResult({
133
+ label: 'Hunter',
134
+ endpoint: input.endpoint,
135
+ response,
136
+ includeRaw: input.include_raw,
137
+ });
138
+ }
139
+ catch (err) {
140
+ return handleToolError(err);
141
+ }
142
+ },
143
+ };
144
+ function stringifyParams(params) {
145
+ const query = {};
146
+ if (!params)
147
+ return query;
148
+ for (const [key, value] of Object.entries(params)) {
149
+ if (Array.isArray(value)) {
150
+ query[key] = value.map(String).join(',');
151
+ }
152
+ else {
153
+ query[key] = String(value);
154
+ }
155
+ }
156
+ return query;
157
+ }
158
+ function buildDataToolResult({ label, endpoint, response, includeRaw, }) {
159
+ const data = response.json;
160
+ const output = {
161
+ data: data.data ?? data,
162
+ };
163
+ if (data.billing && typeof data.billing === 'object')
164
+ output.billing = data.billing;
165
+ if (data.meta && typeof data.meta === 'object')
166
+ output.meta = data.meta;
167
+ if (typeof data.status === 'number')
168
+ output.status = data.status;
169
+ const { raw, resourceLink } = processRawResponse({ status: response.status, headers: response.headers, body: data }, includeRaw);
170
+ if (raw !== undefined)
171
+ output.raw = raw;
172
+ return {
173
+ content: buildContent(formatDataToolText(label, endpoint, data), resourceLink),
174
+ structuredContent: output,
175
+ };
176
+ }
177
+ function formatDataToolText(label, endpoint, data) {
178
+ const primary = data.data ?? data;
179
+ const count = countPrimaryItems(primary);
180
+ let text = `${label} ${endpoint || 'endpoints'} returned ${count.label}.`;
181
+ const billing = data.billing;
182
+ if (billing && typeof billing === 'object') {
183
+ const record = billing;
184
+ const actualUsd = typeof record.actual_usd === 'number' ? record.actual_usd : undefined;
185
+ const estimatedUsd = typeof record.estimated_usd === 'number' ? record.estimated_usd : undefined;
186
+ if (actualUsd !== undefined)
187
+ text += ` Actual cost: $${actualUsd.toFixed(6)}.`;
188
+ if (estimatedUsd !== undefined)
189
+ text += ` Estimated cost: $${estimatedUsd.toFixed(6)}.`;
190
+ }
191
+ const preview = previewPrimary(primary);
192
+ if (preview)
193
+ text += `\n\nPreview:\n${preview}`;
194
+ return text;
195
+ }
196
+ function countPrimaryItems(value) {
197
+ if (Array.isArray(value))
198
+ return { label: `${value.length} item${value.length === 1 ? '' : 's'}`, count: value.length };
199
+ if (value && typeof value === 'object') {
200
+ const record = value;
201
+ if (Array.isArray(record.data))
202
+ return { label: `${record.data.length} data item${record.data.length === 1 ? '' : 's'}`, count: record.data.length };
203
+ if (record.data)
204
+ return { label: '1 data item', count: 1 };
205
+ if (Array.isArray(record.endpoints))
206
+ return { label: `${record.endpoints.length} endpoint${record.endpoints.length === 1 ? '' : 's'}`, count: record.endpoints.length };
207
+ return { label: `${Object.keys(record).length} field${Object.keys(record).length === 1 ? '' : 's'}` };
208
+ }
209
+ return { label: value === null || value === undefined ? 'no data' : '1 value', count: value === null || value === undefined ? 0 : 1 };
210
+ }
211
+ function previewPrimary(value) {
212
+ const items = Array.isArray(value)
213
+ ? value
214
+ : value && typeof value === 'object' && Array.isArray(value.data)
215
+ ? value.data
216
+ : value && typeof value === 'object' && Array.isArray(value.endpoints)
217
+ ? value.endpoints
218
+ : null;
219
+ if (!items || items.length === 0)
220
+ return null;
221
+ return items.slice(0, 3).map((item, index) => `- ${index + 1}: ${summarizeDataItem(item)}`).join('\n');
222
+ }
223
+ function summarizeDataItem(item) {
224
+ if (!item || typeof item !== 'object')
225
+ return String(item);
226
+ const record = item;
227
+ const parts = ['id', 'name', 'username', 'email', 'domain', 'title', 'text']
228
+ .map((key) => {
229
+ const value = record[key];
230
+ if (typeof value !== 'string' && typeof value !== 'number')
231
+ return null;
232
+ const text = String(value).replace(/\s+/g, ' ').trim();
233
+ return text ? `${key}: ${text.slice(0, 120)}${text.length > 120 ? '...' : ''}` : null;
234
+ })
235
+ .filter((part) => Boolean(part))
236
+ .slice(0, 3);
237
+ if (parts.length > 0)
238
+ return parts.join(', ');
239
+ return `fields: ${Object.keys(record).slice(0, 8).join(', ')}`;
240
+ }
241
+ //# sourceMappingURL=researchTools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"researchTools.js","sourceRoot":"","sources":["../../src/tools/researchTools.ts"],"names":[],"mappings":"AAAA;;GAEG;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,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC;IAC/B,CAAC,CAAC,MAAM,EAAE;IACV,CAAC,CAAC,MAAM,EAAE;IACV,CAAC,CAAC,OAAO,EAAE;IACX,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;CACxD,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,g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C,CAAC,CAAC;IACf,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,WAAW,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AACjE,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * nanogpt_vision tool
3
+ *
4
+ * Analyze images with a vision-capable model (default: zai-org/glm-4.6v).
5
+ */
6
+ import { z } from 'zod';
7
+ export declare const inputSchema: z.ZodObject<{
8
+ prompt: z.ZodString;
9
+ image_url: z.ZodOptional<z.ZodString>;
10
+ image_urls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
11
+ image_data_url: z.ZodOptional<z.ZodString>;
12
+ image_data_urls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
13
+ image_detail: z.ZodOptional<z.ZodEnum<["low", "high", "auto"]>>;
14
+ model: z.ZodOptional<z.ZodString>;
15
+ temperature: z.ZodOptional<z.ZodNumber>;
16
+ max_tokens: z.ZodOptional<z.ZodNumber>;
17
+ include_usage: z.ZodOptional<z.ZodBoolean>;
18
+ system_prompt: z.ZodOptional<z.ZodString>;
19
+ include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ include_raw: boolean;
22
+ prompt: string;
23
+ model?: string | undefined;
24
+ temperature?: number | undefined;
25
+ max_tokens?: number | undefined;
26
+ include_usage?: boolean | undefined;
27
+ image_url?: string | undefined;
28
+ image_urls?: string[] | undefined;
29
+ image_data_url?: string | undefined;
30
+ image_data_urls?: string[] | undefined;
31
+ image_detail?: "low" | "high" | "auto" | undefined;
32
+ system_prompt?: string | undefined;
33
+ }, {
34
+ prompt: string;
35
+ include_raw?: boolean | undefined;
36
+ model?: string | undefined;
37
+ temperature?: number | undefined;
38
+ max_tokens?: number | undefined;
39
+ include_usage?: boolean | undefined;
40
+ image_url?: string | undefined;
41
+ image_urls?: string[] | undefined;
42
+ image_data_url?: string | undefined;
43
+ image_data_urls?: string[] | undefined;
44
+ image_detail?: "low" | "high" | "auto" | undefined;
45
+ system_prompt?: string | undefined;
46
+ }>;
47
+ export declare const outputSchema: z.ZodObject<{
48
+ content: z.ZodString;
49
+ message: z.ZodRecord<z.ZodString, z.ZodUnknown>;
50
+ usage: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
51
+ raw: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
52
+ }, "strip", z.ZodTypeAny, {
53
+ message: Record<string, unknown>;
54
+ content: string;
55
+ raw?: string | Record<string, unknown> | undefined;
56
+ usage?: Record<string, unknown> | undefined;
57
+ }, {
58
+ message: Record<string, unknown>;
59
+ content: string;
60
+ raw?: string | Record<string, unknown> | undefined;
61
+ usage?: Record<string, unknown> | undefined;
62
+ }>;
63
+ export declare const inputJsonSchema: import("../toolUtils.js").JsonSchema;
64
+ export declare const outputJsonSchema: import("../toolUtils.js").JsonSchema;
65
+ export declare const name = "nanogpt_vision";
66
+ export declare const description = "Analyze images with a vision-capable model. Provide an image URL or data URL plus a prompt.";
67
+ export declare const annotations: {
68
+ readOnlyHint: boolean;
69
+ openWorldHint: boolean;
70
+ };
71
+ /**
72
+ * Handler for nanogpt_vision
73
+ */
74
+ export declare function handler(args: unknown): Promise<{
75
+ content: import("../toolUtils.js").ContentItem[];
76
+ structuredContent: Record<string, unknown>;
77
+ }>;
78
+ //# sourceMappingURL=vision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vision.d.ts","sourceRoot":"","sources":["../../src/tools/vision.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAatB,CAAC;AAGH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;EAKvB,CAAC;AAGH,eAAO,MAAM,eAAe,sCAA+B,CAAC;AAC5D,eAAO,MAAM,gBAAgB,sCAAgC,CAAC;AAG9D,eAAO,MAAM,IAAI,mBAAmB,CAAC;AACrC,eAAO,MAAM,WAAW,gGACuE,CAAC;AAGhG,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAiBF;;GAEG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,OAAO;;;GA8H1C"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * nanogpt_vision tool
3
+ *
4
+ * Analyze images with a vision-capable model (default: zai-org/glm-4.6v).
5
+ */
6
+ import { z } from 'zod';
7
+ import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
8
+ import { requestJson } from '../httpClient.js';
9
+ import { getConfig } from '../config.js';
10
+ import { handleToolError, processRawResponse, buildContent, zodToJsonSchema } from '../toolUtils.js';
11
+ // Input schema
12
+ export const inputSchema = z.object({
13
+ prompt: z.string().min(1),
14
+ image_url: z.string().min(1).optional(),
15
+ image_urls: z.array(z.string().min(1)).min(1).optional(),
16
+ image_data_url: z.string().min(1).optional(),
17
+ image_data_urls: z.array(z.string().min(1)).min(1).optional(),
18
+ image_detail: z.enum(['low', 'high', 'auto']).optional(),
19
+ model: z.string().optional(),
20
+ temperature: z.number().min(0).max(2).optional(),
21
+ max_tokens: z.number().min(1).optional(),
22
+ include_usage: z.boolean().optional(),
23
+ system_prompt: z.string().optional(),
24
+ include_raw: z.boolean().optional().default(false),
25
+ });
26
+ // Output schema
27
+ export const outputSchema = z.object({
28
+ content: z.string(),
29
+ message: z.record(z.unknown()),
30
+ usage: z.record(z.unknown()).optional(),
31
+ raw: z.union([z.record(z.unknown()), z.string()]).optional(),
32
+ });
33
+ // JSON Schemas for MCP registration
34
+ export const inputJsonSchema = zodToJsonSchema(inputSchema);
35
+ export const outputJsonSchema = zodToJsonSchema(outputSchema);
36
+ // Tool metadata
37
+ export const name = 'nanogpt_vision';
38
+ export const description = 'Analyze images with a vision-capable model. Provide an image URL or data URL plus a prompt.';
39
+ // Annotations
40
+ export const annotations = {
41
+ readOnlyHint: false,
42
+ openWorldHint: true,
43
+ };
44
+ /**
45
+ * Handler for nanogpt_vision
46
+ */
47
+ export async function handler(args) {
48
+ try {
49
+ // Validate input
50
+ const input = inputSchema.parse(args);
51
+ const config = getConfig();
52
+ const imageSources = [];
53
+ if (input.image_url)
54
+ imageSources.push(input.image_url);
55
+ if (input.image_data_url)
56
+ imageSources.push(input.image_data_url);
57
+ if (input.image_urls)
58
+ imageSources.push(...input.image_urls);
59
+ if (input.image_data_urls)
60
+ imageSources.push(...input.image_data_urls);
61
+ if (imageSources.length === 0) {
62
+ throw new McpError(ErrorCode.InvalidParams, 'Provide at least one image via image_url/image_urls or image_data_url/image_data_urls.');
63
+ }
64
+ // Determine model
65
+ const model = input.model || config.visionModel;
66
+ if (!model) {
67
+ throw new McpError(ErrorCode.InvalidRequest, 'No vision model specified. Provide "model" or set NANOGPT_VISION_MODEL.');
68
+ }
69
+ // Build content array (text + images)
70
+ const content = [{ type: 'text', text: input.prompt }];
71
+ const detail = input.image_detail;
72
+ const addImage = (url) => {
73
+ if (detail) {
74
+ content.push({ type: 'image_url', image_url: { url, detail } });
75
+ }
76
+ else {
77
+ content.push({ type: 'image_url', image_url: { url } });
78
+ }
79
+ };
80
+ for (const url of imageSources) {
81
+ addImage(url);
82
+ }
83
+ // Build messages
84
+ const messages = [];
85
+ if (input.system_prompt) {
86
+ messages.push({ role: 'system', content: input.system_prompt });
87
+ }
88
+ messages.push({ role: 'user', content });
89
+ // Build request body
90
+ const requestBody = {
91
+ model,
92
+ messages,
93
+ stream: false, // Force non-streaming for MCP v1
94
+ };
95
+ if (input.temperature !== undefined) {
96
+ requestBody.temperature = input.temperature;
97
+ }
98
+ if (input.max_tokens !== undefined) {
99
+ requestBody.max_tokens = input.max_tokens;
100
+ }
101
+ // Call NanoGPT API
102
+ const response = await requestJson({
103
+ method: 'POST',
104
+ path: '/v1/chat/completions',
105
+ body: requestBody,
106
+ });
107
+ const data = response.json;
108
+ // Extract assistant message
109
+ const choice = data.choices?.[0];
110
+ if (!choice) {
111
+ throw new McpError(ErrorCode.InternalError, 'No response from model');
112
+ }
113
+ const assistantMessage = choice.message;
114
+ const rawContent = assistantMessage.content;
115
+ let contentText = '';
116
+ if (typeof rawContent === 'string') {
117
+ contentText = rawContent;
118
+ }
119
+ else if (rawContent !== undefined) {
120
+ contentText = JSON.stringify(rawContent);
121
+ }
122
+ // Build output
123
+ const output = {
124
+ content: contentText,
125
+ message: assistantMessage,
126
+ };
127
+ if (input.include_usage && data.usage) {
128
+ output.usage = data.usage;
129
+ }
130
+ // Process raw response
131
+ const { raw, resourceLink } = processRawResponse({ status: response.status, headers: response.headers, body: data }, input.include_raw);
132
+ if (raw !== undefined) {
133
+ output.raw = raw;
134
+ }
135
+ // Build content
136
+ let displayText;
137
+ if (contentText) {
138
+ displayText = contentText;
139
+ }
140
+ else if (assistantMessage.tool_calls) {
141
+ displayText = `Assistant requested tool calls: ${JSON.stringify(assistantMessage.tool_calls)}`;
142
+ }
143
+ else {
144
+ displayText = JSON.stringify(assistantMessage);
145
+ }
146
+ return {
147
+ content: buildContent(displayText, resourceLink),
148
+ structuredContent: output,
149
+ };
150
+ }
151
+ catch (err) {
152
+ return handleToolError(err);
153
+ }
154
+ }
155
+ //# sourceMappingURL=vision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vision.js","sourceRoot":"","sources":["../../src/tools/vision.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,c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