@tmcp/transport-http 0.9.0-next.0 → 0.9.1
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/package.json +12 -10
- package/types/index.d.ts +54 -0
- package/types/index.d.ts.map +1 -0
- package/types/request-headers.d.ts +16 -0
- package/types/request-headers.d.ts.map +1 -0
- package/src/types/index.d.ts +0 -61
- package/src/types/index.d.ts.map +0 -21
- /package/{src → types}/type-utils.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmcp/transport-http",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Transport for TMCP using HTTP",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "src/index.js",
|
|
8
|
-
"types": "
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"types": "./
|
|
11
|
+
"types": "./types/index.d.ts",
|
|
12
12
|
"default": "./src/index.js"
|
|
13
13
|
},
|
|
14
14
|
"./package.json": "./package.json"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
|
-
"src/**/*"
|
|
17
|
+
"src/**/*",
|
|
18
|
+
"types/**/*",
|
|
19
|
+
"!src/**/*.d.ts"
|
|
18
20
|
],
|
|
19
21
|
"peerDependencies": {
|
|
20
22
|
"tmcp": "^1.20.0-next.0 || ^1.20.0",
|
|
@@ -37,25 +39,25 @@
|
|
|
37
39
|
},
|
|
38
40
|
"dependencies": {
|
|
39
41
|
"esm-env": "^1.2.2",
|
|
40
|
-
"@tmcp/session-manager": "^0.3.
|
|
42
|
+
"@tmcp/session-manager": "^0.3.1"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
45
|
"@modelcontextprotocol/sdk": "^1.17.1",
|
|
44
46
|
"@remix-run/node-fetch-server": "^0.13.0",
|
|
45
47
|
"@types/node": "^24.0.15",
|
|
46
|
-
"dts-buddy": "^0.6.2",
|
|
47
48
|
"publint": "^0.3.12",
|
|
48
49
|
"valibot": "^1.1.0",
|
|
49
50
|
"vitest": "^4.0.0",
|
|
50
|
-
"@tmcp/adapter-valibot": "^0.1.
|
|
51
|
-
"@tmcp/auth": "^0.5.
|
|
52
|
-
"tmcp": "^1.
|
|
51
|
+
"@tmcp/adapter-valibot": "^0.1.7",
|
|
52
|
+
"@tmcp/auth": "^0.5.1",
|
|
53
|
+
"@tmcp/internal-ts-helpers": "^1.0.0",
|
|
54
|
+
"tmcp": "^1.20.1"
|
|
53
55
|
},
|
|
54
56
|
"publishConfig": {
|
|
55
57
|
"access": "public"
|
|
56
58
|
},
|
|
57
59
|
"scripts": {
|
|
58
|
-
"generate:types": "
|
|
60
|
+
"generate:types": "generate-types && publint",
|
|
59
61
|
"prepublish": "pnpm generate:types",
|
|
60
62
|
"test": "vitest --run"
|
|
61
63
|
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export class HttpTransport<TCustom extends Record<string, unknown> | undefined = undefined> {
|
|
2
|
+
constructor(server: McpServer<any, TCustom>, options?: HttpTransportOptions);
|
|
3
|
+
/**
|
|
4
|
+
* Gracefully complete one active per-request subscription.
|
|
5
|
+
*/
|
|
6
|
+
closeSubscription(response: Response): Promise<boolean>;
|
|
7
|
+
/**
|
|
8
|
+
* Close every active per-request subscription owned by this transport.
|
|
9
|
+
*/
|
|
10
|
+
close(): Promise<void>;
|
|
11
|
+
respond(request: Request, ctx?: TCustom): Promise<Response | null>;
|
|
12
|
+
#private;
|
|
13
|
+
}
|
|
14
|
+
export type CorsConfig = {
|
|
15
|
+
origin?: string | string[] | boolean;
|
|
16
|
+
methods?: string[];
|
|
17
|
+
allowedHeaders?: string[];
|
|
18
|
+
exposedHeaders?: string[];
|
|
19
|
+
credentials?: boolean;
|
|
20
|
+
maxAge?: number;
|
|
21
|
+
};
|
|
22
|
+
export type HttpTransportOptions = {
|
|
23
|
+
getSessionId?: () => string;
|
|
24
|
+
path?: string | null;
|
|
25
|
+
oauth?: OAuth<"built">;
|
|
26
|
+
cors?: CorsConfig | boolean;
|
|
27
|
+
allowedOrigins?: string | string[] | true;
|
|
28
|
+
sessionManager?: {
|
|
29
|
+
streams?: StreamSessionManager;
|
|
30
|
+
info?: OptionalizeSessionManager<InfoSessionManager>;
|
|
31
|
+
};
|
|
32
|
+
subscriptionManager?: SubscriptionManager;
|
|
33
|
+
disableSse?: boolean;
|
|
34
|
+
};
|
|
35
|
+
export type SubscriptionRegistration = {
|
|
36
|
+
promise: Promise<boolean>;
|
|
37
|
+
resolve: (registered: boolean) => void;
|
|
38
|
+
};
|
|
39
|
+
export type SubscriptionSink = {
|
|
40
|
+
controller?: ReadableStreamDefaultController;
|
|
41
|
+
state: "open" | "cancelled" | "disconnected";
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
subscription?: {
|
|
44
|
+
id: string | number;
|
|
45
|
+
registration: SubscriptionRegistration;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
import type { McpServer } from "tmcp";
|
|
49
|
+
import type { OAuth } from "@tmcp/auth";
|
|
50
|
+
import type { StreamSessionManager } from "@tmcp/session-manager";
|
|
51
|
+
import type { InfoSessionManager } from "@tmcp/session-manager";
|
|
52
|
+
import type { OptionalizeSessionManager } from "./type-utils.js";
|
|
53
|
+
import type { SubscriptionManager } from "@tmcp/session-manager";
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAgEA,2BAFoD,OAAO,SAA7C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAU;IAqDjD,oBAHW,UAAU,GAAG,EAAE,OAAO,CAAC,YACvB,oBAAoB,EAwK9B;;;;IAusBD,4BAHW,QAAQ,GAC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BAAwB,CAAA;KAAE,CAAA;CAAE;+BAhCzK,MAAM;2BACnB,YAAY;0CAC2C,uBAAuB;wCAAvB,uBAAuB;+CAC3D,iBAAiB;yCADmB,uBAAuB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate the standard headers mirrored from a per-request JSON-RPC
|
|
3
|
+
* request or notification.
|
|
4
|
+
*/
|
|
5
|
+
export function validate_request_headers(headers: Headers, message: Record<string, any>): void;
|
|
6
|
+
/**
|
|
7
|
+
* Validate recognized `Mcp-Param-*` headers against annotated tool
|
|
8
|
+
* parameters.
|
|
9
|
+
*/
|
|
10
|
+
export function validate_tool_parameter_headers(headers: Headers, input_schema: Record<string, unknown>, args: Record<string, unknown>): void;
|
|
11
|
+
export type ParameterHeader = {
|
|
12
|
+
name: string;
|
|
13
|
+
path: string[];
|
|
14
|
+
type: "string" | "boolean" | "integer";
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=request-headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-headers.d.ts","sourceRoot":"","sources":["../src/request-headers.js"],"names":[],"mappings":";;;;AA4DA,kDAHW,OAAO,WACP,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAiC7B;;;;;AA4HD,yDAJW,OAAO,gBACP,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAqCjC;8BA7IY;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;CAAE"}
|
package/src/types/index.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
declare module '@tmcp/transport-http' {
|
|
2
|
-
import type { McpServer } from 'tmcp';
|
|
3
|
-
import type { OAuth } from '@tmcp/auth';
|
|
4
|
-
import type { StreamSessionManager, InfoSessionManager, SubscriptionManager } from '@tmcp/session-manager';
|
|
5
|
-
export class HttpTransport<TCustom extends Record<string, unknown> | undefined = undefined> {
|
|
6
|
-
|
|
7
|
-
constructor(server: McpServer<any, TCustom>, options?: HttpTransportOptions);
|
|
8
|
-
/**
|
|
9
|
-
* Gracefully complete one active per-request subscription.
|
|
10
|
-
* */
|
|
11
|
-
closeSubscription(response: Response): Promise<boolean>;
|
|
12
|
-
/**
|
|
13
|
-
* Close every active per-request subscription owned by this transport.
|
|
14
|
-
*/
|
|
15
|
-
close(): Promise<void>;
|
|
16
|
-
|
|
17
|
-
respond(request: Request, ctx?: TCustom): Promise<Response | null>;
|
|
18
|
-
#private;
|
|
19
|
-
}
|
|
20
|
-
export type CorsConfig = {
|
|
21
|
-
origin?: string | string[] | boolean;
|
|
22
|
-
methods?: string[];
|
|
23
|
-
allowedHeaders?: string[];
|
|
24
|
-
exposedHeaders?: string[];
|
|
25
|
-
credentials?: boolean;
|
|
26
|
-
maxAge?: number;
|
|
27
|
-
};
|
|
28
|
-
export type HttpTransportOptions = {
|
|
29
|
-
getSessionId?: () => string;
|
|
30
|
-
path?: string | null;
|
|
31
|
-
oauth?: OAuth<"built">;
|
|
32
|
-
cors?: CorsConfig | boolean;
|
|
33
|
-
allowedOrigins?: string | string[] | true;
|
|
34
|
-
sessionManager?: {
|
|
35
|
-
streams?: StreamSessionManager;
|
|
36
|
-
info?: OptionalizeSessionManager<InfoSessionManager>;
|
|
37
|
-
};
|
|
38
|
-
subscriptionManager?: SubscriptionManager;
|
|
39
|
-
disableSse?: boolean;
|
|
40
|
-
};
|
|
41
|
-
export type SubscriptionRegistration = {
|
|
42
|
-
promise: Promise<boolean>;
|
|
43
|
-
resolve: (registered: boolean) => void;
|
|
44
|
-
};
|
|
45
|
-
export type SubscriptionSink = {
|
|
46
|
-
controller?: ReadableStreamDefaultController;
|
|
47
|
-
state: "open" | "cancelled" | "disconnected";
|
|
48
|
-
signal?: AbortSignal;
|
|
49
|
-
subscription?: {
|
|
50
|
-
id: string | number;
|
|
51
|
-
registration: SubscriptionRegistration;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
type ToOmit = 'removeSubscription';
|
|
55
|
-
|
|
56
|
-
type OptionalizeSessionManager<TInfoSessionManager extends InfoSessionManager> = Omit<TInfoSessionManager, ToOmit> & Partial<Pick<TInfoSessionManager, ToOmit>>;
|
|
57
|
-
|
|
58
|
-
export {};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
//# sourceMappingURL=index.d.ts.map
|
package/src/types/index.d.ts.map
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"file": "index.d.ts",
|
|
4
|
-
"names": [
|
|
5
|
-
"HttpTransport",
|
|
6
|
-
"SubscriptionRegistration",
|
|
7
|
-
"SubscriptionSink",
|
|
8
|
-
"ToOmit",
|
|
9
|
-
"OptionalizeSessionManager"
|
|
10
|
-
],
|
|
11
|
-
"sources": [
|
|
12
|
-
"../index.js",
|
|
13
|
-
"../type-utils.d.ts"
|
|
14
|
-
],
|
|
15
|
-
"sourcesContent": [
|
|
16
|
-
null,
|
|
17
|
-
null
|
|
18
|
-
],
|
|
19
|
-
"mappings": ";;;;cAgEaA,aAAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAhC0DC,wBAAwBA;;;;aACuGC,gBAAgBA;;;;;;;;;MC9B9NC,MAAMA;;MAECC,yBAAyBA",
|
|
20
|
-
"ignoreList": []
|
|
21
|
-
}
|
|
File without changes
|