mcp4openapi 0.1.0 → 0.2.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/README.md +137 -95
- package/dist/scripts/validate-profile.js +3 -3
- package/dist/scripts/validate-profile.js.map +1 -1
- package/dist/src/composite-executor.d.ts +3 -1
- package/dist/src/composite-executor.d.ts.map +1 -1
- package/dist/src/composite-executor.js +16 -5
- package/dist/src/composite-executor.js.map +1 -1
- package/dist/src/constants.d.ts +49 -0
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +49 -0
- package/dist/src/constants.js.map +1 -1
- package/dist/src/errors.d.ts +6 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +13 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/generated-schemas.d.ts +832 -52
- package/dist/src/generated-schemas.d.ts.map +1 -1
- package/dist/src/generated-schemas.js +31 -8
- package/dist/src/generated-schemas.js.map +1 -1
- package/dist/src/http-client-factory.d.ts.map +1 -1
- package/dist/src/http-client-factory.js +14 -3
- package/dist/src/http-client-factory.js.map +1 -1
- package/dist/src/http-transport.d.ts +65 -0
- package/dist/src/http-transport.d.ts.map +1 -1
- package/dist/src/http-transport.js +921 -77
- package/dist/src/http-transport.js.map +1 -1
- package/dist/src/index.js +108 -8
- package/dist/src/index.js.map +1 -1
- package/dist/src/interceptors.d.ts +3 -0
- package/dist/src/interceptors.d.ts.map +1 -1
- package/dist/src/interceptors.js +76 -8
- package/dist/src/interceptors.js.map +1 -1
- package/dist/src/logger.d.ts +1 -1
- package/dist/src/logger.js +3 -3
- package/dist/src/logger.js.map +1 -1
- package/dist/src/mcp-server.d.ts +33 -0
- package/dist/src/mcp-server.d.ts.map +1 -1
- package/dist/src/mcp-server.js +263 -54
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/oauth-provider.d.ts +92 -0
- package/dist/src/oauth-provider.d.ts.map +1 -0
- package/dist/src/oauth-provider.js +588 -0
- package/dist/src/oauth-provider.js.map +1 -0
- package/dist/src/openapi-parser.d.ts +16 -0
- package/dist/src/openapi-parser.d.ts.map +1 -1
- package/dist/src/openapi-parser.js +141 -6
- package/dist/src/openapi-parser.js.map +1 -1
- package/dist/src/profile-loader.d.ts +2 -2
- package/dist/src/profile-loader.d.ts.map +1 -1
- package/dist/src/profile-loader.js +45 -24
- package/dist/src/profile-loader.js.map +1 -1
- package/dist/src/testing/fixtures.d.ts +189 -0
- package/dist/src/testing/fixtures.d.ts.map +1 -1
- package/dist/src/testing/fixtures.js +144 -0
- package/dist/src/testing/fixtures.js.map +1 -1
- package/dist/src/testing/mock-gitlab-server.d.ts +26 -17
- package/dist/src/testing/mock-gitlab-server.d.ts.map +1 -1
- package/dist/src/testing/mock-gitlab-server.js +567 -304
- package/dist/src/testing/mock-gitlab-server.js.map +1 -1
- package/dist/src/types/http-transport.d.ts +16 -0
- package/dist/src/types/http-transport.d.ts.map +1 -1
- package/dist/src/types/openapi.d.ts +5 -0
- package/dist/src/types/openapi.d.ts.map +1 -1
- package/dist/src/types/profile.d.ts +112 -3
- package/dist/src/types/profile.d.ts.map +1 -1
- package/dist/src/validation-utils.d.ts +12 -0
- package/dist/src/validation-utils.d.ts.map +1 -1
- package/dist/src/validation-utils.js +17 -0
- package/dist/src/validation-utils.js.map +1 -1
- package/package.json +12 -3
- package/profile-schema.json +169 -7
- package/dist/composite-executor.d.ts +0 -65
- package/dist/composite-executor.d.ts.map +0 -1
- package/dist/composite-executor.js +0 -147
- package/dist/composite-executor.js.map +0 -1
- package/dist/constants.d.ts +0 -36
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -36
- package/dist/constants.js.map +0 -1
- package/dist/http-transport.d.ts +0 -195
- package/dist/http-transport.d.ts.map +0 -1
- package/dist/http-transport.js +0 -760
- package/dist/http-transport.js.map +0 -1
- package/dist/interceptors.d.ts +0 -74
- package/dist/interceptors.d.ts.map +0 -1
- package/dist/interceptors.js +0 -220
- package/dist/interceptors.js.map +0 -1
- package/dist/logger.d.ts +0 -81
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -264
- package/dist/logger.js.map +0 -1
- package/dist/mcp-server.d.ts +0 -110
- package/dist/mcp-server.d.ts.map +0 -1
- package/dist/mcp-server.js +0 -568
- package/dist/mcp-server.js.map +0 -1
- package/dist/metrics.d.ts +0 -86
- package/dist/metrics.d.ts.map +0 -1
- package/dist/metrics.js +0 -229
- package/dist/metrics.js.map +0 -1
- package/dist/openapi-parser.d.ts +0 -35
- package/dist/openapi-parser.d.ts.map +0 -1
- package/dist/openapi-parser.js +0 -160
- package/dist/openapi-parser.js.map +0 -1
- package/dist/profile-loader.d.ts +0 -25
- package/dist/profile-loader.d.ts.map +0 -1
- package/dist/profile-loader.js +0 -134
- package/dist/profile-loader.js.map +0 -1
- package/dist/schema-validator.d.ts +0 -32
- package/dist/schema-validator.d.ts.map +0 -1
- package/dist/schema-validator.js +0 -126
- package/dist/schema-validator.js.map +0 -1
- package/dist/testing/fixtures.d.ts +0 -186
- package/dist/testing/fixtures.d.ts.map +0 -1
- package/dist/testing/fixtures.js +0 -135
- package/dist/testing/fixtures.js.map +0 -1
- package/dist/testing/http-integration.test.d.ts +0 -7
- package/dist/testing/http-integration.test.d.ts.map +0 -1
- package/dist/testing/http-integration.test.js +0 -383
- package/dist/testing/http-integration.test.js.map +0 -1
- package/dist/testing/http-multiuser.test.d.ts +0 -10
- package/dist/testing/http-multiuser.test.d.ts.map +0 -1
- package/dist/testing/http-multiuser.test.js +0 -255
- package/dist/testing/http-multiuser.test.js.map +0 -1
- package/dist/testing/integration.test.d.ts +0 -8
- package/dist/testing/integration.test.d.ts.map +0 -1
- package/dist/testing/integration.test.js +0 -247
- package/dist/testing/integration.test.js.map +0 -1
- package/dist/testing/mock-gitlab-server.d.ts +0 -34
- package/dist/testing/mock-gitlab-server.d.ts.map +0 -1
- package/dist/testing/mock-gitlab-server.js +0 -224
- package/dist/testing/mock-gitlab-server.js.map +0 -1
- package/dist/testing/test-types.d.ts +0 -59
- package/dist/testing/test-types.d.ts.map +0 -1
- package/dist/testing/test-types.js +0 -7
- package/dist/testing/test-types.js.map +0 -1
- package/dist/tool-generator.d.ts +0 -43
- package/dist/tool-generator.d.ts.map +0 -1
- package/dist/tool-generator.js +0 -123
- package/dist/tool-generator.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/http-transport.d.ts +0 -39
- package/dist/types/http-transport.d.ts.map +0 -1
- package/dist/types/http-transport.js +0 -8
- package/dist/types/http-transport.js.map +0 -1
- package/dist/types/openapi.d.ts +0 -50
- package/dist/types/openapi.d.ts.map +0 -1
- package/dist/types/openapi.js +0 -9
- package/dist/types/openapi.js.map +0 -1
- package/dist/types/profile.d.ts +0 -76
- package/dist/types/profile.d.ts.map +0 -1
- package/dist/types/profile.js +0 -9
- package/dist/types/profile.js.map +0 -1
package/dist/http-transport.d.ts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP Streamable Transport for MCP
|
|
3
|
-
*
|
|
4
|
-
* Implements MCP Specification 2025-03-26
|
|
5
|
-
* https://modelcontextprotocol.io/specification/2025-03-26/basic/transports
|
|
6
|
-
*
|
|
7
|
-
* Why: Enables remote MCP server access with SSE streaming, session management,
|
|
8
|
-
* and resumability for reliable communication over HTTP.
|
|
9
|
-
*/
|
|
10
|
-
import type { Logger } from './logger.js';
|
|
11
|
-
import type { HttpTransportConfig } from './types/http-transport.js';
|
|
12
|
-
export declare class HttpTransport {
|
|
13
|
-
private app;
|
|
14
|
-
private server;
|
|
15
|
-
private sessions;
|
|
16
|
-
private config;
|
|
17
|
-
private logger;
|
|
18
|
-
private metrics;
|
|
19
|
-
private cleanupInterval;
|
|
20
|
-
private messageHandler;
|
|
21
|
-
constructor(config: HttpTransportConfig, logger: Logger);
|
|
22
|
-
/**
|
|
23
|
-
* Setup Express middleware
|
|
24
|
-
*
|
|
25
|
-
* Why: Security (Origin validation), JSON parsing, session extraction, metrics
|
|
26
|
-
*/
|
|
27
|
-
private setupMiddleware;
|
|
28
|
-
private hasWarnedAboutBinding;
|
|
29
|
-
/**
|
|
30
|
-
* Check if origin is allowed
|
|
31
|
-
*
|
|
32
|
-
* Why: Prevent DNS rebinding attacks
|
|
33
|
-
*
|
|
34
|
-
* Supports:
|
|
35
|
-
* - Exact hostname: 'example.com', 'api.example.com'
|
|
36
|
-
* - Wildcard subdomain: '*.example.com'
|
|
37
|
-
* - IPv4 CIDR: '192.168.1.0/24', '10.0.0.0/8'
|
|
38
|
-
* - IPv4 exact: '192.168.1.100'
|
|
39
|
-
*/
|
|
40
|
-
private isAllowedOrigin;
|
|
41
|
-
/**
|
|
42
|
-
* Match hostname against allowed origin pattern
|
|
43
|
-
*
|
|
44
|
-
* Supports:
|
|
45
|
-
* - Exact match: 'example.com' === 'example.com'
|
|
46
|
-
* - Wildcard: '*.example.com' matches 'api.example.com', 'web.example.com'
|
|
47
|
-
* - CIDR: '192.168.1.0/24' matches '192.168.1.1' through '192.168.1.254'
|
|
48
|
-
*/
|
|
49
|
-
private matchOrigin;
|
|
50
|
-
/**
|
|
51
|
-
* Check if IP address is within CIDR range
|
|
52
|
-
*
|
|
53
|
-
* Example: '192.168.1.50' matches '192.168.1.0/24'
|
|
54
|
-
*/
|
|
55
|
-
private matchCIDR;
|
|
56
|
-
/**
|
|
57
|
-
* Convert IPv4 address to 32-bit integer
|
|
58
|
-
*
|
|
59
|
-
* Example: '192.168.1.1' -> 3232235777
|
|
60
|
-
*/
|
|
61
|
-
private ipToInt;
|
|
62
|
-
/**
|
|
63
|
-
* Setup MCP endpoint routes
|
|
64
|
-
*
|
|
65
|
-
* Why: Single endpoint for POST (client→server) and GET (SSE stream)
|
|
66
|
-
*/
|
|
67
|
-
private setupRoutes;
|
|
68
|
-
/**
|
|
69
|
-
* Handle metrics endpoint
|
|
70
|
-
*
|
|
71
|
-
* Why: Prometheus scraping endpoint
|
|
72
|
-
*/
|
|
73
|
-
private handleMetrics;
|
|
74
|
-
/**
|
|
75
|
-
* Validate token format and length
|
|
76
|
-
*
|
|
77
|
-
* Why centralized: Single source of truth for token validation rules
|
|
78
|
-
*/
|
|
79
|
-
private validateToken;
|
|
80
|
-
/**
|
|
81
|
-
* Extract and validate auth token from request headers
|
|
82
|
-
*
|
|
83
|
-
* Supports:
|
|
84
|
-
* - Authorization: Bearer <token>
|
|
85
|
-
* - X-API-Token: <token>
|
|
86
|
-
*
|
|
87
|
-
* Why strict validation: Prevents header injection attacks
|
|
88
|
-
*/
|
|
89
|
-
private extractAuthToken;
|
|
90
|
-
/**
|
|
91
|
-
* Handle POST requests - Client sending messages to server
|
|
92
|
-
*
|
|
93
|
-
* MCP Spec: POST can contain requests, notifications, or responses
|
|
94
|
-
*/
|
|
95
|
-
private handlePost;
|
|
96
|
-
/**
|
|
97
|
-
* Handle GET requests - Client opening SSE stream for server messages
|
|
98
|
-
*
|
|
99
|
-
* MCP Spec: GET opens SSE stream for server-initiated requests/notifications
|
|
100
|
-
*/
|
|
101
|
-
private handleGet;
|
|
102
|
-
/**
|
|
103
|
-
* Handle DELETE requests - Client terminating session
|
|
104
|
-
*
|
|
105
|
-
* MCP Spec: DELETE explicitly terminates session
|
|
106
|
-
*/
|
|
107
|
-
private handleDelete;
|
|
108
|
-
/**
|
|
109
|
-
* Start SSE response for a POST request
|
|
110
|
-
*
|
|
111
|
-
* Why: Returns response via SSE stream, allows server-initiated messages
|
|
112
|
-
*/
|
|
113
|
-
private startSSEResponse;
|
|
114
|
-
/**
|
|
115
|
-
* Start SSE stream for GET request
|
|
116
|
-
*
|
|
117
|
-
* Why: Allows server to send requests/notifications to client
|
|
118
|
-
*/
|
|
119
|
-
private startSSEStream;
|
|
120
|
-
/**
|
|
121
|
-
* Replay messages after Last-Event-ID
|
|
122
|
-
*
|
|
123
|
-
* Why: Resumability - client can reconnect and receive missed messages
|
|
124
|
-
*/
|
|
125
|
-
private replayMessages;
|
|
126
|
-
/**
|
|
127
|
-
* Send message to client via SSE
|
|
128
|
-
*
|
|
129
|
-
* Why: Server-initiated requests/notifications
|
|
130
|
-
*/
|
|
131
|
-
sendToClient(sessionId: string, message: unknown): void;
|
|
132
|
-
/**
|
|
133
|
-
* Check if request is initialization
|
|
134
|
-
*/
|
|
135
|
-
private isInitializeRequest;
|
|
136
|
-
/**
|
|
137
|
-
* Determine message type (request, notification, response)
|
|
138
|
-
*/
|
|
139
|
-
private getMessageType;
|
|
140
|
-
/**
|
|
141
|
-
* Create new session
|
|
142
|
-
*
|
|
143
|
-
* Why: Stateful sessions for MCP protocol
|
|
144
|
-
*/
|
|
145
|
-
private createSession;
|
|
146
|
-
/**
|
|
147
|
-
* Update session activity timestamp
|
|
148
|
-
*/
|
|
149
|
-
private updateSessionActivity;
|
|
150
|
-
/**
|
|
151
|
-
* Destroy session and cleanup resources
|
|
152
|
-
*
|
|
153
|
-
* Why: Free memory, close streams
|
|
154
|
-
*/
|
|
155
|
-
private destroySession;
|
|
156
|
-
/**
|
|
157
|
-
* Session destruction listeners for cleanup in other components
|
|
158
|
-
*/
|
|
159
|
-
private sessionDestroyedListeners;
|
|
160
|
-
/**
|
|
161
|
-
* Register listener for session destruction events
|
|
162
|
-
*
|
|
163
|
-
* Why: Allows MCPServer to cleanup per-session HTTP clients
|
|
164
|
-
*/
|
|
165
|
-
onSessionDestroyed(listener: (sessionId: string) => void): void;
|
|
166
|
-
/**
|
|
167
|
-
* Notify all listeners about session destruction
|
|
168
|
-
*/
|
|
169
|
-
private notifySessionDestroyed;
|
|
170
|
-
/**
|
|
171
|
-
* Cleanup expired sessions
|
|
172
|
-
*
|
|
173
|
-
* Why: Prevent memory leaks, enforce session timeout
|
|
174
|
-
*/
|
|
175
|
-
private cleanupExpiredSessions;
|
|
176
|
-
/**
|
|
177
|
-
* Get auth token from session
|
|
178
|
-
*
|
|
179
|
-
* Why public: Allows MCPServer to securely access session tokens without breaking encapsulation
|
|
180
|
-
*/
|
|
181
|
-
getSessionToken(sessionId: string): string | undefined;
|
|
182
|
-
/**
|
|
183
|
-
* Set message handler for processing incoming JSON-RPC messages
|
|
184
|
-
*/
|
|
185
|
-
setMessageHandler(handler: (message: unknown, sessionId?: string) => Promise<unknown>): void;
|
|
186
|
-
/**
|
|
187
|
-
* Start HTTP server
|
|
188
|
-
*/
|
|
189
|
-
start(): Promise<void>;
|
|
190
|
-
/**
|
|
191
|
-
* Stop HTTP server
|
|
192
|
-
*/
|
|
193
|
-
stop(): Promise<void>;
|
|
194
|
-
}
|
|
195
|
-
//# sourceMappingURL=http-transport.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-transport.d.ts","sourceRoot":"","sources":["../src/http-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAIV,mBAAmB,EAEpB,MAAM,2BAA2B,CAAC;AAGnC,qBAAa,aAAa;IACxB,OAAO,CAAC,GAAG,CAAsB;IACjC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,QAAQ,CAAuC;IACvD,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,cAAc,CAA6E;gBAEvF,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM;IAiBvD;;;;OAIG;IACH,OAAO,CAAC,eAAe;IA+CvB,OAAO,CAAC,qBAAqB,CAAS;IAEtC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,eAAe;IA8BvB;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;IAoBnB;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAyBjB;;;;OAIG;IACH,OAAO,CAAC,OAAO;IAmBf;;;;OAIG;IACH,OAAO,CAAC,WAAW;IA2BnB;;;;OAIG;YACW,aAAa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