Skip to content

Commit 4844b3a

Browse files
authored
Merge branch 'main' into fix/1362-widen-elicit-schema-types
2 parents 0c9b2bc + 7778c74 commit 4844b3a

24 files changed

Lines changed: 182 additions & 45 deletions

File tree

.changeset/add-hono-peer-dep.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@modelcontextprotocol/node': patch
3+
---
4+
5+
Add missing `hono` peer dependency to `@modelcontextprotocol/node`. The package already depends on `@hono/node-server` which requires `hono` at runtime, but `hono` was only listed in the workspace root, not as a peer dependency of the package itself.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Temporary files
2+
tmp/
3+
14
# Logs
25
logs
36
*.log

packages/client/src/client/auth.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export interface OAuthClientProvider {
6060
get clientMetadata(): OAuthClientMetadata;
6161

6262
/**
63-
* Returns a OAuth2 state parameter.
63+
* Returns an OAuth2 state parameter.
6464
*/
6565
state?(): string | Promise<string>;
6666

@@ -654,7 +654,8 @@ export function extractResourceMetadataUrl(res: Response): URL | undefined {
654654
}
655655

656656
/**
657-
* Looks up RFC 9728 OAuth 2.0 Protected Resource Metadata.
657+
* Looks up {@link https://datatracker.ietf.org/doc/html/rfc9728 | RFC 9728}
658+
* OAuth 2.0 Protected Resource Metadata.
658659
*
659660
* If the server returns a 404 for the well-known endpoint, this function will
660661
* return `undefined`. Any other errors will be thrown as exceptions.
@@ -872,8 +873,11 @@ export function buildDiscoveryUrls(authorizationServerUrl: string | URL): { url:
872873
}
873874

874875
/**
875-
* Discovers authorization server metadata with support for RFC 8414 OAuth 2.0 Authorization Server Metadata
876-
* and OpenID Connect Discovery 1.0 specifications.
876+
* Discovers authorization server metadata with support for
877+
* {@link https://datatracker.ietf.org/doc/html/rfc8414 | RFC 8414} OAuth 2.0
878+
* Authorization Server Metadata and
879+
* {@link https://openid.net/specs/openid-connect-discovery-1_0.html | OpenID Connect Discovery 1.0}
880+
* specifications.
877881
*
878882
* This function implements a fallback strategy for authorization server discovery:
879883
* 1. Attempts RFC 8414 OAuth metadata discovery first
@@ -1206,6 +1210,7 @@ export async function refreshAuthorization(
12061210
* @throws {Error} When provider doesn't implement prepareTokenRequest or token fetch fails
12071211
*
12081212
* @example
1213+
* ```typescript
12091214
* // Provider for client_credentials:
12101215
* class MyProvider implements OAuthClientProvider {
12111216
* prepareTokenRequest(scope) {
@@ -1217,6 +1222,7 @@ export async function refreshAuthorization(
12171222
* }
12181223
*
12191224
* const tokens = await fetchToken(provider, authServerUrl, { metadata });
1225+
* ```
12201226
*/
12211227
export async function fetchToken(
12221228
provider: OAuthClientProvider,
@@ -1267,7 +1273,8 @@ export async function fetchToken(
12671273
}
12681274

12691275
/**
1270-
* Performs OAuth 2.0 Dynamic Client Registration according to RFC 7591.
1276+
* Performs OAuth 2.0 Dynamic Client Registration according to
1277+
* {@link https://datatracker.ietf.org/doc/html/rfc7591 | RFC 7591}.
12711278
*/
12721279
export async function registerClient(
12731280
authorizationServerUrl: string | URL,

packages/client/src/client/authExtensions.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import type { AddClientAuthentication, OAuthClientProvider } from './auth.js';
1313
/**
1414
* Helper to produce a private_key_jwt client authentication function.
1515
*
16-
* Usage:
17-
* const addClientAuth = createPrivateKeyJwtAuth({ issuer, subject, privateKey, alg, audience? });
18-
* // pass addClientAuth as provider.addClientAuthentication implementation
16+
* @example
17+
* ```typescript
18+
* const addClientAuth = createPrivateKeyJwtAuth({ issuer, subject, privateKey, alg, audience? });
19+
* // pass addClientAuth as provider.addClientAuthentication implementation
20+
* ```
1921
*/
2022
export function createPrivateKeyJwtAuth(options: {
2123
issuer: string;
@@ -30,7 +32,7 @@ export function createPrivateKeyJwtAuth(options: {
3032
// Lazy import to avoid heavy dependency unless used
3133
if (globalThis.crypto === undefined) {
3234
throw new TypeError(
33-
'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)'
35+
'crypto is not available, please ensure you have Web Crypto API support for older Node.js versions (see https://github.com/modelcontextprotocol/typescript-sdk#nodejs-web-crypto-globalthiscrypto-compatibility)'
3436
);
3537
}
3638

@@ -114,6 +116,7 @@ export interface ClientCredentialsProviderOptions {
114116
* the client authenticates using a client_id and client_secret.
115117
*
116118
* @example
119+
* ```typescript
117120
* const provider = new ClientCredentialsProvider({
118121
* clientId: 'my-client',
119122
* clientSecret: 'my-secret'
@@ -122,6 +125,7 @@ export interface ClientCredentialsProviderOptions {
122125
* const transport = new StreamableHTTPClientTransport(serverUrl, {
123126
* authProvider: provider
124127
* });
128+
* ```
125129
*/
126130
export class ClientCredentialsProvider implements OAuthClientProvider {
127131
private _tokens?: OAuthTokens;
@@ -219,9 +223,11 @@ export interface PrivateKeyJwtProviderOptions {
219223
* OAuth provider for client_credentials grant with private_key_jwt authentication.
220224
*
221225
* This provider is designed for machine-to-machine authentication where
222-
* the client authenticates using a signed JWT assertion (RFC 7523 Section 2.2).
226+
* the client authenticates using a signed JWT assertion
227+
* ({@link https://datatracker.ietf.org/doc/html/rfc7523#section-2.2 | RFC 7523 Section 2.2}).
223228
*
224229
* @example
230+
* ```typescript
225231
* const provider = new PrivateKeyJwtProvider({
226232
* clientId: 'my-client',
227233
* privateKey: pemEncodedPrivateKey,
@@ -231,6 +237,7 @@ export interface PrivateKeyJwtProviderOptions {
231237
* const transport = new StreamableHTTPClientTransport(serverUrl, {
232238
* authProvider: provider
233239
* });
240+
* ```
234241
*/
235242
export class PrivateKeyJwtProvider implements OAuthClientProvider {
236243
private _tokens?: OAuthTokens;

packages/client/src/client/streamableHttp.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface StartSSEOptions {
4444

4545
/**
4646
* Override Message ID to associate with the replay message
47-
* so that response can be associate with the new resumed request.
47+
* so that the response can be associated with the new resumed request.
4848
*/
4949
replayMessageId?: string | number;
5050
}
@@ -255,7 +255,7 @@ export class StreamableHTTPClientTransport implements Transport {
255255
}
256256

257257
/**
258-
* Calculates the next reconnection delay using backoff algorithm
258+
* Calculates the next reconnection delay using a backoff algorithm
259259
*
260260
* @param attempt Current reconnection attempt count for the specific stream
261261
* @returns Time to wait in milliseconds before next reconnection attempt
@@ -463,7 +463,7 @@ export class StreamableHTTPClientTransport implements Transport {
463463
const { resumptionToken, onresumptiontoken } = options || {};
464464

465465
if (resumptionToken) {
466-
// If we have at last event ID, we need to reconnect the SSE stream
466+
// If we have a last event ID, we need to reconnect the SSE stream
467467
this._startOrAuthSse({ resumptionToken, replayMessageId: isJSONRPCRequest(message) ? message.id : undefined }).catch(
468468
error => this.onerror?.(error)
469469
);

packages/client/test/client/authExtensions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ describe('createPrivateKeyJwtAuth', () => {
191191
const params = new URLSearchParams();
192192

193193
await expect(addClientAuth(new Headers(), params, 'https://auth.example.com/token', undefined)).rejects.toThrow(
194-
'crypto is not available, please ensure you add have Web Crypto API support for older Node.js versions'
194+
'crypto is not available, please ensure you have Web Crypto API support for older Node.js versions'
195195
);
196196
} finally {
197197
// Restore original crypto to avoid affecting other tests

packages/core/src/auth/errors.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type { OAuthErrorResponse } from '../shared/auth.js';
22

33
/**
4-
* OAuth error codes as defined by RFC 6749 and extensions.
4+
* OAuth error codes as defined by {@link https://datatracker.ietf.org/doc/html/rfc6749#section-5.2 | RFC 6749}
5+
* and extensions.
56
*/
67
export enum OAuthErrorCode {
78
/**

packages/core/src/experimental/tasks/interfaces.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export interface QueuedError extends BaseQueuedMessage {
9797
* All methods are async to support external storage implementations.
9898
* All data in QueuedMessage must be JSON-serializable.
9999
*
100+
* @see {@linkcode InMemoryTaskMessageQueue} for a reference implementation
100101
* @experimental
101102
*/
102103
export interface TaskMessageQueue {
@@ -157,6 +158,7 @@ export interface CreateTaskOptions {
157158
* Similar to Transport, this allows pluggable task storage implementations
158159
* (in-memory, database, distributed cache, etc.).
159160
*
161+
* @see {@linkcode InMemoryTaskStore} for a reference implementation
160162
* @experimental
161163
*/
162164
export interface TaskStore {

packages/core/src/shared/auth.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ export const OAuthMetadataSchema = z.looseObject({
7171

7272
/**
7373
* OpenID Connect Discovery 1.0 Provider Metadata
74-
* see: https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
74+
*
75+
* @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
7576
*/
7677
export const OpenIdProviderMetadataSchema = z.looseObject({
7778
issuer: z.string(),
@@ -148,7 +149,7 @@ export const OAuthErrorResponseSchema = z.object({
148149
});
149150

150151
/**
151-
* Optional version of SafeUrlSchema that allows empty string for retrocompatibility on tos_uri and logo_uri
152+
* Optional version of SafeUrlSchema that allows empty string for backward compatibility on tos_uri and logo_uri
152153
*/
153154
// eslint-disable-next-line unicorn/no-useless-undefined
154155
export const OptionalSafeUrlSchema = SafeUrlSchema.optional().or(z.literal('').transform(() => undefined));

packages/core/src/shared/authUtils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
/**
66
* Converts a server URL to a resource URL by removing the fragment.
7-
* RFC 8707 section 2 states that resource URIs "MUST NOT include a fragment component".
7+
* {@link https://datatracker.ietf.org/doc/html/rfc8707#section-2 | RFC 8707 section 2}
8+
* states that resource URIs "MUST NOT include a fragment component".
89
* Keeps everything else unchanged (scheme, domain, port, path, query).
910
*/
1011
export function resourceUrlFromServerUrl(url: URL | string): URL {

0 commit comments

Comments
 (0)