xmcp 0.1.7 → 0.1.8

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.
@@ -1,2 +1,6 @@
1
- import { type RequestHandler } from "express";
2
- export type Middleware = RequestHandler | RequestHandler[];
1
+ import { type RequestHandler, type Router } from "express";
2
+ export type RequestHandlerAndRouter = {
3
+ middleware: RequestHandler;
4
+ router: Router;
5
+ };
6
+ export type XmcpMiddleware = RequestHandler | RequestHandlerAndRouter;
@@ -20,13 +20,60 @@ export interface ToolMetadata {
20
20
  /** Optional hints about tool behavior */
21
21
  annotations?: ToolAnnotations;
22
22
  }
23
- export interface Tool {
24
- type: string;
25
- handler: (args: any) => any;
26
- metadata: ToolMetadata;
27
- schema: Record<string, z.ZodType>;
28
- }
29
23
  export type ToolSchema = Record<string, z.ZodType<unknown, z.ZodTypeDef, unknown>>;
24
+ /**
25
+ * Extra arguments passed to MCP tool functions.
26
+ */
27
+ export interface ToolExtraArguments {
28
+ /** An abort signal used to communicate if the request was cancelled from the sender's side */
29
+ signal: AbortSignal;
30
+ /** Information about a validated access token, provided to request handlers */
31
+ authInfo?: {
32
+ /** The access token */
33
+ token: string;
34
+ /** The client ID associated with this token */
35
+ clientId: string;
36
+ /** Scopes associated with this token */
37
+ scopes: string[];
38
+ /** When the token expires (in seconds since epoch) */
39
+ expiresAt?: number;
40
+ /** The RFC 8707 resource server identifier for which this token is valid */
41
+ resource?: URL;
42
+ /** Additional data associated with the token */
43
+ extra?: Record<string, unknown>;
44
+ };
45
+ /** The session ID from the transport, if available */
46
+ sessionId?: string;
47
+ /** Metadata from the original request */
48
+ _meta?: {
49
+ /** Progress token for tracking long-running operations */
50
+ progressToken?: string | number;
51
+ };
52
+ /** The JSON-RPC ID of the request being handled */
53
+ requestId: string | number;
54
+ /** The original HTTP request information */
55
+ requestInfo?: {
56
+ /** The headers of the request */
57
+ headers: Record<string, string | string[] | undefined>;
58
+ };
59
+ /** Sends a notification that relates to the current request being handled */
60
+ sendNotification: (notification: any) => Promise<void>;
61
+ /** Sends a request that relates to the current request being handled */
62
+ sendRequest: <U extends z.ZodType<object>>(request: any, resultSchema: U, options?: {
63
+ /** Progress notification callback */
64
+ onprogress?: (progress: any) => void;
65
+ /** Abort signal for cancelling the request */
66
+ signal?: AbortSignal;
67
+ /** Request timeout in milliseconds */
68
+ timeout?: number;
69
+ /** Whether receiving progress notifications resets the timeout */
70
+ resetTimeoutOnProgress?: boolean;
71
+ /** Maximum total time to wait for a response */
72
+ maxTotalTimeout?: number;
73
+ /** Additional transport-specific options */
74
+ [key: string]: unknown;
75
+ }) => Promise<z.infer<U>>;
76
+ }
30
77
  export type InferSchema<T extends ToolSchema> = {
31
78
  [K in keyof T]: z.infer<T[K]>;
32
79
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "xmcp",
3
3
  "description": "The MCP framework",
4
- "version": "0.1.7",
4
+ "version": "0.1.8",
5
5
  "author": {
6
6
  "name": "Basement Studio",
7
7
  "email": "hello@basement.studio",
@@ -1,9 +0,0 @@
1
- import { IncomingHttpHeaders } from "http";
2
- export interface HttpContext {
3
- id: string;
4
- headers: IncomingHttpHeaders;
5
- }
6
- export declare const httpContext: import("../../../utils/context").Context<HttpContext>;
7
- export declare const setHttpContext: (data: Partial<HttpContext>) => void;
8
- export declare const getHttpContext: () => HttpContext;
9
- export declare const httpContextProvider: (initialValue: HttpContext, callback: () => void) => void;