@prefecthq/fastmcp-ts 0.0.2-alpha.0 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { Transport } from '@modelcontextprotocol/sdk/shared/transport';
2
- import { OAuthServerProvider, AuthorizationParams } from '@modelcontextprotocol/sdk/server/auth/provider';
1
+ import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
2
+ import { OAuthServerProvider, AuthorizationParams } from '@modelcontextprotocol/sdk/server/auth/provider.js';
3
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
4
4
  import { Readable, Writable } from 'node:stream';
5
5
  import { Server } from '@modelcontextprotocol/sdk/server';
6
- import { CallToolResult } from '@modelcontextprotocol/sdk/types';
6
+ import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
7
7
  import { Response } from 'express';
8
- import { OAuthClientInformationFull } from '@modelcontextprotocol/sdk/shared/auth';
9
- import { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types';
8
+ import { OAuthClientInformationFull } from '@modelcontextprotocol/sdk/shared/auth.js';
9
+ import { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
10
10
 
11
11
  interface AccessToken {
12
12
  /** The raw bearer token string. */
@@ -230,23 +230,30 @@ interface MiddlewareContext<T = unknown> {
230
230
  readonly mcpContext: McpContext;
231
231
  }
232
232
  type Next<R = unknown> = () => Promise<R>;
233
+ /**
234
+ * A middleware hook. Either call `next()` and return (optionally transforming) its
235
+ * result, or short-circuit by returning your own result without calling `next()`.
236
+ * The return is typed `Promise<unknown>` because a hook can substitute any result
237
+ * shape for the method it intercepts; the framework resolves the concrete type at
238
+ * the call boundary.
239
+ */
233
240
  interface Middleware {
234
241
  /** Called once per Server instance. Use to register notification handlers or other server-level setup. */
235
242
  setup?(server: Server): void;
236
- onRequest?<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
237
- onCallTool?<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
238
- onListTools?<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
239
- onReadResource?<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
240
- onListResources?<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
241
- onListResourceTemplates?<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
242
- onGetPrompt?<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
243
- onListPrompts?<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
243
+ onRequest?(ctx: MiddlewareContext, next: Next): Promise<unknown>;
244
+ onCallTool?(ctx: MiddlewareContext, next: Next): Promise<unknown>;
245
+ onListTools?(ctx: MiddlewareContext, next: Next): Promise<unknown>;
246
+ onReadResource?(ctx: MiddlewareContext, next: Next): Promise<unknown>;
247
+ onListResources?(ctx: MiddlewareContext, next: Next): Promise<unknown>;
248
+ onListResourceTemplates?(ctx: MiddlewareContext, next: Next): Promise<unknown>;
249
+ onGetPrompt?(ctx: MiddlewareContext, next: Next): Promise<unknown>;
250
+ onListPrompts?(ctx: MiddlewareContext, next: Next): Promise<unknown>;
244
251
  }
245
252
  /** Logs every request with method, outcome, and elapsed time. */
246
253
  declare class LoggingMiddleware implements Middleware {
247
254
  private readonly emit;
248
255
  constructor(emit?: (msg: string) => void);
249
- onRequest<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
256
+ onRequest(ctx: MiddlewareContext, next: Next): Promise<unknown>;
250
257
  }
251
258
  /**
252
259
  * Custom cache key function. Receives the full middleware context so callers can
@@ -273,7 +280,7 @@ declare class CachingMiddleware implements Middleware {
273
280
  private readonly _keyFn?;
274
281
  private readonly _cache;
275
282
  constructor(ttl?: number, _keyFn?: CacheKeyFn | undefined);
276
- onRequest<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
283
+ onRequest(ctx: MiddlewareContext, next: Next): Promise<unknown>;
277
284
  }
278
285
  /** Fixed-window counter rate limiter. Resets to full capacity after every windowMs interval. */
279
286
  declare class RateLimitingMiddleware implements Middleware {
@@ -282,13 +289,13 @@ declare class RateLimitingMiddleware implements Middleware {
282
289
  private _tokens;
283
290
  private _lastRefill;
284
291
  constructor(limit: number, windowMs?: number);
285
- onRequest<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
292
+ onRequest(ctx: MiddlewareContext, next: Next): Promise<unknown>;
286
293
  }
287
294
  /** Rejects responses whose JSON serialisation exceeds maxBytes. */
288
295
  declare class SizeLimitingMiddleware implements Middleware {
289
296
  private readonly maxBytes;
290
297
  constructor(maxBytes: number);
291
- onRequest<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
298
+ onRequest(ctx: MiddlewareContext, next: Next): Promise<unknown>;
292
299
  }
293
300
  /**
294
301
  * Normalises errors thrown by handlers to proper MCP shapes:
@@ -302,8 +309,8 @@ declare class SizeLimitingMiddleware implements Middleware {
302
309
  * converted to isError:true tool responses.
303
310
  */
304
311
  declare class ErrorNormalizationMiddleware implements Middleware {
305
- onCallTool<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
306
- onRequest<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
312
+ onCallTool(ctx: MiddlewareContext, next: Next): Promise<unknown>;
313
+ onRequest(ctx: MiddlewareContext, next: Next): Promise<unknown>;
307
314
  }
308
315
  /**
309
316
  * Intercepts `notifications/cancelled` from the client and aborts the matching
@@ -312,7 +319,7 @@ declare class ErrorNormalizationMiddleware implements Middleware {
312
319
  declare class CancellationMiddleware implements Middleware {
313
320
  private readonly _inFlight;
314
321
  setup(server: Server): void;
315
- onRequest<T, R>(ctx: MiddlewareContext<T>, next: Next<R>): Promise<R>;
322
+ onRequest(ctx: MiddlewareContext, next: Next): Promise<unknown>;
316
323
  }
317
324
 
318
325
  interface ToolView {
package/dist/server.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  GetPromptRequestSchema,
15
15
  McpError as McpError3,
16
16
  ErrorCode as ErrorCode3
17
- } from "@modelcontextprotocol/sdk/types";
17
+ } from "@modelcontextprotocol/sdk/types.js";
18
18
  import { randomUUID } from "crypto";
19
19
 
20
20
  // src/server/auth/types.ts
@@ -127,7 +127,7 @@ function createContext(server, requestId, progressToken, auth, sessionState) {
127
127
  }
128
128
 
129
129
  // src/server/middleware.ts
130
- import { McpError, ErrorCode, CancelledNotificationSchema } from "@modelcontextprotocol/sdk/types";
130
+ import { McpError, ErrorCode, CancelledNotificationSchema } from "@modelcontextprotocol/sdk/types.js";
131
131
  var METHOD_HOOK_KEY = {
132
132
  "tools/call": "onCallTool",
133
133
  "tools/list": "onListTools",
@@ -390,7 +390,7 @@ var VersionFilter = class {
390
390
  };
391
391
 
392
392
  // src/server/tool.ts
393
- import { McpError as McpError2, ErrorCode as ErrorCode2 } from "@modelcontextprotocol/sdk/types";
393
+ import { McpError as McpError2, ErrorCode as ErrorCode2 } from "@modelcontextprotocol/sdk/types.js";
394
394
  var Image = class {
395
395
  constructor(buffer, mimeType) {
396
396
  this.buffer = buffer;
@@ -478,7 +478,7 @@ async function toJsonSchema(schema, context) {
478
478
  }
479
479
  }
480
480
  try {
481
- const { z } = await import("./zod-P5QUYVPB.js");
481
+ const { z } = await import("./zod-JRPBLP6C.js");
482
482
  return z.toJSONSchema(
483
483
  schema
484
484
  );
@@ -1904,7 +1904,7 @@ function debugTokenVerifier() {
1904
1904
 
1905
1905
  // src/server/auth/oauth/provider.ts
1906
1906
  import { randomUUID as randomUUID2 } from "crypto";
1907
- import { UnsupportedGrantTypeError } from "@modelcontextprotocol/sdk/server/auth/errors";
1907
+ import { UnsupportedGrantTypeError } from "@modelcontextprotocol/sdk/server/auth/errors.js";
1908
1908
  function oauthProvider(options = {}) {
1909
1909
  const clients = /* @__PURE__ */ new Map();
1910
1910
  const codes = /* @__PURE__ */ new Map();
@@ -2079,13 +2079,13 @@ function oauthProxy(options) {
2079
2079
  }
2080
2080
 
2081
2081
  // src/server/proxy.ts
2082
- import { Client } from "@modelcontextprotocol/sdk/client/index";
2082
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2083
2083
  import {
2084
2084
  CallToolResultSchema,
2085
2085
  ToolListChangedNotificationSchema,
2086
2086
  ResourceListChangedNotificationSchema,
2087
2087
  PromptListChangedNotificationSchema
2088
- } from "@modelcontextprotocol/sdk/types";
2088
+ } from "@modelcontextprotocol/sdk/types.js";
2089
2089
  import { parseTemplate } from "url-template";
2090
2090
  async function buildProxyFromClient(client, options) {
2091
2091
  const cacheTtl = options?.cacheTtl ?? 3e4;