diff --git a/package-lock.json b/package-lock.json index ad7e686..4638341 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,20 +1,25 @@ { - "name": "MCP-summarization-functions", - "version": "0.1.0", + "name": "mcp-summarization-functions", + "version": "0.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "MCP-summarization-functions", - "version": "0.1.0", + "name": "mcp-summarization-functions", + "version": "0.1.2", "hasInstallScript": true, + "license": "MIT", "dependencies": { "@anthropic-ai/sdk": "^0.32.1", "@modelcontextprotocol/sdk": "^0.6.0", "dotenv": "^16.4.7", "execa": "^9.5.2", + "node-fetch": "^3.3.2", "uuid": "^11.0.3" }, + "bin": { + "mcp-summarization-functions": "build/index.js" + }, "devDependencies": { "@types/jest": "^29.5.14", "@types/node": "^20.0.0", @@ -65,6 +70,26 @@ "undici-types": "~5.26.4" } }, + "node_modules/@anthropic-ai/sdk/node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/@anthropic-ai/sdk/node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", @@ -1665,6 +1690,15 @@ "node": ">= 8" } }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, "node_modules/debug": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", @@ -1923,6 +1957,38 @@ "bser": "2.1.1" } }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, + "node_modules/fetch-blob/node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, "node_modules/figures": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/figures/-/figures-6.1.0.tgz", @@ -2031,6 +2097,18 @@ "node": ">= 12.20" } }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "license": "MIT", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3411,23 +3489,21 @@ } }, "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", "license": "MIT", "dependencies": { - "whatwg-url": "^5.0.0" + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" }, "engines": { - "node": "4.x || >=6.0.0" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" } }, "node_modules/node-int64": { diff --git a/package.json b/package.json index 0563b6b..1f08ded 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mcp-summarization-functions", - "version": "0.1.2", + "version": "0.1.3", "description": "Provides summarised output from various actions that could otherwise eat up tokens and cause crashes", "type": "module", "main": "build/index.js", @@ -26,6 +26,7 @@ "@modelcontextprotocol/sdk": "^0.6.0", "dotenv": "^16.4.7", "execa": "^9.5.2", + "node-fetch": "^3.3.2", "uuid": "^11.0.3" }, "devDependencies": { diff --git a/src/index.ts b/src/index.ts index 119eb2a..2563da1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,13 @@ #!/usr/bin/env node +// Set up fetch polyfill before any other imports +import fetch, { Headers, Request, Response } from 'node-fetch'; +if (!globalThis.fetch) { + globalThis.fetch = fetch as unknown as typeof globalThis.fetch; + globalThis.Headers = Headers as unknown as typeof globalThis.Headers; + globalThis.Request = Request as unknown as typeof globalThis.Request; + globalThis.Response = Response as unknown as typeof globalThis.Response; +} + import { config } from 'dotenv'; import { createAnthropicModel } from './models/anthropic.js';