Skip to content

Commit 1f25b0d

Browse files
authored
Replaced fetch with node-fetch (#281)
* Replaced fetch with node-fetch Fetch can be unavailable on some versions of node 18, this PR explicitly uses node-fetch for full backwards compatibility. * Added changeset * Syncronized package versions with types * Downgraded node-fetch for CJS support * Fixed tests for node-fetch changes Fixed tests by mocking node-fetch instead of global fetch * Fixed typescript warning on node-fetch mock
1 parent ade22d6 commit 1f25b0d

7 files changed

Lines changed: 3188 additions & 3112 deletions

File tree

.changeset/lovely-sloths-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sei-js/mcp-server": patch
3+
---
4+
5+
Explicitly use node-fetch instead of relying on users node version to have fetch

.yarn/install-state.gz

12.7 KB
Binary file not shown.

packages/mcp-server/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"devDependencies": {
2222
"@types/cors": "^2.8.17",
2323
"@types/express": "^5.0.0",
24+
"@types/node-fetch": "^2.6.13",
2425
"typescript": "^5.8.3"
2526
},
2627
"dependencies": {
@@ -29,6 +30,7 @@
2930
"dotenv": "^16.5.0",
3031
"express": "^4.21.2",
3132
"jest": "^30.0.3",
33+
"node-fetch": "^2.7.0",
3234
"trieve-ts-sdk": "^0.0.121",
3335
"tsx": "^4.20.3",
3436
"viem": "^2.30.5",

packages/mcp-server/src/docs/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
22
import { z } from 'zod';
3+
import fetch from 'node-fetch';
34
import type { SeiSearchResponse } from '../mintlify/types';
45

56
const DOCS_SEARCH_URL = 'https://docs.sei-apis.io/search';

packages/mcp-server/src/mintlify/search.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
22
import { TrieveSDK } from 'trieve-ts-sdk';
33
import { z } from 'zod';
4+
import fetch from 'node-fetch';
45

56
import { DEFAULT_BASE_URL, SERVER_URL, SUBDOMAIN } from './config.js';
67
import type { MintlifySearchConfig, SeiSearchResponse, TrieveResponse, TrieveSearchResult } from './types.js';

0 commit comments

Comments
 (0)