@1mcp/agent 0.12.0 → 0.13.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 +22 -37
- package/build/auth/sdkOAuthClientProvider.d.ts +93 -0
- package/build/auth/sdkOAuthClientProvider.d.ts.map +1 -0
- package/build/auth/sdkOAuthClientProvider.js +204 -0
- package/build/auth/sdkOAuthClientProvider.js.map +1 -0
- package/build/auth/sdkOAuthServerProvider.d.ts +64 -0
- package/build/auth/sdkOAuthServerProvider.d.ts.map +1 -0
- package/build/auth/sdkOAuthServerProvider.js +359 -0
- package/build/auth/sdkOAuthServerProvider.js.map +1 -0
- package/build/auth/sessionTypes.d.ts +38 -0
- package/build/auth/sessionTypes.d.ts.map +1 -0
- package/build/auth/sessionTypes.js +3 -0
- package/build/auth/sessionTypes.js.map +1 -0
- package/build/auth/storage/authCodeRepository.d.ts +25 -0
- package/build/auth/storage/authCodeRepository.d.ts.map +1 -0
- package/build/auth/storage/authCodeRepository.js +50 -0
- package/build/auth/storage/authCodeRepository.js.map +1 -0
- package/build/auth/storage/authRequestRepository.d.ts +25 -0
- package/build/auth/storage/authRequestRepository.d.ts.map +1 -0
- package/build/auth/storage/authRequestRepository.js +51 -0
- package/build/auth/storage/authRequestRepository.js.map +1 -0
- package/build/auth/storage/clientDataRepository.d.ts +25 -0
- package/build/auth/storage/clientDataRepository.d.ts.map +1 -0
- package/build/auth/storage/clientDataRepository.js +45 -0
- package/build/auth/storage/clientDataRepository.js.map +1 -0
- package/build/auth/storage/clientSessionRepository.d.ts +77 -0
- package/build/auth/storage/clientSessionRepository.d.ts.map +1 -0
- package/build/auth/storage/clientSessionRepository.js +120 -0
- package/build/auth/storage/clientSessionRepository.js.map +1 -0
- package/build/auth/storage/fileStorageService.d.ts +68 -0
- package/build/auth/storage/fileStorageService.d.ts.map +1 -0
- package/build/auth/storage/fileStorageService.js +262 -0
- package/build/auth/storage/fileStorageService.js.map +1 -0
- package/build/auth/storage/oauthStorageService.d.ts +57 -0
- package/build/auth/storage/oauthStorageService.d.ts.map +1 -0
- package/build/auth/storage/oauthStorageService.js +131 -0
- package/build/auth/storage/oauthStorageService.js.map +1 -0
- package/build/auth/storage/sessionRepository.d.ts +29 -0
- package/build/auth/storage/sessionRepository.d.ts.map +1 -0
- package/build/auth/storage/sessionRepository.js +64 -0
- package/build/auth/storage/sessionRepository.js.map +1 -0
- package/build/capabilities/capabilityManager.d.ts +2 -2
- package/build/capabilities/capabilityManager.d.ts.map +1 -1
- package/build/capabilities/capabilityManager.js +1 -1
- package/build/capabilities/capabilityManager.js.map +1 -1
- package/build/config/{configManager.d.ts → mcpConfigManager.d.ts} +11 -6
- package/build/config/mcpConfigManager.d.ts.map +1 -0
- package/build/config/{configManager.js → mcpConfigManager.js} +26 -8
- package/build/config/mcpConfigManager.js.map +1 -0
- package/build/constants.d.ts +51 -14
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +61 -17
- package/build/constants.js.map +1 -1
- package/build/core/client/clientManager.d.ts +14 -6
- package/build/core/client/clientManager.d.ts.map +1 -1
- package/build/core/client/clientManager.js +90 -28
- package/build/core/client/clientManager.js.map +1 -1
- package/build/core/server/{serverConfig.d.ts → agentConfig.d.ts} +50 -15
- package/build/core/server/agentConfig.d.ts.map +1 -0
- package/build/core/server/agentConfig.js +166 -0
- package/build/core/server/agentConfig.js.map +1 -0
- package/build/core/server/serverManager.d.ts +12 -5
- package/build/core/server/serverManager.d.ts.map +1 -1
- package/build/core/server/serverManager.js +12 -2
- package/build/core/server/serverManager.js.map +1 -1
- package/build/core/types/client.d.ts +22 -9
- package/build/core/types/client.d.ts.map +1 -1
- package/build/core/types/client.js +2 -0
- package/build/core/types/client.js.map +1 -1
- package/build/core/types/server.d.ts +3 -3
- package/build/core/types/server.d.ts.map +1 -1
- package/build/core/types/transport.d.ts +58 -0
- package/build/core/types/transport.d.ts.map +1 -1
- package/build/core/types/transport.js +10 -0
- package/build/core/types/transport.js.map +1 -1
- package/build/handlers/notificationHandlers.d.ts +3 -3
- package/build/handlers/notificationHandlers.d.ts.map +1 -1
- package/build/handlers/notificationHandlers.js +2 -2
- package/build/handlers/notificationHandlers.js.map +1 -1
- package/build/handlers/requestHandlers.d.ts +2 -2
- package/build/handlers/requestHandlers.d.ts.map +1 -1
- package/build/handlers/requestHandlers.js +4 -3
- package/build/handlers/requestHandlers.js.map +1 -1
- package/build/index.js +47 -7
- package/build/index.js.map +1 -1
- package/build/{transport/http/middleware/loggingMiddleware.d.ts → logger/mcpLoggingEnhancer.d.ts} +1 -1
- package/build/logger/mcpLoggingEnhancer.d.ts.map +1 -0
- package/build/{transport/http/middleware/loggingMiddleware.js → logger/mcpLoggingEnhancer.js} +2 -2
- package/build/logger/mcpLoggingEnhancer.js.map +1 -0
- package/build/server.js +4 -4
- package/build/server.js.map +1 -1
- package/build/services/configReloadService.d.ts +2 -2
- package/build/services/configReloadService.d.ts.map +1 -1
- package/build/services/configReloadService.js +4 -4
- package/build/services/configReloadService.js.map +1 -1
- package/build/transport/http/middlewares/errorHandler.d.ts.map +1 -0
- package/build/transport/http/{errorHandler.js → middlewares/errorHandler.js} +1 -1
- package/build/transport/http/middlewares/errorHandler.js.map +1 -0
- package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts +39 -0
- package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts.map +1 -0
- package/build/transport/http/middlewares/scopeAuthMiddleware.js +129 -0
- package/build/transport/http/middlewares/scopeAuthMiddleware.js.map +1 -0
- package/build/transport/http/middlewares/securityMiddleware.d.ts +30 -0
- package/build/transport/http/middlewares/securityMiddleware.d.ts.map +1 -0
- package/build/transport/http/middlewares/securityMiddleware.js +201 -0
- package/build/transport/http/middlewares/securityMiddleware.js.map +1 -0
- package/build/transport/http/middlewares/tagsExtractor.d.ts.map +1 -0
- package/build/transport/http/middlewares/tagsExtractor.js.map +1 -0
- package/build/transport/http/routes/oauthRoutes.d.ts +5 -11
- package/build/transport/http/routes/oauthRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/oauthRoutes.js +460 -122
- package/build/transport/http/routes/oauthRoutes.js.map +1 -1
- package/build/transport/http/routes/sseRoutes.d.ts +3 -2
- package/build/transport/http/routes/sseRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/sseRoutes.js +10 -7
- package/build/transport/http/routes/sseRoutes.js.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.d.ts +3 -2
- package/build/transport/http/routes/streamableHttpRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.js +17 -10
- package/build/transport/http/routes/streamableHttpRoutes.js.map +1 -1
- package/build/transport/http/server.d.ts +3 -2
- package/build/transport/http/server.d.ts.map +1 -1
- package/build/transport/http/server.js +58 -21
- package/build/transport/http/server.js.map +1 -1
- package/build/transport/transportFactory.d.ts +9 -0
- package/build/transport/transportFactory.d.ts.map +1 -0
- package/build/transport/transportFactory.js +148 -0
- package/build/transport/transportFactory.js.map +1 -0
- package/build/utils/clientFiltering.d.ts +4 -4
- package/build/utils/clientFiltering.d.ts.map +1 -1
- package/build/utils/clientFiltering.js +54 -19
- package/build/utils/clientFiltering.js.map +1 -1
- package/build/utils/errorHandling.d.ts +0 -12
- package/build/utils/errorHandling.d.ts.map +1 -1
- package/build/utils/errorHandling.js +1 -42
- package/build/utils/errorHandling.js.map +1 -1
- package/build/utils/pagination.d.ts +2 -2
- package/build/utils/pagination.d.ts.map +1 -1
- package/build/utils/pagination.js +4 -4
- package/build/utils/pagination.js.map +1 -1
- package/build/utils/parsing.d.ts +13 -0
- package/build/utils/parsing.d.ts.map +1 -0
- package/build/utils/parsing.js +32 -0
- package/build/utils/parsing.js.map +1 -0
- package/build/utils/sanitization.d.ts +60 -0
- package/build/utils/sanitization.d.ts.map +1 -0
- package/build/utils/sanitization.js +149 -0
- package/build/utils/sanitization.js.map +1 -0
- package/build/utils/scopeValidation.d.ts +102 -0
- package/build/utils/scopeValidation.d.ts.map +1 -0
- package/build/utils/scopeValidation.js +244 -0
- package/build/utils/scopeValidation.js.map +1 -0
- package/package.json +20 -11
- package/build/auth/authManager.d.ts +0 -109
- package/build/auth/authManager.d.ts.map +0 -1
- package/build/auth/authManager.js +0 -173
- package/build/auth/authManager.js.map +0 -1
- package/build/auth/authMiddleware.d.ts +0 -16
- package/build/auth/authMiddleware.d.ts.map +0 -1
- package/build/auth/authMiddleware.js +0 -45
- package/build/auth/authMiddleware.js.map +0 -1
- package/build/auth/sessionManager.d.ts +0 -197
- package/build/auth/sessionManager.d.ts.map +0 -1
- package/build/auth/sessionManager.js +0 -408
- package/build/auth/sessionManager.js.map +0 -1
- package/build/config/configManager.d.ts.map +0 -1
- package/build/config/configManager.js.map +0 -1
- package/build/core/server/serverConfig.d.ts.map +0 -1
- package/build/core/server/serverConfig.js +0 -117
- package/build/core/server/serverConfig.js.map +0 -1
- package/build/transport/config.d.ts +0 -7
- package/build/transport/config.d.ts.map +0 -1
- package/build/transport/config.js +0 -90
- package/build/transport/config.js.map +0 -1
- package/build/transport/http/errorHandler.d.ts.map +0 -1
- package/build/transport/http/errorHandler.js.map +0 -1
- package/build/transport/http/middleware/loggingMiddleware.d.ts.map +0 -1
- package/build/transport/http/middleware/loggingMiddleware.js.map +0 -1
- package/build/utils/tagsExtractor.d.ts.map +0 -1
- package/build/utils/tagsExtractor.js.map +0 -1
- /package/build/transport/http/{errorHandler.d.ts → middlewares/errorHandler.d.ts} +0 -0
- /package/build/{utils → transport/http/middlewares}/tagsExtractor.d.ts +0 -0
- /package/build/{utils → transport/http/middlewares}/tagsExtractor.js +0 -0
package/README.md
CHANGED
|
@@ -16,6 +16,8 @@ A unified Model Context Protocol server implementation that aggregates multiple
|
|
|
16
16
|
- Provides a standardized way for AI models to interact with external tools and resources
|
|
17
17
|
- Supports dynamic configuration reloading without server restart
|
|
18
18
|
- Handles graceful shutdown and resource cleanup
|
|
19
|
+
- Includes comprehensive authentication and security features
|
|
20
|
+
- Supports advanced filtering, pagination, and request optimization
|
|
19
21
|
|
|
20
22
|
## Quick Start
|
|
21
23
|
|
|
@@ -62,28 +64,25 @@ npx -y @1mcp/agent --help
|
|
|
62
64
|
|
|
63
65
|
Available options:
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
export ONE_MCP_TAGS=network,filesystem
|
|
85
|
-
npx -y @1mcp/agent
|
|
86
|
-
```
|
|
67
|
+
| Option (CLI) | Environment Variable | Description | Default | Deprecated? |
|
|
68
|
+
| :--------------------------- | :--------------------------------- | :---------------------------------------------------- | :-------: | :---------: |
|
|
69
|
+
| `--transport`, `-t` | `ONE_MCP_TRANSPORT` | Choose transport type ("stdio", "http", or "sse") | "http" | |
|
|
70
|
+
| `--config`, `-c` | `ONE_MCP_CONFIG` | Use a specific config file | | |
|
|
71
|
+
| `--port`, `-P` | `ONE_MCP_PORT` | Change HTTP port | 3050 | |
|
|
72
|
+
| `--host`, `-H` | `ONE_MCP_HOST` | Change HTTP host | localhost | |
|
|
73
|
+
| `--tags`, `-g` | `ONE_MCP_TAGS` | Filter servers by tags | | |
|
|
74
|
+
| `--pagination`, `-p` | `ONE_MCP_PAGINATION` | Enable pagination for client/server lists (boolean) | false | |
|
|
75
|
+
| `--auth` | `ONE_MCP_AUTH` | Enable authentication (OAuth 2.1) | false | Yes |
|
|
76
|
+
| `--enable-auth` | `ONE_MCP_ENABLE_AUTH` | Enable authentication (OAuth 2.1) | false | |
|
|
77
|
+
| `--enable-scope-validation` | `ONE_MCP_ENABLE_SCOPE_VALIDATION` | Enable tag-based scope validation (boolean) | true | |
|
|
78
|
+
| `--enable-enhanced-security` | `ONE_MCP_ENABLE_ENHANCED_SECURITY` | Enable enhanced security middleware (boolean) | false | |
|
|
79
|
+
| `--session-ttl` | `ONE_MCP_SESSION_TTL` | Session expiry time in minutes (number) | 1440 | |
|
|
80
|
+
| `--session-storage-path` | `ONE_MCP_SESSION_STORAGE_PATH` | Custom session storage directory path (string) | | |
|
|
81
|
+
| `--rate-limit-window` | `ONE_MCP_RATE_LIMIT_WINDOW` | OAuth rate limit window in minutes (number) | 15 | |
|
|
82
|
+
| `--rate-limit-max` | `ONE_MCP_RATE_LIMIT_MAX` | Maximum requests per OAuth rate limit window (number) | 100 | |
|
|
83
|
+
| `--help`, `-h` | | Show help | | |
|
|
84
|
+
|
|
85
|
+
> 💡 **Note:** Deprecated options are provided for backward compatibility. Prefer using the non-deprecated options for new configurations.
|
|
87
86
|
|
|
88
87
|
## Docker
|
|
89
88
|
|
|
@@ -109,21 +108,7 @@ Available image tags:
|
|
|
109
108
|
- `vX.Y.Z`: Specific version (e.g. `v1.0.0`)
|
|
110
109
|
- `sha-<commit>`: Specific commit
|
|
111
110
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
You can configure 1MCP using environment variables prefixed with `ONE_MCP_`:
|
|
115
|
-
|
|
116
|
-
- `ONE_MCP_TRANSPORT`: Transport type ("stdio" or "http", default: "http")
|
|
117
|
-
- `ONE_MCP_PORT`: HTTP port (default: 3050)
|
|
118
|
-
- `ONE_MCP_HOST`: HTTP host (default: "localhost")
|
|
119
|
-
- `ONE_MCP_CONFIG`: Path to config file
|
|
120
|
-
- `ONE_MCP_TAGS`: Comma-separated list of tags to filter servers
|
|
121
|
-
- `ONE_MCP_PAGINATION`: Enable pagination for client/server lists (boolean, default: false)
|
|
122
|
-
- `ONE_MCP_AUTH`: Enable authentication (OAuth 2.1) (boolean, default: false)
|
|
123
|
-
- `ONE_MCP_SESSION_TTL`: Session expiry time in minutes (number, default: 1440)
|
|
124
|
-
- `ONE_MCP_SESSION_STORAGE_PATH`: Custom session storage directory path (string, default: undefined)
|
|
125
|
-
|
|
126
|
-
Example with environment variables:
|
|
111
|
+
Example:
|
|
127
112
|
|
|
128
113
|
```bash
|
|
129
114
|
docker run -p 3051:3051 \
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js';
|
|
2
|
+
import type { OAuthClientMetadata, OAuthClientInformationFull, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
3
|
+
/**
|
|
4
|
+
* OAuth client configuration for connecting to downstream MCP servers
|
|
5
|
+
*/
|
|
6
|
+
export interface OAuthClientConfig {
|
|
7
|
+
clientId?: string;
|
|
8
|
+
clientSecret?: string;
|
|
9
|
+
scopes?: string[];
|
|
10
|
+
redirectUrl: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* SDK-compatible OAuth client provider that replaces the custom implementation.
|
|
14
|
+
*
|
|
15
|
+
* This provider implements the OAuth 2.1 Authorization Code Grant flow using
|
|
16
|
+
* the SDK's OAuthClientProvider interface while maintaining compatibility with
|
|
17
|
+
* the existing session storage system.
|
|
18
|
+
*/
|
|
19
|
+
export declare class SDKOAuthClientProvider implements OAuthClientProvider {
|
|
20
|
+
private _clientMetadata;
|
|
21
|
+
private _clientInfo?;
|
|
22
|
+
private _tokens?;
|
|
23
|
+
private _codeVerifier?;
|
|
24
|
+
private _state?;
|
|
25
|
+
private sessionRepository;
|
|
26
|
+
private serverName;
|
|
27
|
+
private config;
|
|
28
|
+
private _authorizationUrl?;
|
|
29
|
+
constructor(serverName: string, config: OAuthClientConfig, sessionStoragePath?: string);
|
|
30
|
+
get redirectUrl(): string;
|
|
31
|
+
get clientMetadata(): OAuthClientMetadata;
|
|
32
|
+
/**
|
|
33
|
+
* Returns current client registration information
|
|
34
|
+
*/
|
|
35
|
+
clientInformation(): OAuthClientInformationFull | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Saves client registration information from dynamic registration
|
|
38
|
+
*/
|
|
39
|
+
saveClientInformation(clientInfo: OAuthClientInformationFull): void;
|
|
40
|
+
/**
|
|
41
|
+
* Returns current OAuth tokens
|
|
42
|
+
*/
|
|
43
|
+
tokens(): OAuthTokens | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Saves OAuth tokens after successful authorization
|
|
46
|
+
*/
|
|
47
|
+
saveTokens(tokens: OAuthTokens): void;
|
|
48
|
+
/**
|
|
49
|
+
* Stores authorization URL instead of prompting user in console
|
|
50
|
+
*/
|
|
51
|
+
redirectToAuthorization(authorizationUrl: URL): void;
|
|
52
|
+
/**
|
|
53
|
+
* Gets the current authorization URL
|
|
54
|
+
*/
|
|
55
|
+
getAuthorizationUrl(): string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Clears the stored authorization URL
|
|
58
|
+
*/
|
|
59
|
+
clearAuthorizationUrl(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Saves PKCE code verifier for the authorization session
|
|
62
|
+
*/
|
|
63
|
+
saveCodeVerifier(codeVerifier: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the PKCE code verifier for token exchange
|
|
66
|
+
*/
|
|
67
|
+
codeVerifier(): string | Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Returns the OAuth state parameter for CSRF protection
|
|
70
|
+
*/
|
|
71
|
+
state(): string | Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Custom resource validation (optional)
|
|
74
|
+
*/
|
|
75
|
+
validateResourceURL(serverUrl: string | URL, resource?: string): Promise<URL | undefined>;
|
|
76
|
+
/**
|
|
77
|
+
* Load persisted OAuth data from unified client session storage
|
|
78
|
+
*/
|
|
79
|
+
private loadPersistedData;
|
|
80
|
+
/**
|
|
81
|
+
* Persist all OAuth data to unified client session storage
|
|
82
|
+
*/
|
|
83
|
+
private persistAllData;
|
|
84
|
+
/**
|
|
85
|
+
* Check if OAuth tokens are expired
|
|
86
|
+
*/
|
|
87
|
+
private isTokenExpired;
|
|
88
|
+
/**
|
|
89
|
+
* Clean up resources
|
|
90
|
+
*/
|
|
91
|
+
shutdown(): void;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=sdkOAuthClientProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdkOAuthClientProvider.d.ts","sourceRoot":"","sources":["../../src/auth/sdkOAuthClientProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,KAAK,EACV,mBAAmB,EACnB,0BAA0B,EAC1B,WAAW,EACZ,MAAM,0CAA0C,CAAC;AAQlD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,qBAAa,sBAAuB,YAAW,mBAAmB;IAChE,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,WAAW,CAAC,CAA6B;IACjD,OAAO,CAAC,OAAO,CAAC,CAAc;IAC9B,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,iBAAiB,CAA0B;IACnD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,iBAAiB,CAAC,CAAS;gBAEvB,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,EAAE,MAAM;IAyBtF,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,cAAc,IAAI,mBAAmB,CAExC;IAED;;OAEG;IACH,iBAAiB,IAAI,0BAA0B,GAAG,SAAS;IAI3D;;OAEG;IACH,qBAAqB,CAAC,UAAU,EAAE,0BAA0B,GAAG,IAAI;IAMnE;;OAEG;IACH,MAAM,IAAI,WAAW,GAAG,SAAS;IAIjC;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAMrC;;OAEG;IACH,uBAAuB,CAAC,gBAAgB,EAAE,GAAG,GAAG,IAAI;IAIpD;;OAEG;IACH,mBAAmB,IAAI,MAAM,GAAG,SAAS;IAIzC;;OAEG;IACH,qBAAqB,IAAI,IAAI;IAI7B;;OAEG;IACH,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAK5C;;OAEG;IACH,YAAY,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIxC;;OAEG;IACH,KAAK,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQjC;;OAEG;IACG,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC;IAS/F;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAiCzB;;OAEG;IACH,OAAO,CAAC,cAAc;IAwBtB;;OAEG;IACH,OAAO,CAAC,cAAc;IAUtB;;OAEG;IACH,QAAQ,IAAI,IAAI;CAMjB"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import logger from '../logger/logger.js';
|
|
3
|
+
import { ClientSessionRepository } from './storage/clientSessionRepository.js';
|
|
4
|
+
import { FileStorageService } from './storage/fileStorageService.js';
|
|
5
|
+
import { AUTH_CONFIG, getGlobalConfigDir } from '../constants.js';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
/**
|
|
8
|
+
* SDK-compatible OAuth client provider that replaces the custom implementation.
|
|
9
|
+
*
|
|
10
|
+
* This provider implements the OAuth 2.1 Authorization Code Grant flow using
|
|
11
|
+
* the SDK's OAuthClientProvider interface while maintaining compatibility with
|
|
12
|
+
* the existing session storage system.
|
|
13
|
+
*/
|
|
14
|
+
export class SDKOAuthClientProvider {
|
|
15
|
+
_clientMetadata;
|
|
16
|
+
_clientInfo;
|
|
17
|
+
_tokens;
|
|
18
|
+
_codeVerifier;
|
|
19
|
+
_state;
|
|
20
|
+
sessionRepository;
|
|
21
|
+
serverName;
|
|
22
|
+
config;
|
|
23
|
+
_authorizationUrl;
|
|
24
|
+
constructor(serverName, config, sessionStoragePath) {
|
|
25
|
+
this.serverName = serverName;
|
|
26
|
+
this.config = config;
|
|
27
|
+
// Create FileStorageService and ClientSessionRepository
|
|
28
|
+
const storagePath = sessionStoragePath || path.join(getGlobalConfigDir(), 'clientSessions');
|
|
29
|
+
const fileStorage = new FileStorageService(storagePath);
|
|
30
|
+
this.sessionRepository = new ClientSessionRepository(fileStorage);
|
|
31
|
+
// Set up client metadata for registration with better defaults
|
|
32
|
+
this._clientMetadata = {
|
|
33
|
+
client_name: `1MCP Agent - ${serverName}`,
|
|
34
|
+
redirect_uris: [config.redirectUrl || ''],
|
|
35
|
+
grant_types: ['authorization_code', 'refresh_token'],
|
|
36
|
+
response_types: ['code'],
|
|
37
|
+
token_endpoint_auth_method: config.clientSecret ? 'client_secret_post' : 'none',
|
|
38
|
+
scope: config.scopes?.join(' ') || AUTH_CONFIG.CLIENT.OAUTH.DEFAULT_SCOPES.join(' '),
|
|
39
|
+
};
|
|
40
|
+
logger.debug(`OAuth client metadata: ${JSON.stringify(this._clientMetadata)}`);
|
|
41
|
+
// Load existing client info and tokens if available
|
|
42
|
+
this.loadPersistedData();
|
|
43
|
+
}
|
|
44
|
+
get redirectUrl() {
|
|
45
|
+
return this.config.redirectUrl || '';
|
|
46
|
+
}
|
|
47
|
+
get clientMetadata() {
|
|
48
|
+
return this._clientMetadata;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns current client registration information
|
|
52
|
+
*/
|
|
53
|
+
clientInformation() {
|
|
54
|
+
return this._clientInfo;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Saves client registration information from dynamic registration
|
|
58
|
+
*/
|
|
59
|
+
saveClientInformation(clientInfo) {
|
|
60
|
+
this._clientInfo = clientInfo;
|
|
61
|
+
this.persistAllData();
|
|
62
|
+
logger.info(`OAuth client registered for ${this.serverName}: ${clientInfo.client_id}`);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns current OAuth tokens
|
|
66
|
+
*/
|
|
67
|
+
tokens() {
|
|
68
|
+
return this._tokens;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Saves OAuth tokens after successful authorization
|
|
72
|
+
*/
|
|
73
|
+
saveTokens(tokens) {
|
|
74
|
+
this._tokens = tokens;
|
|
75
|
+
this.persistAllData();
|
|
76
|
+
logger.info(`OAuth tokens saved for ${this.serverName}`);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Stores authorization URL instead of prompting user in console
|
|
80
|
+
*/
|
|
81
|
+
redirectToAuthorization(authorizationUrl) {
|
|
82
|
+
this._authorizationUrl = authorizationUrl.toString();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Gets the current authorization URL
|
|
86
|
+
*/
|
|
87
|
+
getAuthorizationUrl() {
|
|
88
|
+
return this._authorizationUrl;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Clears the stored authorization URL
|
|
92
|
+
*/
|
|
93
|
+
clearAuthorizationUrl() {
|
|
94
|
+
this._authorizationUrl = undefined;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Saves PKCE code verifier for the authorization session
|
|
98
|
+
*/
|
|
99
|
+
saveCodeVerifier(codeVerifier) {
|
|
100
|
+
this._codeVerifier = codeVerifier;
|
|
101
|
+
this.persistAllData();
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Returns the PKCE code verifier for token exchange
|
|
105
|
+
*/
|
|
106
|
+
codeVerifier() {
|
|
107
|
+
return this._codeVerifier || '';
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns the OAuth state parameter for CSRF protection
|
|
111
|
+
*/
|
|
112
|
+
state() {
|
|
113
|
+
if (!this._state) {
|
|
114
|
+
this._state = randomUUID();
|
|
115
|
+
this.persistAllData();
|
|
116
|
+
}
|
|
117
|
+
return this._state;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Custom resource validation (optional)
|
|
121
|
+
*/
|
|
122
|
+
async validateResourceURL(serverUrl, resource) {
|
|
123
|
+
const url = typeof serverUrl === 'string' ? new URL(serverUrl) : serverUrl;
|
|
124
|
+
// Basic validation - can be extended for specific requirements
|
|
125
|
+
if (resource && !resource.startsWith(url.origin)) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
return url;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Load persisted OAuth data from unified client session storage
|
|
132
|
+
*/
|
|
133
|
+
loadPersistedData() {
|
|
134
|
+
const clientSession = this.sessionRepository.get(this.serverName);
|
|
135
|
+
if (clientSession) {
|
|
136
|
+
// Load client info
|
|
137
|
+
if (clientSession.clientInfo) {
|
|
138
|
+
this._clientInfo = JSON.parse(clientSession.clientInfo);
|
|
139
|
+
}
|
|
140
|
+
// Load tokens
|
|
141
|
+
if (clientSession.tokens) {
|
|
142
|
+
this._tokens = JSON.parse(clientSession.tokens);
|
|
143
|
+
// Check if tokens are expired
|
|
144
|
+
if (this._tokens && this.isTokenExpired(this._tokens)) {
|
|
145
|
+
logger.warn(`OAuth tokens expired for ${this.serverName}, clearing`);
|
|
146
|
+
this._tokens = undefined;
|
|
147
|
+
this.persistAllData();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// Load code verifier
|
|
151
|
+
if (clientSession.codeVerifier) {
|
|
152
|
+
this._codeVerifier = clientSession.codeVerifier;
|
|
153
|
+
}
|
|
154
|
+
// Load state
|
|
155
|
+
if (clientSession.state) {
|
|
156
|
+
this._state = clientSession.state;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Persist all OAuth data to unified client session storage
|
|
162
|
+
*/
|
|
163
|
+
persistAllData() {
|
|
164
|
+
// Calculate the longest TTL based on the data we have
|
|
165
|
+
let maxTtl = AUTH_CONFIG.CLIENT.OAUTH.TTL_MS; // Default to 30 days
|
|
166
|
+
// If we have tokens, use their expiry time
|
|
167
|
+
if (this._tokens && this._tokens.expires_in) {
|
|
168
|
+
const tokenTtl = this._tokens.expires_in * 1000;
|
|
169
|
+
maxTtl = Math.max(maxTtl, tokenTtl);
|
|
170
|
+
}
|
|
171
|
+
// Code verifier and state have shorter TTL, but we keep them for completeness
|
|
172
|
+
const clientSessionData = {
|
|
173
|
+
serverName: this.serverName,
|
|
174
|
+
clientInfo: this._clientInfo ? JSON.stringify(this._clientInfo) : undefined,
|
|
175
|
+
tokens: this._tokens ? JSON.stringify(this._tokens) : undefined,
|
|
176
|
+
codeVerifier: this._codeVerifier,
|
|
177
|
+
state: this._state,
|
|
178
|
+
expires: Date.now() + maxTtl,
|
|
179
|
+
createdAt: Date.now(),
|
|
180
|
+
};
|
|
181
|
+
this.sessionRepository.save(this.serverName, clientSessionData, maxTtl);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Check if OAuth tokens are expired
|
|
185
|
+
*/
|
|
186
|
+
isTokenExpired(tokens) {
|
|
187
|
+
if (!tokens.expires_in) {
|
|
188
|
+
return false; // No expiration info, assume valid
|
|
189
|
+
}
|
|
190
|
+
// This is a simple check - in practice, you might want to store the issued_at time
|
|
191
|
+
// For now, we'll rely on the session storage TTL for expiration
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Clean up resources
|
|
196
|
+
*/
|
|
197
|
+
shutdown() {
|
|
198
|
+
// Clean up temporary session data by clearing verifier and state
|
|
199
|
+
this._codeVerifier = undefined;
|
|
200
|
+
this._state = undefined;
|
|
201
|
+
this.persistAllData();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=sdkOAuthClientProvider.js.map
|
|
@@ -0,0 +1 @@
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U,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;YAC3E,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS;YAC/D,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM;YAC5B,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC;QAEF,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAC;IAC1E,CAAC;IAED;;OAEG;IACK,cAAc,CAAC,MAAmB;QACxC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACvB,OAAO,KAAK,CAAC,CAAC,mCAAmC;QACnD,CAAC;QAED,mFAAmF;QACnF,gEAAgE;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,iEAAiE;QACjE,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Response } from 'express';
|
|
2
|
+
import type { OAuthServerProvider, AuthorizationParams } from '@modelcontextprotocol/sdk/server/auth/provider.js';
|
|
3
|
+
import type { OAuthRegisteredClientsStore } from '@modelcontextprotocol/sdk/server/auth/clients.js';
|
|
4
|
+
import type { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
|
|
5
|
+
import type { OAuthClientInformationFull, OAuthTokens, OAuthTokenRevocationRequest } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
6
|
+
import { OAuthStorageService } from './storage/oauthStorageService.js';
|
|
7
|
+
/**
|
|
8
|
+
* Implementation of SDK's OAuthServerProvider interface using the new repository architecture.
|
|
9
|
+
*
|
|
10
|
+
* This provider implements OAuth 2.1 server functionality using the MCP SDK's interfaces
|
|
11
|
+
* with the new layered storage architecture for better separation of concerns.
|
|
12
|
+
*/
|
|
13
|
+
export declare class SDKOAuthServerProvider implements OAuthServerProvider {
|
|
14
|
+
oauthStorage: OAuthStorageService;
|
|
15
|
+
private configManager;
|
|
16
|
+
private _clientsStore;
|
|
17
|
+
constructor(sessionStoragePath?: string);
|
|
18
|
+
get clientsStore(): OAuthRegisteredClientsStore;
|
|
19
|
+
/**
|
|
20
|
+
* Handles the authorization request with scope validation and user consent
|
|
21
|
+
*/
|
|
22
|
+
authorize(client: OAuthClientInformationFull, params: AuthorizationParams, res: Response): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Determines if user consent is required for the authorization
|
|
25
|
+
*/
|
|
26
|
+
private requiresUserConsent;
|
|
27
|
+
/**
|
|
28
|
+
* Renders the consent page for scope selection
|
|
29
|
+
*/
|
|
30
|
+
private renderConsentPage;
|
|
31
|
+
/**
|
|
32
|
+
* Approves the authorization and redirects back to client
|
|
33
|
+
*/
|
|
34
|
+
approveAuthorization(client: OAuthClientInformationFull, params: AuthorizationParams, grantedScopes: string[], res: Response): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Generates the HTML for the consent page
|
|
37
|
+
*/
|
|
38
|
+
private generateConsentPageHtml;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves the PKCE challenge for an authorization code
|
|
41
|
+
*/
|
|
42
|
+
challengeForAuthorizationCode(client: OAuthClientInformationFull, authorizationCode: string): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Exchanges authorization code for access token
|
|
45
|
+
*/
|
|
46
|
+
exchangeAuthorizationCode(client: OAuthClientInformationFull, authorizationCode: string, _codeVerifier?: string, redirectUri?: string, resource?: URL): Promise<OAuthTokens>;
|
|
47
|
+
/**
|
|
48
|
+
* Exchanges refresh token for new access token (not implemented)
|
|
49
|
+
*/
|
|
50
|
+
exchangeRefreshToken(_client: OAuthClientInformationFull, _refreshToken: string, _scopes?: string[], _resource?: URL): Promise<OAuthTokens>;
|
|
51
|
+
/**
|
|
52
|
+
* Verifies access token and returns auth info with granted scopes
|
|
53
|
+
*/
|
|
54
|
+
verifyAccessToken(token: string): Promise<AuthInfo>;
|
|
55
|
+
/**
|
|
56
|
+
* Revokes a token
|
|
57
|
+
*/
|
|
58
|
+
revokeToken(client: OAuthClientInformationFull, request: OAuthTokenRevocationRequest): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Graceful shutdown
|
|
61
|
+
*/
|
|
62
|
+
shutdown(): void;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=sdkOAuthServerProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdkOAuthServerProvider.d.ts","sourceRoot":"","sources":["../../src/auth/sdkOAuthServerProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AAClH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AACpG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAC/E,OAAO,KAAK,EACV,0BAA0B,EAC1B,WAAW,EACX,2BAA2B,EAC5B,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAoDvE;;;;;GAKG;AACH,qBAAa,sBAAuB,YAAW,mBAAmB;IACzD,YAAY,EAAE,mBAAmB,CAAC;IACzC,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,aAAa,CA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