Skip to content

Commit 6822457

Browse files
committed
prettier fix
1 parent f16bc71 commit 6822457

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,8 @@ To test your server, you can use the [MCP Inspector](https://github.com/modelcon
795795
Some parts of the SDK (for example, JWT-based client authentication in `auth-extensions.ts` via `jose`) rely on the Web Crypto API exposed as `globalThis.crypto`.
796796

797797
- **Node.js v19.0.0 and later**: `globalThis.crypto` is available by default.
798-
- **Node.js v18.x**: `globalThis.crypto` may not be defined by default; in this repository we polyfill it for tests (see `vitest.setup.ts`), and you should do the same in your app if it is missing - or alternatively, run Node with `--experimental-global-webcrypto` as per your Node version documentation. (See https://nodejs.org/dist/latest-v18.x/docs/api/globals.html#crypto )
798+
- **Node.js v18.x**: `globalThis.crypto` may not be defined by default; in this repository we polyfill it for tests (see `vitest.setup.ts`), and you should do the same in your app if it is missing - or alternatively, run Node with `--experimental-global-webcrypto` as per your
799+
Node version documentation. (See https://nodejs.org/dist/latest-v18.x/docs/api/globals.html#crypto )
799800

800801
If you run tests or applications on Node.js versions where `globalThis.crypto` is missing, you can polyfill it using the built-in `node:crypto` module, similar to the SDK's own `vitest.setup.ts`:
801802

@@ -1466,11 +1467,7 @@ You can use these providers with the `StreamableHTTPClientTransport` and the hig
14661467
```typescript
14671468
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
14681469
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
1469-
import {
1470-
ClientCredentialsProvider,
1471-
PrivateKeyJwtProvider,
1472-
StaticPrivateKeyJwtProvider
1473-
} from '@modelcontextprotocol/sdk/client/auth-extensions.js';
1470+
import { ClientCredentialsProvider, PrivateKeyJwtProvider, StaticPrivateKeyJwtProvider } from '@modelcontextprotocol/sdk/client/auth-extensions.js';
14741471
import { auth } from '@modelcontextprotocol/sdk/client/auth.js';
14751472

14761473
const serverUrl = new URL('https://mcp.example.com/');

src/client/auth-extensions.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,7 @@ describe('createPrivateKeyJwtAuth', () => {
231231
const addClientAuth = createPrivateKeyJwtAuth(baseOptions);
232232
const params = new URLSearchParams();
233233

234-
await expect(
235-
addClientAuth(new Headers(), params, 'https://auth.example.com/token', undefined)
236-
).rejects.toThrow(
234+
await expect(addClientAuth(new Headers(), params, 'https://auth.example.com/token', undefined)).rejects.toThrow(
237235
'crypto is not available, please ensure you add have Web Crypto API support for older Node.js versions'
238236
);
239237
} finally {

src/client/auth-extensions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export function createPrivateKeyJwtAuth(options: {
2828
return async (_headers, params, url, metadata) => {
2929
// Lazy import to avoid heavy dependency unless used
3030
if (typeof globalThis.crypto === 'undefined') {
31-
throw new TypeError('crypto is not available, please ensure you add have Web Crypto API support for older Node.js versions (see https://github.com/modelcontextprotocol/typescript-sdk#nodejs-web-crypto-globalthiscrypto-compatibility)');
31+
throw new TypeError(
32+
'crypto is not available, please ensure you add have Web Crypto API support for older Node.js versions (see https://github.com/modelcontextprotocol/typescript-sdk#nodejs-web-crypto-globalthiscrypto-compatibility)'
33+
);
3234
}
3335

3436
const jose = await import('jose');

0 commit comments

Comments
 (0)