Skip to content

Commit c986b61

Browse files
committed
Removed axios for fetch
1 parent 2274463 commit c986b61

3 files changed

Lines changed: 12 additions & 25 deletions

File tree

.yarn/install-state.gz

24 Bytes
Binary file not shown.

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2-
import axios, { AxiosError } from 'axios';
32
import { TrieveSDK } from 'trieve-ts-sdk';
43
import { z } from 'zod';
54

65
import { DEFAULT_BASE_URL, SERVER_URL, SUBDOMAIN } from './config.js';
76
import type { MintlifySearchConfig, SeiSearchResponse, TrieveResponse, TrieveSearchResult } from './types.js';
8-
import { formatErr, throwOnAxiosError } from './utils.js';
7+
import { formatErr } from './utils.js';
98

109
/**
1110
* Fetch Mintlify configuration for the given subdomain
1211
*/
1312
const fetchMintlifyConfig = async (subdomain: string): Promise<MintlifySearchConfig> => {
1413
try {
1514
const url = `${SERVER_URL}/api/mcp/config/${subdomain}`;
16-
const response = await axios.get(url, {
17-
validateStatus() {
18-
return true;
15+
const response = await fetch(url);
16+
17+
if (!response.ok) {
18+
if (response.status === 404) {
19+
throw new Error(`${subdomain} not found`);
1920
}
20-
});
21-
throwOnAxiosError(response, 'Failed to fetch MCP config');
22-
return response.data;
21+
throw new Error(`Failed to fetch MCP config: ${response.status} ${response.statusText}`);
22+
}
23+
24+
return (await response.json()) as MintlifySearchConfig;
2325
} catch (err) {
24-
throw new Error(formatErr(err).replace('Request failed with status code 404', `${subdomain} not found`));
26+
throw new Error(formatErr(err));
2527
}
2628
};
2729

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
1-
import type { AxiosError, AxiosResponse } from 'axios';
2-
31
/**
42
* Format error messages for consistent error handling
53
*/
6-
export const formatErr = (err: AxiosError | Error | unknown): string => {
7-
if (err && typeof err === 'object' && 'response' in err) {
8-
const axiosErr = err as AxiosError;
9-
return `Request failed with status code ${axiosErr.response?.status}`;
10-
}
4+
export const formatErr = (err: Error | unknown): string => {
115
if (err instanceof Error) {
126
return err.message;
137
}
148
return String(err);
159
};
16-
17-
/**
18-
* Throw an error if the axios response indicates failure
19-
*/
20-
export const throwOnAxiosError = (response: AxiosResponse, message: string): void => {
21-
if (response.status < 200 || response.status >= 300) {
22-
throw new Error(`${message}: ${response.status} ${response.statusText}`);
23-
}
24-
};

0 commit comments

Comments
 (0)