@claude-flow/cli 3.38.9 → 3.38.12
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/.claude/helpers/.helpers-version +1 -1
- package/.claude/helpers/helpers.manifest.json +2 -2
- package/catalog-manifest.json +2 -2
- package/dist/src/commands/doctor.js +53 -8
- package/dist/src/commands/hooks.js +3 -2
- package/dist/src/commands/mcp.js +4 -3
- package/dist/src/init/executor.d.ts +6 -0
- package/dist/src/init/executor.js +5 -3
- package/dist/src/init/helper-refresh.d.ts +16 -9
- package/dist/src/init/helper-refresh.js +177 -20
- package/dist/src/init/settings-generator.js +6 -2
- package/dist/src/log-filters.d.ts +3 -3
- package/dist/src/mcp-server.d.ts +1 -0
- package/dist/src/mcp-server.js +39 -3
- package/dist/src/mcp-tools/neural-tools.js +4 -3
- package/dist/src/memory/memory-bridge.d.ts +8 -0
- package/dist/src/memory/memory-bridge.js +18 -0
- package/node_modules/@claude-flow/codex/dist/cli.js +0 -0
- package/node_modules/@claude-flow/mcp/README.md +429 -0
- package/node_modules/@claude-flow/mcp/dist/connection-pool.d.ts +36 -0
- package/node_modules/@claude-flow/mcp/dist/connection-pool.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/connection-pool.js +273 -0
- package/node_modules/@claude-flow/mcp/dist/connection-pool.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/index.d.ts +75 -0
- package/node_modules/@claude-flow/mcp/dist/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/index.js +85 -0
- package/node_modules/@claude-flow/mcp/dist/index.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/oauth.d.ts +146 -0
- package/node_modules/@claude-flow/mcp/dist/oauth.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/oauth.js +318 -0
- package/node_modules/@claude-flow/mcp/dist/oauth.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/prompt-registry.d.ts +90 -0
- package/node_modules/@claude-flow/mcp/dist/prompt-registry.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/prompt-registry.js +209 -0
- package/node_modules/@claude-flow/mcp/dist/prompt-registry.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/rate-limiter.d.ts +86 -0
- package/node_modules/@claude-flow/mcp/dist/rate-limiter.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/rate-limiter.js +197 -0
- package/node_modules/@claude-flow/mcp/dist/rate-limiter.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/resource-registry.d.ts +144 -0
- package/node_modules/@claude-flow/mcp/dist/resource-registry.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/resource-registry.js +405 -0
- package/node_modules/@claude-flow/mcp/dist/resource-registry.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/sampling.d.ts +102 -0
- package/node_modules/@claude-flow/mcp/dist/sampling.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/sampling.js +268 -0
- package/node_modules/@claude-flow/mcp/dist/sampling.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/schema-validator.d.ts +30 -0
- package/node_modules/@claude-flow/mcp/dist/schema-validator.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/schema-validator.js +182 -0
- package/node_modules/@claude-flow/mcp/dist/schema-validator.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/server.d.ts +125 -0
- package/node_modules/@claude-flow/mcp/dist/server.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/server.js +849 -0
- package/node_modules/@claude-flow/mcp/dist/server.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/session-manager.d.ts +55 -0
- package/node_modules/@claude-flow/mcp/dist/session-manager.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/session-manager.js +252 -0
- package/node_modules/@claude-flow/mcp/dist/session-manager.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/task-manager.d.ts +81 -0
- package/node_modules/@claude-flow/mcp/dist/task-manager.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/task-manager.js +337 -0
- package/node_modules/@claude-flow/mcp/dist/task-manager.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/tool-registry.d.ts +96 -0
- package/node_modules/@claude-flow/mcp/dist/tool-registry.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/tool-registry.js +399 -0
- package/node_modules/@claude-flow/mcp/dist/tool-registry.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/transport/http.d.ts +60 -0
- package/node_modules/@claude-flow/mcp/dist/transport/http.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/transport/http.js +503 -0
- package/node_modules/@claude-flow/mcp/dist/transport/http.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/transport/index.d.ts +50 -0
- package/node_modules/@claude-flow/mcp/dist/transport/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/transport/index.js +181 -0
- package/node_modules/@claude-flow/mcp/dist/transport/index.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/transport/stdio.d.ts +43 -0
- package/node_modules/@claude-flow/mcp/dist/transport/stdio.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/transport/stdio.js +194 -0
- package/node_modules/@claude-flow/mcp/dist/transport/stdio.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/transport/websocket.d.ts +65 -0
- package/node_modules/@claude-flow/mcp/dist/transport/websocket.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/transport/websocket.js +314 -0
- package/node_modules/@claude-flow/mcp/dist/transport/websocket.js.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/types.d.ts +482 -0
- package/node_modules/@claude-flow/mcp/dist/types.d.ts.map +1 -0
- package/node_modules/@claude-flow/mcp/dist/types.js +40 -0
- package/node_modules/@claude-flow/mcp/dist/types.js.map +1 -0
- package/node_modules/@claude-flow/mcp/package.json +50 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js +0 -0
- package/node_modules/@claude-flow/security/dist/path-validator.d.ts +23 -0
- package/node_modules/@claude-flow/security/dist/path-validator.d.ts.map +1 -1
- package/node_modules/@claude-flow/security/dist/path-validator.js +128 -27
- package/node_modules/@claude-flow/security/dist/path-validator.js.map +1 -1
- package/package.json +9 -2
- package/.claude/.proven-config-version +0 -1
- package/.claude/proven-config.json +0 -42
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @claude-flow/mcp - Connection Pool
|
|
3
|
+
*
|
|
4
|
+
* High-performance connection pooling
|
|
5
|
+
*/
|
|
6
|
+
import { EventEmitter } from 'events';
|
|
7
|
+
const DEFAULT_POOL_CONFIG = {
|
|
8
|
+
maxConnections: 10,
|
|
9
|
+
minConnections: 2,
|
|
10
|
+
idleTimeout: 30000,
|
|
11
|
+
acquireTimeout: 5000,
|
|
12
|
+
maxWaitingClients: 50,
|
|
13
|
+
evictionRunInterval: 10000,
|
|
14
|
+
};
|
|
15
|
+
class ManagedConnection {
|
|
16
|
+
id;
|
|
17
|
+
transport;
|
|
18
|
+
createdAt;
|
|
19
|
+
metadata;
|
|
20
|
+
state = 'idle';
|
|
21
|
+
lastUsedAt;
|
|
22
|
+
useCount = 0;
|
|
23
|
+
constructor(id, transport, createdAt = new Date(), metadata) {
|
|
24
|
+
this.id = id;
|
|
25
|
+
this.transport = transport;
|
|
26
|
+
this.createdAt = createdAt;
|
|
27
|
+
this.metadata = metadata;
|
|
28
|
+
this.lastUsedAt = this.createdAt;
|
|
29
|
+
}
|
|
30
|
+
acquire() {
|
|
31
|
+
this.state = 'busy';
|
|
32
|
+
this.lastUsedAt = new Date();
|
|
33
|
+
this.useCount++;
|
|
34
|
+
}
|
|
35
|
+
release() {
|
|
36
|
+
this.state = 'idle';
|
|
37
|
+
this.lastUsedAt = new Date();
|
|
38
|
+
}
|
|
39
|
+
isExpired(idleTimeout) {
|
|
40
|
+
if (this.state !== 'idle')
|
|
41
|
+
return false;
|
|
42
|
+
return Date.now() - this.lastUsedAt.getTime() > idleTimeout;
|
|
43
|
+
}
|
|
44
|
+
isHealthy() {
|
|
45
|
+
return this.state !== 'error' && this.state !== 'closed';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class ConnectionPool extends EventEmitter {
|
|
49
|
+
logger;
|
|
50
|
+
transportType;
|
|
51
|
+
config;
|
|
52
|
+
connections = new Map();
|
|
53
|
+
waitingClients = [];
|
|
54
|
+
evictionTimer;
|
|
55
|
+
connectionCounter = 0;
|
|
56
|
+
isShuttingDown = false;
|
|
57
|
+
stats = {
|
|
58
|
+
totalAcquired: 0,
|
|
59
|
+
totalReleased: 0,
|
|
60
|
+
totalCreated: 0,
|
|
61
|
+
totalDestroyed: 0,
|
|
62
|
+
acquireTimeTotal: 0,
|
|
63
|
+
acquireCount: 0,
|
|
64
|
+
};
|
|
65
|
+
constructor(config = {}, logger, transportType = 'in-process') {
|
|
66
|
+
super();
|
|
67
|
+
this.logger = logger;
|
|
68
|
+
this.transportType = transportType;
|
|
69
|
+
this.config = { ...DEFAULT_POOL_CONFIG, ...config };
|
|
70
|
+
this.startEvictionTimer();
|
|
71
|
+
this.initializeMinConnections();
|
|
72
|
+
}
|
|
73
|
+
async initializeMinConnections() {
|
|
74
|
+
const promises = [];
|
|
75
|
+
for (let i = 0; i < this.config.minConnections; i++) {
|
|
76
|
+
promises.push(this.createConnection());
|
|
77
|
+
}
|
|
78
|
+
await Promise.all(promises);
|
|
79
|
+
this.logger.debug('Connection pool initialized', {
|
|
80
|
+
minConnections: this.config.minConnections,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async createConnection() {
|
|
84
|
+
const id = `conn-${++this.connectionCounter}-${Date.now()}`;
|
|
85
|
+
const connection = new ManagedConnection(id, this.transportType);
|
|
86
|
+
this.connections.set(id, connection);
|
|
87
|
+
this.stats.totalCreated++;
|
|
88
|
+
this.emit('pool:connection:created', { connectionId: id });
|
|
89
|
+
this.logger.debug('Connection created', { id, total: this.connections.size });
|
|
90
|
+
return connection;
|
|
91
|
+
}
|
|
92
|
+
async acquire() {
|
|
93
|
+
const startTime = performance.now();
|
|
94
|
+
if (this.isShuttingDown) {
|
|
95
|
+
throw new Error('Connection pool is shutting down');
|
|
96
|
+
}
|
|
97
|
+
for (const connection of this.connections.values()) {
|
|
98
|
+
if (connection.state === 'idle' && connection.isHealthy()) {
|
|
99
|
+
connection.acquire();
|
|
100
|
+
this.stats.totalAcquired++;
|
|
101
|
+
this.recordAcquireTime(startTime);
|
|
102
|
+
this.emit('pool:connection:acquired', { connectionId: connection.id });
|
|
103
|
+
this.logger.debug('Connection acquired from pool', { id: connection.id });
|
|
104
|
+
return connection;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (this.connections.size < this.config.maxConnections) {
|
|
108
|
+
const connection = await this.createConnection();
|
|
109
|
+
connection.acquire();
|
|
110
|
+
this.stats.totalAcquired++;
|
|
111
|
+
this.recordAcquireTime(startTime);
|
|
112
|
+
this.emit('pool:connection:acquired', { connectionId: connection.id });
|
|
113
|
+
return connection;
|
|
114
|
+
}
|
|
115
|
+
return this.waitForConnection(startTime);
|
|
116
|
+
}
|
|
117
|
+
waitForConnection(startTime) {
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
if (this.waitingClients.length >= this.config.maxWaitingClients) {
|
|
120
|
+
reject(new Error('Connection pool exhausted - max waiting clients reached'));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const client = {
|
|
124
|
+
resolve: (connection) => {
|
|
125
|
+
this.recordAcquireTime(startTime);
|
|
126
|
+
resolve(connection);
|
|
127
|
+
},
|
|
128
|
+
reject,
|
|
129
|
+
timestamp: Date.now(),
|
|
130
|
+
};
|
|
131
|
+
this.waitingClients.push(client);
|
|
132
|
+
setTimeout(() => {
|
|
133
|
+
const index = this.waitingClients.indexOf(client);
|
|
134
|
+
if (index !== -1) {
|
|
135
|
+
this.waitingClients.splice(index, 1);
|
|
136
|
+
reject(new Error(`Connection acquire timeout after ${this.config.acquireTimeout}ms`));
|
|
137
|
+
}
|
|
138
|
+
}, this.config.acquireTimeout);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
release(connection) {
|
|
142
|
+
const managed = this.connections.get(connection.id);
|
|
143
|
+
if (!managed) {
|
|
144
|
+
this.logger.warn('Attempted to release unknown connection', { id: connection.id });
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const waitingClient = this.waitingClients.shift();
|
|
148
|
+
if (waitingClient) {
|
|
149
|
+
managed.acquire();
|
|
150
|
+
this.stats.totalAcquired++;
|
|
151
|
+
this.emit('pool:connection:acquired', { connectionId: connection.id });
|
|
152
|
+
waitingClient.resolve(managed);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
managed.release();
|
|
156
|
+
this.stats.totalReleased++;
|
|
157
|
+
this.emit('pool:connection:released', { connectionId: connection.id });
|
|
158
|
+
this.logger.debug('Connection released to pool', { id: connection.id });
|
|
159
|
+
}
|
|
160
|
+
destroy(connection) {
|
|
161
|
+
const managed = this.connections.get(connection.id);
|
|
162
|
+
if (!managed) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
managed.state = 'closed';
|
|
166
|
+
this.connections.delete(connection.id);
|
|
167
|
+
this.stats.totalDestroyed++;
|
|
168
|
+
this.emit('pool:connection:destroyed', { connectionId: connection.id });
|
|
169
|
+
this.logger.debug('Connection destroyed', { id: connection.id });
|
|
170
|
+
if (this.connections.size < this.config.minConnections && !this.isShuttingDown) {
|
|
171
|
+
this.createConnection().catch((err) => {
|
|
172
|
+
this.logger.error('Failed to create replacement connection', err);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
getStats() {
|
|
177
|
+
let idleCount = 0;
|
|
178
|
+
let busyCount = 0;
|
|
179
|
+
for (const connection of this.connections.values()) {
|
|
180
|
+
if (connection.state === 'idle')
|
|
181
|
+
idleCount++;
|
|
182
|
+
else if (connection.state === 'busy')
|
|
183
|
+
busyCount++;
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
totalConnections: this.connections.size,
|
|
187
|
+
idleConnections: idleCount,
|
|
188
|
+
busyConnections: busyCount,
|
|
189
|
+
pendingRequests: this.waitingClients.length,
|
|
190
|
+
totalAcquired: this.stats.totalAcquired,
|
|
191
|
+
totalReleased: this.stats.totalReleased,
|
|
192
|
+
totalCreated: this.stats.totalCreated,
|
|
193
|
+
totalDestroyed: this.stats.totalDestroyed,
|
|
194
|
+
avgAcquireTime: this.stats.acquireCount > 0
|
|
195
|
+
? this.stats.acquireTimeTotal / this.stats.acquireCount
|
|
196
|
+
: 0,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
async drain() {
|
|
200
|
+
this.isShuttingDown = true;
|
|
201
|
+
this.logger.info('Draining connection pool');
|
|
202
|
+
while (this.waitingClients.length > 0) {
|
|
203
|
+
const client = this.waitingClients.shift();
|
|
204
|
+
client?.reject(new Error('Connection pool is draining'));
|
|
205
|
+
}
|
|
206
|
+
const maxWait = 10000;
|
|
207
|
+
const startTime = Date.now();
|
|
208
|
+
while (Date.now() - startTime < maxWait) {
|
|
209
|
+
let busyCount = 0;
|
|
210
|
+
for (const connection of this.connections.values()) {
|
|
211
|
+
if (connection.state === 'busy')
|
|
212
|
+
busyCount++;
|
|
213
|
+
}
|
|
214
|
+
if (busyCount === 0)
|
|
215
|
+
break;
|
|
216
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
217
|
+
}
|
|
218
|
+
this.logger.info('Connection pool drained');
|
|
219
|
+
}
|
|
220
|
+
async clear() {
|
|
221
|
+
this.stopEvictionTimer();
|
|
222
|
+
await this.drain();
|
|
223
|
+
for (const connection of this.connections.values()) {
|
|
224
|
+
connection.state = 'closed';
|
|
225
|
+
}
|
|
226
|
+
this.connections.clear();
|
|
227
|
+
this.logger.info('Connection pool cleared');
|
|
228
|
+
}
|
|
229
|
+
startEvictionTimer() {
|
|
230
|
+
this.evictionTimer = setInterval(() => {
|
|
231
|
+
this.evictIdleConnections();
|
|
232
|
+
}, this.config.evictionRunInterval);
|
|
233
|
+
}
|
|
234
|
+
stopEvictionTimer() {
|
|
235
|
+
if (this.evictionTimer) {
|
|
236
|
+
clearInterval(this.evictionTimer);
|
|
237
|
+
this.evictionTimer = undefined;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
evictIdleConnections() {
|
|
241
|
+
if (this.isShuttingDown)
|
|
242
|
+
return;
|
|
243
|
+
const toEvict = [];
|
|
244
|
+
for (const connection of this.connections.values()) {
|
|
245
|
+
if (connection.isExpired(this.config.idleTimeout) &&
|
|
246
|
+
this.connections.size > this.config.minConnections) {
|
|
247
|
+
toEvict.push(connection);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
for (const connection of toEvict) {
|
|
251
|
+
this.destroy(connection);
|
|
252
|
+
this.logger.debug('Evicted idle connection', { id: connection.id });
|
|
253
|
+
}
|
|
254
|
+
if (toEvict.length > 0) {
|
|
255
|
+
this.logger.info('Evicted idle connections', { count: toEvict.length });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
recordAcquireTime(startTime) {
|
|
259
|
+
const duration = performance.now() - startTime;
|
|
260
|
+
this.stats.acquireTimeTotal += duration;
|
|
261
|
+
this.stats.acquireCount++;
|
|
262
|
+
}
|
|
263
|
+
getConnections() {
|
|
264
|
+
return Array.from(this.connections.values());
|
|
265
|
+
}
|
|
266
|
+
isHealthy() {
|
|
267
|
+
return !this.isShuttingDown && this.connections.size >= this.config.minConnections;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
export function createConnectionPool(config = {}, logger, transportType = 'in-process') {
|
|
271
|
+
return new ConnectionPool(config, logger, transportType);
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=connection-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-pool.js","sourceRoot":"","sources":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/**
|
|
2
|
+
* @claude-flow/mcp - Standalone MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Zero-dependency MCP (Model Context Protocol) implementation
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - High-performance server with <400ms startup
|
|
8
|
+
* - Connection pooling with max 10 connections
|
|
9
|
+
* - Multiple transport support (stdio, http, websocket, in-process)
|
|
10
|
+
* - Fast tool registry with <10ms registration
|
|
11
|
+
* - Session management with timeout handling
|
|
12
|
+
* - Comprehensive metrics and monitoring
|
|
13
|
+
*
|
|
14
|
+
* @module @claude-flow/mcp
|
|
15
|
+
* @version 3.0.0
|
|
16
|
+
*/
|
|
17
|
+
export type { JsonRpcVersion, RequestId, MCPMessage, MCPRequest, MCPResponse, MCPNotification, MCPError, TransportType, AuthMethod, AuthConfig, LoadBalancerConfig, ConnectionPoolConfig, MCPServerConfig, SessionState, MCPSession, MCPClientInfo, MCPCapabilities, MCPProtocolVersion, MCPInitializeParams, MCPInitializeResult, JSONSchema, ToolContext, ToolHandler, MCPTool, ToolCallResult, ToolRegistrationOptions, RequestHandler, NotificationHandler, TransportHealthStatus, ITransport, ConnectionState, PooledConnection, ConnectionPoolStats, IConnectionPool, ToolCallMetrics, MCPServerMetrics, SessionMetrics, MCPEventType, MCPEvent, EventHandler, LogLevel, ILogger, MCPResource, ResourceContent, ResourceTemplate, ResourceListResult, ResourceReadResult, PromptArgument, MCPPrompt, PromptRole, ContentAnnotations, TextContent, ImageContent, AudioContent, EmbeddedResource, PromptContent, PromptMessage, PromptListResult, PromptGetResult, TaskState, MCPTask, TaskProgress, TaskResult, PaginatedRequest, PaginatedResult, ProgressNotification, CancellationParams, SamplingMessage, ModelPreferences, CreateMessageRequest, CreateMessageResult, Root, RootsListResult, MCPLogLevel, LoggingMessage, CompletionReference, CompletionArgument, CompletionResult, } from './types.js';
|
|
18
|
+
export { ErrorCodes, MCPServerError } from './types.js';
|
|
19
|
+
import { MCPServer, createMCPServer } from './server.js';
|
|
20
|
+
export { MCPServer, createMCPServer };
|
|
21
|
+
export type { IMCPServer } from './server.js';
|
|
22
|
+
export { ToolRegistry, createToolRegistry, defineTool, type ToolAuthorizationDecision, type ToolAuthorizer, } from './tool-registry.js';
|
|
23
|
+
import { SessionManager, createSessionManager } from './session-manager.js';
|
|
24
|
+
export { SessionManager, createSessionManager };
|
|
25
|
+
export type { SessionConfig } from './session-manager.js';
|
|
26
|
+
export { ConnectionPool, createConnectionPool } from './connection-pool.js';
|
|
27
|
+
export { ResourceRegistry, createResourceRegistry, createTextResource, createFileResource, } from './resource-registry.js';
|
|
28
|
+
export type { ResourceHandler, SubscriptionCallback, ResourceRegistryOptions } from './resource-registry.js';
|
|
29
|
+
export { PromptRegistry, createPromptRegistry, definePrompt, textMessage, resourceMessage, interpolate, } from './prompt-registry.js';
|
|
30
|
+
export type { PromptHandler, PromptDefinition, PromptRegistryOptions } from './prompt-registry.js';
|
|
31
|
+
export { TaskManager, createTaskManager } from './task-manager.js';
|
|
32
|
+
export type { TaskExecutor, TaskManagerOptions } from './task-manager.js';
|
|
33
|
+
export { validateSchema, formatValidationErrors, createValidator, } from './schema-validator.js';
|
|
34
|
+
export type { ValidationError, ValidationResult } from './schema-validator.js';
|
|
35
|
+
export { RateLimiter, createRateLimiter, rateLimitMiddleware, } from './rate-limiter.js';
|
|
36
|
+
export type { RateLimitConfig, RateLimitResult } from './rate-limiter.js';
|
|
37
|
+
export { SamplingManager, createSamplingManager, createMockProvider, createAnthropicProvider, } from './sampling.js';
|
|
38
|
+
export type { LLMProvider, SamplingConfig, SamplingContext } from './sampling.js';
|
|
39
|
+
export { OAuthManager, createOAuthManager, oauthMiddleware, InMemoryTokenStorage, createGitHubOAuthConfig, createGoogleOAuthConfig, } from './oauth.js';
|
|
40
|
+
export type { OAuthConfig, OAuthTokens, TokenStorage, AuthorizationRequest, } from './oauth.js';
|
|
41
|
+
export { createTransport, createInProcessTransport, TransportManager, createTransportManager, DEFAULT_TRANSPORT_CONFIGS, StdioTransport, HttpTransport, WebSocketTransport, } from './transport/index.js';
|
|
42
|
+
export type { TransportConfig, StdioTransportConfig, HttpTransportConfig, WebSocketTransportConfig, } from './transport/index.js';
|
|
43
|
+
import type { MCPServerConfig, ILogger } from './types.js';
|
|
44
|
+
/**
|
|
45
|
+
* Quick start function to create and configure an MCP server
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { quickStart } from '@claude-flow/mcp';
|
|
50
|
+
*
|
|
51
|
+
* const server = await quickStart({
|
|
52
|
+
* transport: 'stdio',
|
|
53
|
+
* name: 'My MCP Server',
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* server.registerTool({
|
|
57
|
+
* name: 'my-tool',
|
|
58
|
+
* description: 'My custom tool',
|
|
59
|
+
* inputSchema: { type: 'object', properties: {} },
|
|
60
|
+
* handler: async () => ({ result: 'success' }),
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* await server.start();
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function quickStart(config: Partial<MCPServerConfig>, logger?: ILogger): Promise<MCPServer>;
|
|
67
|
+
/**
|
|
68
|
+
* Module version
|
|
69
|
+
*/
|
|
70
|
+
export declare const VERSION = "3.0.0";
|
|
71
|
+
/**
|
|
72
|
+
* Module name
|
|
73
|
+
*/
|
|
74
|
+
export declare const MODULE_NAME = "@claude-flow/mcp";
|
|
75
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,YAAY,EACV,cAAc,EACd,SAAS,EACT,UAAU,EACV,UAAU,EACV,WAAW,EACX,eAAe,EACf,QAAQ,EACR,aAAa,EACb,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,UAAU,EAC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ACX,YAAY,EACZ,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,EACd,aAAa,EACb,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,EAChC,MAAM,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,SAAS,CAAC,CAWpB;AAED;;GAEG;AACH,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,WAAW,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @claude-flow/mcp - Standalone MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Zero-dependency MCP (Model Context Protocol) implementation
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - High-performance server with <400ms startup
|
|
8
|
+
* - Connection pooling with max 10 connections
|
|
9
|
+
* - Multiple transport support (stdio, http, websocket, in-process)
|
|
10
|
+
* - Fast tool registry with <10ms registration
|
|
11
|
+
* - Session management with timeout handling
|
|
12
|
+
* - Comprehensive metrics and monitoring
|
|
13
|
+
*
|
|
14
|
+
* @module @claude-flow/mcp
|
|
15
|
+
* @version 3.0.0
|
|
16
|
+
*/
|
|
17
|
+
// Error handling
|
|
18
|
+
export { ErrorCodes, MCPServerError } from './types.js';
|
|
19
|
+
// Server
|
|
20
|
+
import { MCPServer, createMCPServer } from './server.js';
|
|
21
|
+
export { MCPServer, createMCPServer };
|
|
22
|
+
// Tool Registry
|
|
23
|
+
export { ToolRegistry, createToolRegistry, defineTool, } from './tool-registry.js';
|
|
24
|
+
// Session Manager
|
|
25
|
+
import { SessionManager, createSessionManager } from './session-manager.js';
|
|
26
|
+
export { SessionManager, createSessionManager };
|
|
27
|
+
// Connection Pool
|
|
28
|
+
export { ConnectionPool, createConnectionPool } from './connection-pool.js';
|
|
29
|
+
// Resource Registry (MCP 2025-11-25)
|
|
30
|
+
export { ResourceRegistry, createResourceRegistry, createTextResource, createFileResource, } from './resource-registry.js';
|
|
31
|
+
// Prompt Registry (MCP 2025-11-25)
|
|
32
|
+
export { PromptRegistry, createPromptRegistry, definePrompt, textMessage, resourceMessage, interpolate, } from './prompt-registry.js';
|
|
33
|
+
// Task Manager (MCP 2025-11-25)
|
|
34
|
+
export { TaskManager, createTaskManager } from './task-manager.js';
|
|
35
|
+
// Schema Validator
|
|
36
|
+
export { validateSchema, formatValidationErrors, createValidator, } from './schema-validator.js';
|
|
37
|
+
// Rate Limiter
|
|
38
|
+
export { RateLimiter, createRateLimiter, rateLimitMiddleware, } from './rate-limiter.js';
|
|
39
|
+
// Sampling (Server-initiated LLM)
|
|
40
|
+
export { SamplingManager, createSamplingManager, createMockProvider, createAnthropicProvider, } from './sampling.js';
|
|
41
|
+
// OAuth 2.1
|
|
42
|
+
export { OAuthManager, createOAuthManager, oauthMiddleware, InMemoryTokenStorage, createGitHubOAuthConfig, createGoogleOAuthConfig, } from './oauth.js';
|
|
43
|
+
// Transport layer
|
|
44
|
+
export { createTransport, createInProcessTransport, TransportManager, createTransportManager, DEFAULT_TRANSPORT_CONFIGS, StdioTransport, HttpTransport, WebSocketTransport, } from './transport/index.js';
|
|
45
|
+
/**
|
|
46
|
+
* Quick start function to create and configure an MCP server
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* import { quickStart } from '@claude-flow/mcp';
|
|
51
|
+
*
|
|
52
|
+
* const server = await quickStart({
|
|
53
|
+
* transport: 'stdio',
|
|
54
|
+
* name: 'My MCP Server',
|
|
55
|
+
* });
|
|
56
|
+
*
|
|
57
|
+
* server.registerTool({
|
|
58
|
+
* name: 'my-tool',
|
|
59
|
+
* description: 'My custom tool',
|
|
60
|
+
* inputSchema: { type: 'object', properties: {} },
|
|
61
|
+
* handler: async () => ({ result: 'success' }),
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* await server.start();
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export async function quickStart(config, logger) {
|
|
68
|
+
const defaultLogger = logger || {
|
|
69
|
+
debug: (msg, data) => console.debug(`[DEBUG] ${msg}`, data || ''),
|
|
70
|
+
info: (msg, data) => console.info(`[INFO] ${msg}`, data || ''),
|
|
71
|
+
warn: (msg, data) => console.warn(`[WARN] ${msg}`, data || ''),
|
|
72
|
+
error: (msg, data) => console.error(`[ERROR] ${msg}`, data || ''),
|
|
73
|
+
};
|
|
74
|
+
const server = createMCPServer(config, defaultLogger);
|
|
75
|
+
return server;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Module version
|
|
79
|
+
*/
|
|
80
|
+
export const VERSION = '3.0.0';
|
|
81
|
+
/**
|
|
82
|
+
* Module name
|
|
83
|
+
*/
|
|
84
|
+
export const MODULE_NAME = '@claude-flow/mcp';
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAqFH,iBAAiB;AACjB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAExD,SAAS;AACT,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AAGtC,gBAAgB;AAChB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,UAAU,GAGX,MAA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Aa,GAAY,MAAM,IAAI;QACvC,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC;QACjE,IAAI,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,GAAG,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC;QAC9D,IAAI,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,GAAG,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC;QAC9D,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC;KAClE,CAAC;IAEF,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAEtD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @claude-flow/mcp - OAuth 2.1 Authentication
|
|
3
|
+
*
|
|
4
|
+
* MCP 2025-11-25 compliant OAuth 2.1 with PKCE
|
|
5
|
+
*/
|
|
6
|
+
import { EventEmitter } from 'events';
|
|
7
|
+
import type { ILogger } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* OAuth 2.1 configuration
|
|
10
|
+
*/
|
|
11
|
+
export interface OAuthConfig {
|
|
12
|
+
/** Client ID */
|
|
13
|
+
clientId: string;
|
|
14
|
+
/** Client secret (for confidential clients) */
|
|
15
|
+
clientSecret?: string;
|
|
16
|
+
/** Authorization endpoint */
|
|
17
|
+
authorizationEndpoint: string;
|
|
18
|
+
/** Token endpoint */
|
|
19
|
+
tokenEndpoint: string;
|
|
20
|
+
/** Redirect URI */
|
|
21
|
+
redirectUri: string;
|
|
22
|
+
/** Scopes to request */
|
|
23
|
+
scopes?: string[];
|
|
24
|
+
/** Token storage adapter */
|
|
25
|
+
tokenStorage?: TokenStorage;
|
|
26
|
+
/** Enable PKCE (default: true) */
|
|
27
|
+
usePKCE?: boolean;
|
|
28
|
+
/** State parameter generator */
|
|
29
|
+
stateGenerator?: () => string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* OAuth tokens
|
|
33
|
+
*/
|
|
34
|
+
export interface OAuthTokens {
|
|
35
|
+
accessToken: string;
|
|
36
|
+
refreshToken?: string;
|
|
37
|
+
tokenType: string;
|
|
38
|
+
expiresIn?: number;
|
|
39
|
+
expiresAt?: number;
|
|
40
|
+
scope?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Token storage interface
|
|
44
|
+
*/
|
|
45
|
+
export interface TokenStorage {
|
|
46
|
+
save(key: string, tokens: OAuthTokens): Promise<void>;
|
|
47
|
+
load(key: string): Promise<OAuthTokens | null>;
|
|
48
|
+
delete(key: string): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Authorization request
|
|
52
|
+
*/
|
|
53
|
+
export interface AuthorizationRequest {
|
|
54
|
+
url: string;
|
|
55
|
+
state: string;
|
|
56
|
+
codeVerifier?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* In-memory token storage (for development)
|
|
60
|
+
*/
|
|
61
|
+
export declare class InMemoryTokenStorage implements TokenStorage {
|
|
62
|
+
private tokens;
|
|
63
|
+
save(key: string, tokens: OAuthTokens): Promise<void>;
|
|
64
|
+
load(key: string): Promise<OAuthTokens | null>;
|
|
65
|
+
delete(key: string): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* OAuth 2.1 Manager
|
|
69
|
+
*/
|
|
70
|
+
export declare class OAuthManager extends EventEmitter {
|
|
71
|
+
private readonly logger;
|
|
72
|
+
private readonly config;
|
|
73
|
+
private readonly tokenStorage;
|
|
74
|
+
private pendingRequests;
|
|
75
|
+
private cleanupTimer?;
|
|
76
|
+
constructor(logger: ILogger, config: OAuthConfig);
|
|
77
|
+
/**
|
|
78
|
+
* Generate authorization URL for OAuth flow
|
|
79
|
+
*/
|
|
80
|
+
createAuthorizationRequest(): AuthorizationRequest;
|
|
81
|
+
/**
|
|
82
|
+
* Exchange authorization code for tokens
|
|
83
|
+
*/
|
|
84
|
+
exchangeCode(code: string, state: string): Promise<OAuthTokens>;
|
|
85
|
+
/**
|
|
86
|
+
* Refresh access token using refresh token
|
|
87
|
+
*/
|
|
88
|
+
refreshTokens(storageKey?: string): Promise<OAuthTokens>;
|
|
89
|
+
/**
|
|
90
|
+
* Get valid access token (auto-refresh if expired)
|
|
91
|
+
*/
|
|
92
|
+
getAccessToken(storageKey?: string): Promise<string | null>;
|
|
93
|
+
/**
|
|
94
|
+
* Revoke tokens
|
|
95
|
+
*/
|
|
96
|
+
revokeTokens(storageKey?: string): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Check if authenticated
|
|
99
|
+
*/
|
|
100
|
+
isAuthenticated(storageKey?: string): Promise<boolean>;
|
|
101
|
+
/**
|
|
102
|
+
* Destroy manager and cleanup
|
|
103
|
+
*/
|
|
104
|
+
destroy(): void;
|
|
105
|
+
/**
|
|
106
|
+
* Parse token response
|
|
107
|
+
*/
|
|
108
|
+
private parseTokenResponse;
|
|
109
|
+
/**
|
|
110
|
+
* Generate PKCE code verifier
|
|
111
|
+
*/
|
|
112
|
+
private generateCodeVerifier;
|
|
113
|
+
/**
|
|
114
|
+
* Generate PKCE code challenge (S256)
|
|
115
|
+
*/
|
|
116
|
+
private generateCodeChallenge;
|
|
117
|
+
/**
|
|
118
|
+
* Generate random string
|
|
119
|
+
*/
|
|
120
|
+
private generateRandomString;
|
|
121
|
+
/**
|
|
122
|
+
* Base64 URL encode
|
|
123
|
+
*/
|
|
124
|
+
private base64UrlEncode;
|
|
125
|
+
/**
|
|
126
|
+
* Start cleanup of expired pending requests
|
|
127
|
+
*/
|
|
128
|
+
private startCleanup;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Create OAuth manager
|
|
132
|
+
*/
|
|
133
|
+
export declare function createOAuthManager(logger: ILogger, config: OAuthConfig): OAuthManager;
|
|
134
|
+
/**
|
|
135
|
+
* OAuth middleware for Express/Connect
|
|
136
|
+
*/
|
|
137
|
+
export declare function oauthMiddleware(oauthManager: OAuthManager, storageKey?: string): (req: any, res: any, next: () => void) => Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Create GitHub OAuth provider config
|
|
140
|
+
*/
|
|
141
|
+
export declare function createGitHubOAuthConfig(clientId: string, clientSecret: string, redirectUri: string, scopes?: string[]): OAuthConfig;
|
|
142
|
+
/**
|
|
143
|
+
* Create Google OAuth provider config
|
|
144
|
+
*/
|
|
145
|
+
export declare function createGoogleOAuthConfig(clientId: string, clientSecret: string, redirectUri: string, scopes?: string[]): OAuthConfig;
|
|
146
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6BAA6B;IAC7B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,qBAAqB;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB;IACnB,WAAW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