@quantish/agent 0.1.31 → 0.1.32

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 (2) hide show
  1. package/dist/index.js +16 -51
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -251,27 +251,17 @@ var MCPClient = class {
251
251
  if (this.toolsCache) {
252
252
  return this.toolsCache;
253
253
  }
254
+ const headers = {
255
+ "Content-Type": "application/json",
256
+ "x-api-key": this.apiKey
257
+ };
254
258
  if (this.source === "discovery") {
255
- const response2 = await fetch(`${this.baseUrl}/tools`, {
256
- method: "GET",
257
- headers: {
258
- "Content-Type": "application/json",
259
- "X-API-Key": this.apiKey
260
- }
261
- });
262
- if (!response2.ok) {
263
- throw new Error(`MCP server error: ${response2.status} ${response2.statusText}`);
264
- }
265
- const data2 = await response2.json();
266
- this.toolsCache = data2.tools || [];
267
- return this.toolsCache;
259
+ headers["Accept"] = "application/json, text/event-stream";
260
+ headers["X-API-Key"] = this.apiKey;
268
261
  }
269
262
  const response = await fetch(this.baseUrl, {
270
263
  method: "POST",
271
- headers: {
272
- "Content-Type": "application/json",
273
- "x-api-key": this.apiKey
274
- },
264
+ headers,
275
265
  body: JSON.stringify({
276
266
  jsonrpc: "2.0",
277
267
  method: "tools/list",
@@ -292,45 +282,20 @@ var MCPClient = class {
292
282
  }
293
283
  /**
294
284
  * Call a tool on the MCP server
295
- * Discovery MCP uses REST endpoints, Trading MCP uses JSON-RPC
285
+ * All MCPs use JSON-RPC format
296
286
  */
297
287
  async callTool(name, args) {
288
+ const headers = {
289
+ "Content-Type": "application/json",
290
+ "x-api-key": this.apiKey
291
+ };
298
292
  if (this.source === "discovery") {
299
- const response2 = await fetch(`${this.baseUrl}/execute`, {
300
- method: "POST",
301
- headers: {
302
- "Content-Type": "application/json",
303
- "X-API-Key": this.apiKey
304
- },
305
- body: JSON.stringify({
306
- name,
307
- arguments: args
308
- })
309
- });
310
- if (!response2.ok) {
311
- return {
312
- success: false,
313
- error: `MCP server error: ${response2.status} ${response2.statusText}`
314
- };
315
- }
316
- const data2 = await response2.json();
317
- if (data2.error) {
318
- return {
319
- success: false,
320
- error: typeof data2.error === "string" ? data2.error : JSON.stringify(data2.error)
321
- };
322
- }
323
- return {
324
- success: true,
325
- data: data2.data ?? data2.result ?? data2
326
- };
293
+ headers["Accept"] = "application/json, text/event-stream";
294
+ headers["X-API-Key"] = this.apiKey;
327
295
  }
328
296
  const response = await fetch(this.baseUrl, {
329
297
  method: "POST",
330
- headers: {
331
- "Content-Type": "application/json",
332
- "x-api-key": this.apiKey
333
- },
298
+ headers,
334
299
  body: JSON.stringify({
335
300
  jsonrpc: "2.0",
336
301
  method: "tools/call",
@@ -5456,7 +5421,7 @@ Stopped ${count} background process${count > 1 ? "es" : ""}.`);
5456
5421
  }
5457
5422
 
5458
5423
  // src/index.ts
5459
- var VERSION = "0.1.31";
5424
+ var VERSION = "0.1.32";
5460
5425
  function cleanup() {
5461
5426
  if (processManager.hasRunning()) {
5462
5427
  const count = processManager.runningCount();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantish/agent",
3
- "version": "0.1.31",
3
+ "version": "0.1.32",
4
4
  "description": "AI-powered agent for trading on Polymarket and Kalshi",
5
5
  "type": "module",
6
6
  "bin": {