@codemieai/code 0.0.53 → 0.0.55

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.
Files changed (56) hide show
  1. package/README.md +6 -0
  2. package/bin/codemie-mcp-proxy.js +91 -0
  3. package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
  4. package/dist/agents/core/BaseAgentAdapter.js +3 -0
  5. package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
  6. package/dist/agents/plugins/claude/claude.plugin.d.ts.map +1 -1
  7. package/dist/agents/plugins/claude/claude.plugin.js +0 -8
  8. package/dist/agents/plugins/claude/claude.plugin.js.map +1 -1
  9. package/dist/cli/commands/mcp/index.d.ts +3 -0
  10. package/dist/cli/commands/mcp/index.d.ts.map +1 -0
  11. package/dist/cli/commands/mcp/index.js +103 -0
  12. package/dist/cli/commands/mcp/index.js.map +1 -0
  13. package/dist/cli/commands/mcp-proxy.d.ts +13 -0
  14. package/dist/cli/commands/mcp-proxy.d.ts.map +1 -0
  15. package/dist/cli/commands/mcp-proxy.js +53 -0
  16. package/dist/cli/commands/mcp-proxy.js.map +1 -0
  17. package/dist/cli/index.js +4 -0
  18. package/dist/cli/index.js.map +1 -1
  19. package/dist/mcp/auth/callback-server.d.ts +22 -0
  20. package/dist/mcp/auth/callback-server.d.ts.map +1 -0
  21. package/dist/mcp/auth/callback-server.js +87 -0
  22. package/dist/mcp/auth/callback-server.js.map +1 -0
  23. package/dist/mcp/auth/mcp-oauth-provider.d.ts +49 -0
  24. package/dist/mcp/auth/mcp-oauth-provider.d.ts.map +1 -0
  25. package/dist/mcp/auth/mcp-oauth-provider.js +156 -0
  26. package/dist/mcp/auth/mcp-oauth-provider.js.map +1 -0
  27. package/dist/mcp/constants.d.ts +5 -0
  28. package/dist/mcp/constants.d.ts.map +1 -0
  29. package/dist/mcp/constants.js +7 -0
  30. package/dist/mcp/constants.js.map +1 -0
  31. package/dist/mcp/proxy-logger.d.ts +7 -0
  32. package/dist/mcp/proxy-logger.d.ts.map +1 -0
  33. package/dist/mcp/proxy-logger.js +32 -0
  34. package/dist/mcp/proxy-logger.js.map +1 -0
  35. package/dist/mcp/stdio-http-bridge.d.ts +63 -0
  36. package/dist/mcp/stdio-http-bridge.d.ts.map +1 -0
  37. package/dist/mcp/stdio-http-bridge.js +307 -0
  38. package/dist/mcp/stdio-http-bridge.js.map +1 -0
  39. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts +2 -1
  40. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts.map +1 -1
  41. package/dist/providers/plugins/sso/proxy/plugins/index.js +3 -1
  42. package/dist/providers/plugins/sso/proxy/plugins/index.js.map +1 -1
  43. package/dist/providers/plugins/sso/proxy/plugins/mcp-auth.plugin.d.ts +34 -0
  44. package/dist/providers/plugins/sso/proxy/plugins/mcp-auth.plugin.d.ts.map +1 -0
  45. package/dist/providers/plugins/sso/proxy/plugins/mcp-auth.plugin.js +1200 -0
  46. package/dist/providers/plugins/sso/proxy/plugins/mcp-auth.plugin.js.map +1 -0
  47. package/dist/providers/plugins/sso/proxy/plugins/types.d.ts +18 -1
  48. package/dist/providers/plugins/sso/proxy/plugins/types.d.ts.map +1 -1
  49. package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts.map +1 -1
  50. package/dist/providers/plugins/sso/proxy/sso.proxy.js +32 -2
  51. package/dist/providers/plugins/sso/proxy/sso.proxy.js.map +1 -1
  52. package/dist/utils/exec.d.ts +1 -0
  53. package/dist/utils/exec.d.ts.map +1 -1
  54. package/dist/utils/exec.js +13 -5
  55. package/dist/utils/exec.js.map +1 -1
  56. package/package.json +5 -2
