@monoes/mcp 1.0.0

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 (70) hide show
  1. package/README.md +127 -0
  2. package/dist/connection-pool.d.ts +36 -0
  3. package/dist/connection-pool.d.ts.map +1 -0
  4. package/dist/connection-pool.js +273 -0
  5. package/dist/connection-pool.js.map +1 -0
  6. package/dist/index.d.ts +75 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +85 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/oauth.d.ts +146 -0
  11. package/dist/oauth.d.ts.map +1 -0
  12. package/dist/oauth.js +318 -0
  13. package/dist/oauth.js.map +1 -0
  14. package/dist/prompt-registry.d.ts +90 -0
  15. package/dist/prompt-registry.d.ts.map +1 -0
  16. package/dist/prompt-registry.js +209 -0
  17. package/dist/prompt-registry.js.map +1 -0
  18. package/dist/rate-limiter.d.ts +86 -0
  19. package/dist/rate-limiter.d.ts.map +1 -0
  20. package/dist/rate-limiter.js +197 -0
  21. package/dist/rate-limiter.js.map +1 -0
  22. package/dist/resource-registry.d.ts +144 -0
  23. package/dist/resource-registry.d.ts.map +1 -0
  24. package/dist/resource-registry.js +405 -0
  25. package/dist/resource-registry.js.map +1 -0
  26. package/dist/sampling.d.ts +102 -0
  27. package/dist/sampling.d.ts.map +1 -0
  28. package/dist/sampling.js +268 -0
  29. package/dist/sampling.js.map +1 -0
  30. package/dist/schema-validator.d.ts +30 -0
  31. package/dist/schema-validator.d.ts.map +1 -0
  32. package/dist/schema-validator.js +182 -0
  33. package/dist/schema-validator.js.map +1 -0
  34. package/dist/server.d.ts +122 -0
  35. package/dist/server.d.ts.map +1 -0
  36. package/dist/server.js +829 -0
  37. package/dist/server.js.map +1 -0
  38. package/dist/session-manager.d.ts +55 -0
  39. package/dist/session-manager.d.ts.map +1 -0
  40. package/dist/session-manager.js +252 -0
  41. package/dist/session-manager.js.map +1 -0
  42. package/dist/task-manager.d.ts +81 -0
  43. package/dist/task-manager.d.ts.map +1 -0
  44. package/dist/task-manager.js +337 -0
  45. package/dist/task-manager.js.map +1 -0
  46. package/dist/tool-registry.d.ts +88 -0
  47. package/dist/tool-registry.d.ts.map +1 -0
  48. package/dist/tool-registry.js +353 -0
  49. package/dist/tool-registry.js.map +1 -0
  50. package/dist/transport/http.d.ts +71 -0
  51. package/dist/transport/http.d.ts.map +1 -0
  52. package/dist/transport/http.js +567 -0
  53. package/dist/transport/http.js.map +1 -0
  54. package/dist/transport/index.d.ts +50 -0
  55. package/dist/transport/index.d.ts.map +1 -0
  56. package/dist/transport/index.js +181 -0
  57. package/dist/transport/index.js.map +1 -0
  58. package/dist/transport/stdio.d.ts +43 -0
  59. package/dist/transport/stdio.d.ts.map +1 -0
  60. package/dist/transport/stdio.js +194 -0
  61. package/dist/transport/stdio.js.map +1 -0
  62. package/dist/transport/websocket.d.ts +87 -0
  63. package/dist/transport/websocket.d.ts.map +1 -0
  64. package/dist/transport/websocket.js +408 -0
  65. package/dist/transport/websocket.js.map +1 -0
  66. package/dist/types.d.ts +473 -0
  67. package/dist/types.d.ts.map +1 -0
  68. package/dist/types.js +40 -0
  69. package/dist/types.js.map +1 -0
  70. package/package.json +45 -0
