diff --git a/mcp-worker/src/axiosFetchDefaults.test.ts b/mcp-worker/src/axiosFetchDefaults.test.ts new file mode 100644 index 00000000..6c2048de --- /dev/null +++ b/mcp-worker/src/axiosFetchDefaults.test.ts @@ -0,0 +1,14 @@ +import { describe, expect, test } from 'vitest' +import axios from 'axios' +import { axiosClient } from '../../src/api/apiClient' +import './axiosFetchDefaults' + +describe('axiosFetchDefaults', () => { + test('sets a Workers-compatible cache mode on global axios defaults', () => { + expect(axios.defaults.fetchOptions?.cache).toBe('no-store') + }) + + test('sets a Workers-compatible cache mode on the shared axiosClient', () => { + expect(axiosClient.defaults.fetchOptions?.cache).toBe('no-store') + }) +}) diff --git a/mcp-worker/src/axiosFetchDefaults.ts b/mcp-worker/src/axiosFetchDefaults.ts new file mode 100644 index 00000000..5ef9b9c5 --- /dev/null +++ b/mcp-worker/src/axiosFetchDefaults.ts @@ -0,0 +1,13 @@ +import axios from 'axios' +import { axiosClient } from '../../src/api/apiClient' + +/** + * axios >= 1.20 defaults fetch requests to `cache: 'default'`, which the + * Workers runtime rejects ("Unsupported cache mode: default"). Workers only + * accept `no-store` / `no-cache`, so set an explicit value on both the global + * axios defaults and the shared CLI client instance. + */ +const fetchOptions = { cache: 'no-store' as const } + +axios.defaults.fetchOptions = fetchOptions +axiosClient.defaults.fetchOptions = fetchOptions diff --git a/mcp-worker/src/index.ts b/mcp-worker/src/index.ts index 736d5522..e8e12a2a 100644 --- a/mcp-worker/src/index.ts +++ b/mcp-worker/src/index.ts @@ -1,3 +1,4 @@ +import './axiosFetchDefaults' import OAuthProvider from '@cloudflare/workers-oauth-provider' import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js' import type { ToolAnnotations } from '@modelcontextprotocol/sdk/types.js'