@@ -0,0 +1,307 @@
1
+ /**
2
+ * Stdio-to-HTTP MCP Bridge
3
+ *
4
+ * Pipes JSON-RPC messages between a StdioServerTransport (Claude Code side)
5
+ * and a StreamableHTTPClientTransport (real MCP server side).
6
+ *
7
+ * Lazy connect: the HTTP transport is created and started only when the first
8
+ * stdio message arrives. If the server requires OAuth, the auth flow runs during
9
+ * that first connection (blocking the first message until auth completes).
10
+ *
11
+ * Cookie jar: Node's fetch doesn't persist cookies between requests. Some MCP
12
+ * auth gateways set session cookies during the OAuth flow that must be sent with
13
+ * subsequent requests. The bridge maintains a per-origin cookie jar automatically.
14
+ */
15
+ import { StreamableHTTPClientTransport, UnauthorizedError, } from '@modelcontextprotocol/client';
16
+ import { StdioServerTransport } from '@modelcontextprotocol/server';
17
+ import { logger } from '../utils/logger.js';
18
+ import { proxyLog } from './proxy-logger.js';
19
+ import { McpOAuthProvider } from './auth/mcp-oauth-provider.js';
20
+ function log(msg) {
21
+ logger.debug(msg);
22
+ proxyLog(msg);
23
+ }
24
+ /** Serialize an error with all available details (message, cause, status, body, stack). */
25
+ function errorDetail(error) {
26
+ if (!(error instanceof Error))
27
+ return String(error);
28
+ const parts = [`${error.constructor.name}: ${error.message}`];
29
+ for (const key of ['status', 'statusCode', 'code', 'body', 'response', 'statusText', 'data']) {
30
+ const val = error[key];
31
+ if (val !== undefined)
32
+ parts.push(` ${key}: ${JSON.stringify(val).slice(0, 500)}`);
33
+ }
34
+ if (error.cause)
35
+ parts.push(` cause: ${errorDetail(error.cause)}`);
36
+ if (error.stack)
37
+ parts.push(` stack: ${error.stack}`);
38
+ return parts.join('\n');
39
+ }
40
+ /**
41
+ * Minimal cookie jar: stores Set-Cookie values keyed by origin, sends them
42
+ * back on subsequent requests to the same origin.
43
+ */
44
+ class CookieJar {
45
+ /** origin → Map<cookie-name, full-cookie-string> */
46
+ cookies = new Map();
47
+ /** Extract and store cookies from a response's Set-Cookie headers. */
48
+ capture(requestUrl, response) {
49
+ const origin = new URL(requestUrl).origin;
50
+ // getSetCookie() returns individual Set-Cookie header values
51
+ const setCookies = response.headers.getSetCookie?.() ?? [];
52
+ if (setCookies.length === 0)
53
+ return;
54
+ let jar = this.cookies.get(origin);
55
+ if (!jar) {
56
+ jar = new Map();
57
+ this.cookies.set(origin, jar);
58
+ }
59
+ for (const raw of setCookies) {
60
+ const name = raw.split('=')[0]?.trim();
61
+ if (name) {
62
+ jar.set(name, raw.split(';')[0]); // store "name=value" only
63
+ log(`[mcp-proxy] Cookie stored for ${origin}: ${name}=***`);
64
+ }
65
+ }
66
+ }
67
+ /** Build a Cookie header value for the given request URL. */
68
+ headerFor(requestUrl) {
69
+ const origin = new URL(requestUrl).origin;
70
+ const jar = this.cookies.get(origin);
71
+ if (!jar || jar.size === 0)
72
+ return undefined;
73
+ return [...jar.values()].join('; ');
74
+ }
75
+ }
76
+ export class StdioHttpBridge {
77
+ stdioTransport;
78
+ httpTransport = null;
79
+ oauthProvider;
80
+ serverUrl;
81
+ cookieJar = new CookieJar();
82
+ connected = false;
83
+ connecting = false;
84
+ shuttingDown = false;
85
+ pendingMessages = [];
86
+ constructor(options) {
87
+ this.serverUrl = new URL(options.serverUrl);
88
+ this.oauthProvider = new McpOAuthProvider();
89
+ this.stdioTransport = new StdioServerTransport();
90
+ log(`[mcp-proxy] Bridge created for ${this.serverUrl}`);
91
+ }
92
+ /**
93
+ * Start the bridge: begin listening on stdio immediately.
94
+ * HTTP connection is deferred until the first message arrives.
95
+ */
96
+ async start() {
97
+ this.stdioTransport.onmessage = (message) => {
98
+ this.handleStdioMessage(message);
99
+ };
100
+ this.stdioTransport.onclose = () => {
101
+ log('[mcp-proxy] Stdio transport closed');
102
+ this.shutdown();
103
+ };
104
+ this.stdioTransport.onerror = (error) => {
105
+ log(`[mcp-proxy] Stdio transport error: ${error.message}`);
106
+ };
107
+ await this.stdioTransport.start();
108
+ log('[mcp-proxy] Stdio transport started, waiting for messages');
109
+ }
110
+ /**
111
+ * Handle a message from Claude Code (stdio side).
112
+ * On the first message, lazily connect the HTTP transport.
113
+ */
114
+ handleStdioMessage(message) {
115
+ if (this.shuttingDown)
116
+ return;
117
+ log(`[mcp-proxy] Received stdio message: ${JSON.stringify(message).slice(0, 200)}`);
118
+ if (this.connected && this.httpTransport) {
119
+ this.httpTransport.send(message).catch((error) => {
120
+ log(`[mcp-proxy] Error forwarding to HTTP:\n${errorDetail(error)}`);
121
+ this.shutdown();
122
+ });
123
+ return;
124
+ }
125
+ this.pendingMessages.push(message);
126
+ log(`[mcp-proxy] Queued message (${this.pendingMessages.length} pending), connecting=${this.connecting}`);
127
+ if (!this.connecting) {
128
+ this.connecting = true;
129
+ this.connectHttpTransport().catch((error) => {
130
+ if (this.shuttingDown) {
131
+ log(`[mcp-proxy] Connection aborted during shutdown: ${errorDetail(error)}`);
132
+ return;
133
+ }
134
+ log(`[mcp-proxy] Failed to connect to MCP server:\n${errorDetail(error)}`);
135
+ process.exit(1);
136
+ });
137
+ }
138
+ }
139
+ /**
140
+ * Lazily create and connect the HTTP transport to the real MCP server.
141
+ * Handles OAuth authorization if the server returns 401.
142
+ */
143
+ async connectHttpTransport() {
144
+ log(`[mcp-proxy] Connecting to MCP server: ${this.serverUrl}`);
145
+ await this.oauthProvider.ensureCallbackServer();
146
+ log('[mcp-proxy] Callback server pre-started');
147
+ this.httpTransport = this.createHttpTransport(this.oauthProvider);
148
+ log('[mcp-proxy] HTTP transport created with auth provider');
149
+ try {
150
+ log('[mcp-proxy] Starting HTTP transport...');
151
+ await this.httpTransport.start();
152
+ log('[mcp-proxy] HTTP transport started');
153
+ this.connected = true;
154
+ log('[mcp-proxy] HTTP transport connected');
155
+ try {
156
+ await this.flushPendingMessages();
157
+ }
158
+ catch (error) {
159
+ if (error instanceof UnauthorizedError) {
160
+ log('[mcp-proxy] Auth required on first send, completing OAuth flow');
161
+ await this.handleOAuthFlow(this.httpTransport);
162
+ log('[mcp-proxy] OAuth complete, retrying queued messages');
163
+ await this.flushPendingMessages();
164
+ }
165
+ else {
166
+ throw error;
167
+ }
168
+ }
169
+ }
170
+ catch (error) {
171
+ if (error instanceof UnauthorizedError) {
172
+ log('[mcp-proxy] Auth required on start, completing OAuth flow');
173
+ await this.handleOAuthFlow(this.httpTransport);
174
+ this.connected = true;
175
+ log('[mcp-proxy] HTTP transport connected after OAuth');
176
+ await this.flushPendingMessages();
177
+ }
178
+ else {
179
+ throw error;
180
+ }
181
+ }
182
+ finally {
183
+ this.connecting = false;
184
+ }
185
+ }
186
+ /**
187
+ * Create an HTTP transport with cookie jar and logging.
188
+ */
189
+ createHttpTransport(authProvider) {
190
+ const jar = this.cookieJar;
191
+ // Wrap fetch to: (1) inject cookies, (2) capture Set-Cookie, (3) log details
192
+ const cookieFetch = async (input, init) => {
193
+ const reqUrl = typeof input === 'string' ? input : input instanceof URL ? input.toString() : input.url;
194
+ const method = init?.method ?? 'GET';
195
+ log(`[mcp-proxy] HTTP ${method} ${reqUrl}`);
196
+ if (init?.body)
197
+ log(`[mcp-proxy] Request body: ${String(init.body).slice(0, 300)}`);
198
+ // Inject stored cookies into the request
199
+ const cookieHeader = jar.headerFor(reqUrl);
200
+ if (cookieHeader && init?.headers) {
201
+ const headers = init.headers instanceof Headers ? init.headers : new Headers(init.headers);
202
+ headers.set('Cookie', cookieHeader);
203
+ init = { ...init, headers };
204
+ log(`[mcp-proxy] Injected cookies for ${new URL(reqUrl).origin}`);
205
+ }
206
+ // Log auth header presence (not value)
207
+ if (init?.headers instanceof Headers) {
208
+ log(`[mcp-proxy] Has Authorization: ${init.headers.has('Authorization')}`);
209
+ log(`[mcp-proxy] Request headers: ${[...init.headers.keys()].join(', ')}`);
210
+ }
211
+ const response = await fetch(input, init);
212
+ log(`[mcp-proxy] HTTP response: ${response.status} ${response.statusText}`);
213
+ const ct = response.headers.get('content-type');
214
+ if (ct)
215
+ log(`[mcp-proxy] Response content-type: ${ct}`);
216
+ // Capture any Set-Cookie headers from the response
217
+ jar.capture(reqUrl, response);
218
+ // Log error response bodies
219
+ if (!response.ok) {
220
+ const cloned = response.clone();
221
+ const errorBody = await cloned.text().catch(() => '(unreadable)');
222
+ log(`[mcp-proxy] Error response body: ${errorBody.slice(0, 500)}`);
223
+ }
224
+ return response;
225
+ };
226
+ const transport = new StreamableHTTPClientTransport(this.serverUrl, {
227
+ fetch: cookieFetch,
228
+ ...(authProvider ? { authProvider } : {}),
229
+ });
230
+ transport.onmessage = (message) => {
231
+ log(`[mcp-proxy] Received HTTP message: ${JSON.stringify(message).slice(0, 200)}`);
232
+ this.stdioTransport.send(message).catch((error) => {
233
+ log(`[mcp-proxy] Error forwarding to stdio: ${error.message}`);
234
+ });
235
+ };
236
+ transport.onclose = () => {
237
+ log('[mcp-proxy] HTTP transport closed');
238
+ this.shutdown();
239
+ };
240
+ transport.onerror = (error) => {
241
+ log(`[mcp-proxy] HTTP transport error:\n${errorDetail(error)}`);
242
+ };
243
+ return transport;
244
+ }
245
+ /**
246
+ * Handle the OAuth authorization code flow.
247
+ */
248
+ async handleOAuthFlow(transport) {
249
+ log('[mcp-proxy] Waiting for authorization code from browser...');
250
+ const code = await this.oauthProvider.waitForAuthorizationCode();
251
+ log('[mcp-proxy] Authorization code received, exchanging for token');
252
+ await transport.finishAuth(code);
253
+ log('[mcp-proxy] Token exchange complete, transport ready');
254
+ }
255
+ /**
256
+ * Forward any messages that arrived while we were connecting/authenticating.
257
+ * UnauthorizedError is re-thrown so the caller can handle the OAuth flow.
258
+ */
259
+ async flushPendingMessages() {
260
+ const messages = this.pendingMessages;
261
+ this.pendingMessages = [];
262
+ for (const message of messages) {
263
+ try {
264
+ await this.httpTransport.send(message);
265
+ }
266
+ catch (error) {
267
+ if (error instanceof UnauthorizedError) {
268
+ const remaining = messages.slice(messages.indexOf(message));
269
+ this.pendingMessages = remaining.concat(this.pendingMessages);
270
+ log(`[mcp-proxy] UnauthorizedError during flush, re-queued ${remaining.length} message(s)`);
271
+ throw error;
272
+ }
273
+ log(`[mcp-proxy] Error flushing pending message:\n${errorDetail(error)}`);
274
+ }
275
+ }
276
+ if (messages.length > 0) {
277
+ log(`[mcp-proxy] Flushed ${messages.length} pending message(s)`);
278
+ }
279
+ }
280
+ /**
281
+ * Graceful shutdown: close both transports. Idempotent.
282
+ */
283
+ async shutdown() {
284
+ if (this.shuttingDown)
285
+ return;
286
+ this.shuttingDown = true;
287
+ log('[mcp-proxy] Shutting down bridge');
288
+ this.oauthProvider.dispose();
289
+ try {
290
+ if (this.httpTransport) {
291
+ await this.httpTransport.terminateSession();
292
+ await this.httpTransport.close();
293
+ }
294
+ }
295
+ catch (error) {
296
+ log(`[mcp-proxy] Error closing HTTP transport: ${error.message}`);
297
+ }
298
+ try {
299
+ await this.stdioTransport.close();
300
+ }
301
+ catch (error) {
302
+ log(`[mcp-proxy] Error closing stdio transport: ${error.message}`);
303
+ }
304
+ log('[mcp-proxy] Bridge shutdown complete');
305
+ }
306
+ }
307
+ //# sourceMappingURL=stdio-http-bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio-http-bridge.js","sourceRoot":"","sources":["../../src/mcp/stdio-http-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,6BAA6B,EAC7B,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,SAAS,GAAG,CAAC,GAAW;IACtB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,QAAQ,CAAC,GAAG,CAAC,CAAC;AAChB,CAAC;AAED,2FAA2F;AAC3F,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,KAAK,GAAa,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACxE,KAAK,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,U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EAAE,CAAC,CAAC;YAC5E,CAAC;QACH,CAAC;QAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,GAAG,CAAC,uBAAuB,QAAQ,CAAC,MAAM,qBAAqB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ;QACZ,IAAI,IAAI,CAAC,YAAY;YAAE,OAAO;QAC9B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAEzB,GAAG,CAAC,kCAAkC,CAAC,CAAC;QACxC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;QAE7B,IAAI,CAAC;YACH,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;gBACvB,MAAM,IAAI,CAAC,aAAa,CAAC,gBAAgB,EAAE,CAAC;gBAC5C,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;YACnC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,6CAA8C,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/E,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,8CAA+C,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QAChF,CAAC;QAED,GAAG,CAAC,sCAAsC,CAAC,CAAC;IAC9C,CAAC;CACF"}
@@ -4,6 +4,7 @@
4
4
  * KISS: Single file to register all core plugins
