@revealui/mcp 0.0.1-pre.0 → 0.1.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/LICENSE +22 -202
- package/LICENSE.commercial +112 -0
- package/README.md +263 -0
- package/dist/adapters/db.d.ts +46 -0
- package/dist/adapters/db.d.ts.map +1 -0
- package/dist/adapters/db.js +127 -0
- package/dist/adapters/db.js.map +1 -0
- package/dist/config/index.d.ts +11 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +18 -0
- package/dist/config/index.js.map +1 -0
- package/dist/contracts.d.ts +131 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +153 -0
- package/dist/contracts.js.map +1 -0
- package/dist/hypervisor.d.ts +132 -0
- package/dist/hypervisor.d.ts.map +1 -0
- package/dist/hypervisor.js +359 -0
- package/dist/hypervisor.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -10985
- package/dist/index.js.map +1 -1
- package/dist/servers/adapter.d.ts +209 -0
- package/dist/servers/adapter.d.ts.map +1 -0
- package/dist/servers/adapter.js +503 -0
- package/dist/servers/adapter.js.map +1 -0
- package/dist/servers/revealui-content.d.ts +21 -0
- package/dist/servers/revealui-content.d.ts.map +1 -0
- package/dist/servers/revealui-content.js +199 -0
- package/dist/servers/revealui-content.js.map +1 -0
- package/dist/servers/revealui-email.d.ts +18 -0
- package/dist/servers/revealui-email.d.ts.map +1 -0
- package/dist/servers/revealui-email.js +185 -0
- package/dist/servers/revealui-email.js.map +1 -0
- package/dist/servers/revealui-stripe.d.ts +19 -0
- package/dist/servers/revealui-stripe.d.ts.map +1 -0
- package/dist/servers/revealui-stripe.js +211 -0
- package/dist/servers/revealui-stripe.js.map +1 -0
- package/package.json +43 -68
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* MCP Adapter - Generic Model Context Protocol Integration
|
|
4
|
+
*
|
|
5
|
+
* Provides a unified interface for all MCP server integrations,
|
|
6
|
+
* eliminating code duplication across different service adapters.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* const adapter = new MCPAdapter('vercel', config)
|
|
10
|
+
* await adapter.execute(request)
|
|
11
|
+
*/
|
|
12
|
+
export declare enum McpErrorCode {
|
|
13
|
+
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
14
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
15
|
+
TIMEOUT_ERROR = "TIMEOUT_ERROR",
|
|
16
|
+
CONFIG_ERROR = "CONFIG_ERROR"
|
|
17
|
+
}
|
|
18
|
+
export declare class McpError extends Error {
|
|
19
|
+
code: McpErrorCode;
|
|
20
|
+
constructor(message: string, code: McpErrorCode);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Dispose all active MCP adapters (cleanup on shutdown)
|
|
24
|
+
*/
|
|
25
|
+
export declare function disposeAllAdapters(): void;
|
|
26
|
+
export interface MCPRequest {
|
|
27
|
+
action: string;
|
|
28
|
+
parameters?: Record<string, unknown>;
|
|
29
|
+
options?: {
|
|
30
|
+
timeout?: number;
|
|
31
|
+
retries?: number;
|
|
32
|
+
dryRun?: boolean;
|
|
33
|
+
/** Idempotency key to prevent duplicate operations */
|
|
34
|
+
idempotencyKey?: string;
|
|
35
|
+
/** TTL for idempotency cache in milliseconds (default: 5 minutes) */
|
|
36
|
+
idempotencyTTL?: number;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface MCPResponse {
|
|
40
|
+
success: boolean;
|
|
41
|
+
data?: unknown;
|
|
42
|
+
error?: string;
|
|
43
|
+
metadata?: {
|
|
44
|
+
duration: number;
|
|
45
|
+
retries: number;
|
|
46
|
+
service: string;
|
|
47
|
+
/** Indicates this response was served from idempotency cache */
|
|
48
|
+
cached?: boolean;
|
|
49
|
+
/** The idempotency key that was used */
|
|
50
|
+
idempotencyKey?: string;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* In-memory idempotency cache for preventing duplicate operations.
|
|
55
|
+
* Each adapter instance has its own cache.
|
|
56
|
+
*/
|
|
57
|
+
declare class IdempotencyCache {
|
|
58
|
+
private cache;
|
|
59
|
+
private cleanupInterval;
|
|
60
|
+
private readonly DEFAULT_TTL;
|
|
61
|
+
constructor();
|
|
62
|
+
/**
|
|
63
|
+
* Get a cached response by idempotency key
|
|
64
|
+
*/
|
|
65
|
+
get(key: string): MCPResponse | null;
|
|
66
|
+
/**
|
|
67
|
+
* Store a response with idempotency key
|
|
68
|
+
*/
|
|
69
|
+
set(key: string, response: MCPResponse, ttl?: number): void;
|
|
70
|
+
/**
|
|
71
|
+
* Check if a key exists in the cache
|
|
72
|
+
*/
|
|
73
|
+
has(key: string): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Remove expired entries
|
|
76
|
+
*/
|
|
77
|
+
private cleanup;
|
|
78
|
+
/**
|
|
79
|
+
* Clear all cached entries
|
|
80
|
+
*/
|
|
81
|
+
clear(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Stop the cleanup interval
|
|
84
|
+
*/
|
|
85
|
+
dispose(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Get cache statistics
|
|
88
|
+
*/
|
|
89
|
+
stats(): {
|
|
90
|
+
size: number;
|
|
91
|
+
keys: string[];
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export interface MCPConfig {
|
|
95
|
+
apiKey?: string;
|
|
96
|
+
baseUrl?: string;
|
|
97
|
+
timeout?: number;
|
|
98
|
+
retries?: number;
|
|
99
|
+
environment?: 'development' | 'production';
|
|
100
|
+
}
|
|
101
|
+
export declare abstract class MCPAdapter {
|
|
102
|
+
protected serviceName: string;
|
|
103
|
+
protected config: MCPConfig;
|
|
104
|
+
protected logger: import("@revealui/utils/logger").Logger;
|
|
105
|
+
protected idempotencyCache: IdempotencyCache;
|
|
106
|
+
constructor(serviceName: string, config: MCPConfig);
|
|
107
|
+
/**
|
|
108
|
+
* Dispose of adapter resources (cleanup idempotency cache)
|
|
109
|
+
*/
|
|
110
|
+
dispose(): void;
|
|
111
|
+
/**
|
|
112
|
+
* Get idempotency cache statistics
|
|
113
|
+
*/
|
|
114
|
+
getCacheStats(): {
|
|
115
|
+
size: number;
|
|
116
|
+
keys: string[];
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Clear the idempotency cache
|
|
120
|
+
*/
|
|
121
|
+
clearCache(): void;
|
|
122
|
+
/**
|
|
123
|
+
* Execute an MCP request
|
|
124
|
+
*
|
|
125
|
+
* If an idempotencyKey is provided in options, the request will be checked
|
|
126
|
+
* against the cache. If a cached response exists, it will be returned
|
|
127
|
+
* immediately. Otherwise, the request will be executed and the response
|
|
128
|
+
* will be cached for future duplicate requests.
|
|
129
|
+
*/
|
|
130
|
+
execute(request: MCPRequest): Promise<MCPResponse>;
|
|
131
|
+
/**
|
|
132
|
+
* Validate the incoming request
|
|
133
|
+
*/
|
|
134
|
+
protected validateRequest(request: MCPRequest): void;
|
|
135
|
+
/**
|
|
136
|
+
* Check if an action is supported by this adapter
|
|
137
|
+
*/
|
|
138
|
+
protected abstract isValidAction(action: string): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Execute the actual request (implemented by subclasses)
|
|
141
|
+
*/
|
|
142
|
+
protected abstract executeRequest(request: MCPRequest): Promise<unknown>;
|
|
143
|
+
/**
|
|
144
|
+
* Create a dry-run response
|
|
145
|
+
*/
|
|
146
|
+
protected createDryRunResponse(request: MCPRequest): MCPResponse;
|
|
147
|
+
/**
|
|
148
|
+
* Get authentication headers for API calls
|
|
149
|
+
*/
|
|
150
|
+
protected getAuthHeaders(): Record<string, string>;
|
|
151
|
+
/**
|
|
152
|
+
* Get the authentication header name for this service
|
|
153
|
+
*/
|
|
154
|
+
protected abstract getAuthHeaderName(): string;
|
|
155
|
+
/**
|
|
156
|
+
* Make an HTTP request with proper error handling
|
|
157
|
+
*/
|
|
158
|
+
protected makeRequest(method: 'GET' | 'POST' | 'PUT' | 'DELETE', url: string, data?: unknown): Promise<unknown>;
|
|
159
|
+
}
|
|
160
|
+
export declare class VercelAdapter extends MCPAdapter {
|
|
161
|
+
constructor(config: MCPConfig);
|
|
162
|
+
protected isValidAction(action: string): boolean;
|
|
163
|
+
protected getAuthHeaderName(): string;
|
|
164
|
+
protected executeRequest(request: MCPRequest): Promise<unknown>;
|
|
165
|
+
}
|
|
166
|
+
export declare class StripeAdapter extends MCPAdapter {
|
|
167
|
+
constructor(config: MCPConfig);
|
|
168
|
+
protected isValidAction(action: string): boolean;
|
|
169
|
+
protected getAuthHeaderName(): string;
|
|
170
|
+
protected executeRequest(request: MCPRequest): Promise<unknown>;
|
|
171
|
+
}
|
|
172
|
+
export declare class NeonAdapter extends MCPAdapter {
|
|
173
|
+
constructor(config: MCPConfig);
|
|
174
|
+
protected isValidAction(action: string): boolean;
|
|
175
|
+
protected getAuthHeaderName(): string;
|
|
176
|
+
protected executeRequest(request: MCPRequest): Promise<unknown>;
|
|
177
|
+
}
|
|
178
|
+
export declare function createMCPAdapter(service: string, config: MCPConfig): MCPAdapter;
|
|
179
|
+
/**
|
|
180
|
+
* Generate an idempotency key based on the request content.
|
|
181
|
+
*
|
|
182
|
+
* This creates a deterministic key from the action and parameters,
|
|
183
|
+
* so identical requests will get the same key.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const key = generateIdempotencyKey({
|
|
188
|
+
* action: 'deploy',
|
|
189
|
+
* parameters: { projectId: '123' }
|
|
190
|
+
* })
|
|
191
|
+
* // Returns: "deploy:a1b2c3d4e5f6..."
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
export declare function generateIdempotencyKey(request: MCPRequest): string;
|
|
195
|
+
/**
|
|
196
|
+
* Generate a unique idempotency key with timestamp.
|
|
197
|
+
*
|
|
198
|
+
* Use this when you want each request to be unique but still
|
|
199
|
+
* want idempotency protection against rapid duplicate submissions.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* const key = generateUniqueIdempotencyKey('deploy')
|
|
204
|
+
* // Returns: "deploy:1706536800000:a1b2c3d4"
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
export declare function generateUniqueIdempotencyKey(action: string): string;
|
|
208
|
+
export {};
|
|
209
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/servers/adapter.ts"],"names":[],"mappings":";AAEA;;;;;;;;;GASG;AAMH,oBAAY,YAAY;IACtB,gBAAgB,qBAAqB;IACrC,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;CAC9B;AAED,qBAAa,QAAS,SAAQ,KAAK;IACjC,IAAI,EAAE,YAAY,CAAA;gBACN,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY;CAKhD;AAgBD;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAYzC;AAmBD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,MAAM,CAAC,EAAE,OAAO,CAAA;QAChB,sDAAsD;QACtD,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,qEAAqE;QACrE,cAAc,CAAC,EAAE,MAAM,CAAA;KACxB,CAAA;CACF;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE;QACT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