package/README.md ADDED
@@ -0,0 +1,127 @@
1
+ # @monoes/mcp
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@monoes/mcp.svg?style=flat-square)](https://www.npmjs.com/package/@monoes/mcp)
4
+ [![license](https://img.shields.io/npm/l/@monoes/mcp.svg?style=flat-square)](https://github.com/monoes/monomind/blob/main/LICENSE)
5
+ [![node](https://img.shields.io/badge/node-%3E%3D20-blue?style=flat-square)](https://nodejs.org)
6
+
7
+ **Standalone MCP server** — stdio, HTTP, and WebSocket transports with tool registry, resources, prompts, sessions, and connection pooling. Zero `@monomind/*` dependencies.
8
+
9
+ > Part of the [Monomind](https://github.com/monoes/monomind) ecosystem.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @monoes/mcp
15
+ ```
16
+
17
+ ## Quick start
18
+
19
+ ```typescript
20
+ import { quickStart, defineTool } from '@monoes/mcp';
21
+
22
+ const server = await quickStart({
23
+ transport: 'stdio',
24
+ name: 'My MCP Server',
25
+ });
26
+
27
+ server.registerTool(defineTool(
28
+ 'greet',
29
+ 'Greet a user',
30
+ { type: 'object', properties: { name: { type: 'string' } }, required: ['name'] },
31
+ async ({ name }) => ({ message: `Hello, ${name}!` })
32
+ ));
33
+
34
+ await server.start();
35
+ ```
36
+
37
+ ## Transports
38
+
39
+ ```typescript
40
+ import { createMCPServer } from '@monoes/mcp';
41
+
42
+ // stdio (default — for Claude Code integration)
43
+ const server = createMCPServer({ transport: 'stdio', name: 'My Server' }, logger);
44
+
45
+ // HTTP with auth
46
+ const server = createMCPServer({
47
+ transport: 'http',
48
+ host: 'localhost',
49
+ port: 3000,
50
+ corsEnabled: true,
51
+ auth: { enabled: true, method: 'token', tokens: ['secret'] },
52
+ }, logger);
53
+
54
+ // WebSocket
55
+ const server = createMCPServer({
56
+ transport: 'websocket',
57
+ host: 'localhost',
58
+ port: 3001,
59
+ maxConnections: 100,
60
+ }, logger);
61
+ ```
62
+
63
+ ## Tool registry
64
+
65
+ ```typescript
66
+ import { createToolRegistry, defineTool } from '@monoes/mcp';
67
+
68
+ const registry = createToolRegistry(logger);
69
+
70
+ registry.register({
71
+ name: 'calculate',
72
+ description: 'Perform calculations',
73
+ inputSchema: { type: 'object', properties: { expression: { type: 'string' } } },
74
+ handler: async ({ expression }) => ({ result: eval(expression) }),
75
+ });
76
+
77
+ const result = await registry.execute('calculate', { expression: '2 + 2' });
78
+ ```
79
+
80
+ ## Resources & prompts
81
+
82
+ ```typescript
83
+ import { createTextResource, definePrompt, textMessage } from '@monoes/mcp';
84
+
85
+ // Resources
86
+ const { resource, handler } = createTextResource('file://readme.txt', 'README', 'Hello!');
87
+ server.getResourceRegistry().registerResource(resource, handler);
88
+
89
+ // Prompts
90
+ const prompt = definePrompt('summarize', 'Summarize text', [
91
+ { name: 'text', description: 'Text to summarize', required: true }
92
+ ], (args) => ({ messages: [textMessage(`Summarize: ${args.text}`)] }));
93
+ server.getPromptRegistry().registerPrompt(prompt);
94
+ ```
95
+
96
+ ## Server API
97
+
98
+ ```typescript
99
+ interface IMCPServer {
100
+ start(): Promise<void>;
101
+ stop(): Promise<void>;
102
+ registerTool(tool: MCPTool): boolean;
103
+ registerTools(tools: MCPTool[]): { registered: number; failed: string[] };
104
+ getHealthStatus(): Promise<{ healthy: boolean; error?: string }>;
105
+ getMetrics(): MCPServerMetrics;
106
+ getSessions(): MCPSession[];
107
+ }
108
+ ```
109
+
110
+ ## Built-in tools
111
+
112
+ | Tool | Description |
113
+ |------|-------------|
114
+ | `system/info` | Server information |
115
+ | `system/health` | Health status |
116
+ | `system/metrics` | Server metrics |
117
+ | `tools/list-detailed` | List all tools with details |
118
+
119
+ ## Links
120
+
121
+ - [GitHub](https://github.com/monoes/monomind)
122
+ - [MCP Specification](https://modelcontextprotocol.io)
123
+ - [Issues](https://github.com/monoes/monomind/issues)
124
+
125
+ ## License
126
+
127
+ MIT
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @monoes/mcp - Connection Pool
3
+ *
4
+ * High-performance connection pooling
5
+ */
6
+ import { EventEmitter } from 'events';
7
+ import type { PooledConnection, ConnectionPoolStats, ConnectionPoolConfig, IConnectionPool, ILogger, TransportType } from './types.js';
8
+ export declare class ConnectionPool extends EventEmitter implements IConnectionPool {
9
+ private readonly logger;
10
+ private readonly transportType;
11
+ private readonly config;
12
+ private readonly connections;
13
+ private readonly waitingClients;
14
+ private evictionTimer?;
15
+ private connectionCounter;
16
+ private isShuttingDown;
17
+ private stats;
18
+ constructor(config: Partial<ConnectionPoolConfig> | undefined, logger: ILogger, transportType?: TransportType);
19
+ private initializeMinConnections;
20
+ private createConnection;
21
+ acquire(): Promise<PooledConnection>;
22
+ private waitForConnection;
23
+ release(connection: PooledConnection): void;
24
+ destroy(connection: PooledConnection): void;
25
+ getStats(): ConnectionPoolStats;
26
+ drain(): Promise<void>;
27
+ clear(): Promise<void>;
28
+ private startEvictionTimer;
29
+ private stopEvictionTimer;
30
+ private evictIdleConnections;
31
+ private recordAcquireTime;
32
+ getConnections(): PooledConnection[];
33
+ isHealthy(): boolean;
34
+ }
35
+ export declare function createConnectionPool(config: Partial<ConnectionPoolConfig> | undefined, logger: ILogger, transportType?: TransportType): ConnectionPool;
36
+ //# sourceMappingURL=connection-pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-pool.d.ts","sourceRoot":"","sources":["../src/connection-pool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EAEpB,eAAe,EACf,OAAO,EACP,aAAa,EACd,MAAM,YAAY,CAAC;AAoDpB,qBAAa,cAAe,SAAQ,YAAa,YAAW,eAAe;IAmBvE,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAnBhC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuB;IAC9C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6C;IACzE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAuB;IACtD,OAAO,CAAC,aAAa,CAAC,CAAiB;IACvC,OAAO,CAAC,iBAAiB,CAAa;IACtC,OAAO,CAAC,cAAc,CAAkB;IAExC,OAAO,CAAC,KAAK,CAOX;IAEF,YACE,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,YAAK,EACzB,MAAM,EAAE,OAAO,EACf,aAAa,GAAE,aAA4B,EAM7D;YAEa,wBAAwB;YAWxB,gBAAgB;IAaxB,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC,CA+BzC;IAED,OAAO,CAAC,iBAAiB;IA4BzB,OAAO,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAqB1C;IAED,OAAO,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAkB1C;IAED,QAAQ,IAAI,mBAAmB,CAsB9B;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAwB3B;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAU3B;IAED,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,oBAAoB;IAwB5B,OAAO,CAAC,iBAAiB;IAMzB,cAAc,IAAI,gBAAgB,EAAE,CAEnC;IAED,SAAS,IAAI,OAAO,CAEnB;CACF;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,YAAK,EAC1C,MAAM,EAAE,OAAO,EACf,aAAa,GAAE,aAA4B,GAC1C,cAAc,CAEhB"}
@@ -0,0 +1,273 @@
1
+ /**
2
+ * @monoes/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":["../src/connection-pool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAWtC,MAAM,mBAAmB,GAAyB;IAChD,cAAc,EAAE,EAAE;IAClB,cAAc,EAAE,CAAC;IACjB,WAAW,EAAE,KAAK;IAClB,cAAc,EAAE,IAAI;IACpB,iBAAiB,EAAE,EAAE;IACrB,mBAAmB,EAAE,KAAK;CAC3B,CAAC;AAEF,MAAM,iBAAiB;IAMH,EAAE;IACF,SAAS;IACT,SAAS;IAClB,QAAQ;IARV,KAAK,GAAoB,MAAM,CAAC;IAChC,UAAU,CAAO;IACjB,QAAQ,GAAW,CAAC,CAAC;IAE5B,YACkB,EAAU,EACV,SAAwB,EACxB,SAAS,GAAS,IAAI,IAAI,EAAE,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CAAC;IAEO,iBAAiB,CAAC,SAAiB;QACzC,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QAC/C,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,QAAQ,CAAC;QACxC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;IAC5B,CAAC;IAED,cAAc;QACZ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,SAAS;QACP,OAAO,CAAC,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;IACrF,CAAC;CACF;AAED,MAAM,UAAU,oBAAoB,CAClC,MAAM,GAAkC,EAAE,EAC1C,MAAe,EACf,aAAa,GAAkB,YAAY;IAE3C,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * @monoes/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 @monoes/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 } 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 '@monoes/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 = "@monoes/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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AAC;AACpB,YAAY,EACV,WAAW,EACX,WAAW,EACX,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,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @monoes/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 @monoes/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 '@monoes/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 = '@monoes/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,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAElF,kBAAkB;AAClB,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,CAAC;AAGhD,kBAAkB;AAClB,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5E,qCAAqC;AACrC,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAGhC,mCAAmC;AACnC,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,WAAW,EACX,eAAe,EACf,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAG9B,gCAAgC;AAChC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGnE,mBAAmB;AACnB,OAAO,EACL,cAAc,EACd,sBAAsB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