5
5
  * Extensibility: Easy to add new plugins
6
6
  */
7
+ import { MCPAuthPlugin } from './mcp-auth.plugin.js';
7
8
  import { EndpointBlockerPlugin } from './endpoint-blocker.plugin.js';
8
9
  import { SSOAuthPlugin } from './sso-auth.plugin.js';
9
10
  import { JWTAuthPlugin } from './jwt-auth.plugin.js';
@@ -15,7 +16,7 @@ import { LoggingPlugin } from './logging.plugin.js';
15
16
  * Called at app startup
16
17
  */
17
18
  export declare function registerCorePlugins(): void;
18
- export { EndpointBlockerPlugin, SSOAuthPlugin, JWTAuthPlugin, HeaderInjectionPlugin, RequestSanitizerPlugin, LoggingPlugin };
19
+ export { MCPAuthPlugin, EndpointBlockerPlugin, SSOAuthPlugin, JWTAuthPlugin, HeaderInjectionPlugin, RequestSanitizerPlugin, LoggingPlugin };
19
20
  export { SSOSessionSyncPlugin } from './sso.session-sync.plugin.js';
20
21
  export { getPluginRegistry, resetPluginRegistry } from './registry.js';
21
22
  export * from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/providers/plugins/sso/proxy/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAW1C;AAMD,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,aAAa,EAAE,CAAC;AAC7H,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACvE,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/providers/plugins/sso/proxy/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAY1C;AAMD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,aAAa,EAAE,CAAC;AAC5I,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACvE,cAAc,YAAY,CAAC"}
@@ -5,6 +5,7 @@
5
5
  * Extensibility: Easy to add new plugins
6
6
  */
7
7
  import { getPluginRegistry } from './registry.js';
8
+ import { MCPAuthPlugin } from './mcp-auth.plugin.js';
8
9
  import { EndpointBlockerPlugin } from './endpoint-blocker.plugin.js';
9
10
  import { SSOAuthPlugin } from './sso-auth.plugin.js';
10
11
  import { JWTAuthPlugin } from './jwt-auth.plugin.js';
@@ -19,6 +20,7 @@ import { SSOSessionSyncPlugin } from './sso.session-sync.plugin.js';
19
20
  export function registerCorePlugins() {
20
21
  const registry = getPluginRegistry();
21
22
  // Register in any order (priority determines execution order)
23
+ registry.register(new MCPAuthPlugin()); // Priority 3 - MCP auth relay routing
22
24
  registry.register(new EndpointBlockerPlugin()); // Priority 5 - blocks unwanted endpoints early
23
25
  registry.register(new SSOAuthPlugin());
24
26
  registry.register(new JWTAuthPlugin());
@@ -30,7 +32,7 @@ export function registerCorePlugins() {
30
32
  // Auto-register on import
31
33
  registerCorePlugins();
32
34
  // Re-export for convenience
33
- export { EndpointBlockerPlugin, SSOAuthPlugin, JWTAuthPlugin, HeaderInjectionPlugin, RequestSanitizerPlugin, LoggingPlugin };
35
+ export { MCPAuthPlugin, EndpointBlockerPlugin, SSOAuthPlugin, JWTAuthPlugin, HeaderInjectionPlugin, RequestSanitizerPlugin, LoggingPlugin };
34
36
  export { SSOSessionSyncPlugin } from './sso.session-sync.plugin.js';
35
37
  export { getPluginRegistry, resetPluginRegistry } from './registry.js';
36
38
  export * from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/providers/plugins/sso/proxy/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;IAErC,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,CAAC,IAAI,qBAAqB,EAAE,CAAC,CAAC,CAAC,+CAA+C;IAC/F,QAAQ,CAAC,QAAQ,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,IAAI,sBAAsB,EAAE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,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC,CAAU,sCAAsC;IACvF,QAAQ,CAAC,QAAQ,CAAC,IAAI,qBAAqB,EAAE,CAAC,CAAC,CAAC,+CAA+C;IAC/F,QAAQ,CAAC,QAAQ,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,IAAI,sBAAsB,EAAE,CAAC,CAAC,CAAC,oDAAoD;IACrG,QAAQ,CAAC,QAAQ,CAAC,IAAI,qBAAqB,EAAE,CAAC,CAAC;IAC/C,QAAQ,CAAC,QAAQ,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC,CAAC,mDAAmD;IAC3F,QAAQ,CAAC,QAAQ,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC,CAAC,wDAAwD;AACzG,CAAC;AAED,0BAA0B;AAC1B,mBAAmB,EAAE,CAAC;AAEtB,4BAA4B;AAC5B,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,aAAa,EAAE,CAAC;AAC5I,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACvE,cAAc,YAAY,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * MCP Authorization Proxy Plugin
3
+ * Priority: 3 (runs before endpoint blocker, auth, and all other plugins)
4
+ *
5
+ * Proxies the MCP OAuth authorization flow so that:
6
+ * 1. All auth traffic is routed through the CodeMie proxy
7
+ * 2. `client_name` is replaced with MCP_CLIENT_NAME env var (default "CodeMie CLI") in dynamic client registration
8
+ *
9
+ * URL scheme:
10
+ * - /mcp_auth?original=<url> → Initial MCP connection
11
+ * - /mcp_relay/<root_b64>/<relay_b64>/<path> → Relayed requests (per-flow scoped)
12
+ *
13
+ * The root_b64 segment carries the root MCP server origin for per-flow isolation.
14
+ * The relay_b64 segment identifies the actual target origin (may differ from root
15
+ * when the auth server is on a separate host).
16
+ *
17
+ * Response URL rewriting replaces external URLs with proxy relay URLs so that
18
+ * the MCP client (Claude Code CLI) routes all subsequent requests through the proxy.
19
+ *
20
+ * Security:
21
+ * - SSRF protection: private/loopback origins are rejected (hostname + DNS resolution)
22
+ * - Per-flow origin scoping: discovered origins are tagged with their root MCP server
23
+ * origin and relay requests validate the root-relay association
24
+ * - Buffering is restricted to auth metadata responses; post-auth MCP traffic streams through
25
+ */
26
+ import { ProxyPlugin, PluginContext, ProxyInterceptor } from './types.js';
27
+ export declare class MCPAuthPlugin implements ProxyPlugin {
28
+ id: string;
29
+ name: string;
30
+ version: string;
31
+ priority: number;
32
+ createInterceptor(context: PluginContext): Promise<ProxyInterceptor>;
33
+ }
34
+ //# sourceMappingURL=mcp-auth.plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-auth.plugin.d.ts","sourceRoot":"","sources":["../../../../../../src/providers/plugins/sso/proxy/plugins/mcp-auth.plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAOH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AA0O1E,qBAAa,aAAc,YAAW,WAAW;IAC/C,EAAE,SAA6B;IAC/B,IAAI,SAAoB;IACxB,OAAO,SAAW;IAClB,QAAQ,SAAK;IAEP,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAG3E"}