@ananay-nag/mcp-decorators 1.0.0 → 2.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.
- package/README.md +77 -8
- package/dist/cjs/index.js +2 -35
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/src/client/decorators/client.decorator.js +29 -37
- package/dist/cjs/src/client/decorators/client.decorator.js.map +1 -1
- package/dist/cjs/src/client/decorators/index.js +3 -22
- package/dist/cjs/src/client/decorators/index.js.map +1 -1
- package/dist/cjs/src/client/decorators/notification.decorator.js +5 -9
- package/dist/cjs/src/client/decorators/notification.decorator.js.map +1 -1
- package/dist/cjs/src/client/decorators/requestHandler.decorator.js +1 -5
- package/dist/cjs/src/client/decorators/requestHandler.decorator.js.map +1 -1
- package/dist/cjs/src/client/index.js +3 -19
- package/dist/cjs/src/client/index.js.map +1 -1
- package/dist/cjs/src/client/types/client/client.js +1 -2
- package/dist/cjs/src/client/types/index.js +2 -18
- package/dist/cjs/src/client/types/index.js.map +1 -1
- package/dist/cjs/src/client/utils/clientRegistry.js +2 -7
- package/dist/cjs/src/client/utils/clientRegistry.js.map +1 -1
- package/dist/cjs/src/client/utils/index.js +1 -17
- package/dist/cjs/src/client/utils/index.js.map +1 -1
- package/dist/cjs/src/server/decorators/action.decorator.js +1 -5
- package/dist/cjs/src/server/decorators/action.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/completion.decorator.js +5 -9
- package/dist/cjs/src/server/decorators/completion.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/index.js +9 -24
- package/dist/cjs/src/server/decorators/index.js.map +1 -1
- package/dist/cjs/src/server/decorators/notification.decorator.js +5 -9
- package/dist/cjs/src/server/decorators/notification.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/prompt.decorator.js +5 -9
- package/dist/cjs/src/server/decorators/prompt.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/requestHandler.decorator.js +1 -5
- package/dist/cjs/src/server/decorators/requestHandler.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/resource.decorator.js +10 -15
- package/dist/cjs/src/server/decorators/resource.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/server.decorator.d.ts.map +1 -1
- package/dist/cjs/src/server/decorators/server.decorator.js +48 -57
- package/dist/cjs/src/server/decorators/server.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/subscribe.decorator.js +6 -11
- package/dist/cjs/src/server/decorators/subscribe.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/tool.decorator.js +5 -9
- package/dist/cjs/src/server/decorators/tool.decorator.js.map +1 -1
- package/dist/cjs/src/server/index.js +3 -32
- package/dist/cjs/src/server/index.js.map +1 -1
- package/dist/cjs/src/server/types/index.js +2 -18
- package/dist/cjs/src/server/types/index.js.map +1 -1
- package/dist/cjs/src/server/types/server/index.js +1 -17
- package/dist/cjs/src/server/types/server/index.js.map +1 -1
- package/dist/cjs/src/server/types/server/server.js +1 -2
- package/dist/cjs/src/server/utils/index.js +1 -17
- package/dist/cjs/src/server/utils/index.js.map +1 -1
- package/dist/cjs/src/server/utils/serverRegistry.js +10 -21
- package/dist/cjs/src/server/utils/serverRegistry.js.map +1 -1
- package/dist/esm/src/client/decorators/client.decorator.js.map +1 -1
- package/dist/esm/src/client/decorators/notification.decorator.js.map +1 -1
- package/dist/esm/src/client/decorators/requestHandler.decorator.js.map +1 -1
- package/dist/esm/src/client/utils/clientRegistry.js.map +1 -1
- package/dist/esm/src/server/decorators/action.decorator.js.map +1 -1
- package/dist/esm/src/server/decorators/completion.decorator.js.map +1 -1
- package/dist/esm/src/server/decorators/notification.decorator.js.map +1 -1
- package/dist/esm/src/server/decorators/prompt.decorator.js.map +1 -1
- package/dist/esm/src/server/decorators/requestHandler.decorator.js.map +1 -1
- package/dist/esm/src/server/decorators/resource.decorator.js.map +1 -1
- package/dist/esm/src/server/decorators/server.decorator.d.ts.map +1 -1
- package/dist/esm/src/server/decorators/server.decorator.js +0 -2
- package/dist/esm/src/server/decorators/server.decorator.js.map +1 -1
- package/dist/esm/src/server/decorators/tool.decorator.js.map +1 -1
- package/dist/esm/src/server/utils/serverRegistry.js.map +1 -1
- package/package.json +29 -7
package/README.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@ananay-nag/mcp-decorators">
|
|
7
|
+
<img src="https://img.shields.io/npm/v/@ananay-nag/mcp-decorators.svg?color=cb3837&style=flat-square" alt="npm version" />
|
|
8
|
+
</a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/@ananay-nag/mcp-decorators">
|
|
10
|
+
<img src="https://img.shields.io/node/v/@ananay-nag/mcp-decorators.svg?color=339933&style=flat-square" alt="node compatibility" />
|
|
11
|
+
</a>
|
|
12
|
+
<a href="https://github.com/ananay-nag/mcp-decorators/actions/workflows/test.yml">
|
|
13
|
+
<img src="https://img.shields.io/github/actions/workflow/status/ananay-nag/mcp-decorators/test.yml.svg?style=flat-square" alt="build status" />
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://github.com/ananay-nag/mcp-decorators/issues">
|
|
16
|
+
<img src="https://img.shields.io/github/issues/ananay-nag/mcp-decorators.svg?color=2ea44f&style=flat-square" alt="github issues" />
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://github.com/ananay-nag/mcp-decorators/blob/main/LICENSE">
|
|
19
|
+
<img src="https://img.shields.io/github/license/ananay-nag/mcp-decorators.svg?color=6f42c1&style=flat-square" alt="license" />
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://mcp-decorators-doc.vercel.app/">
|
|
22
|
+
<img src="https://img.shields.io/badge/Documentation-mcp--decorators-0969da.svg?style=flat-square" alt="Documentation" />
|
|
23
|
+
</a>
|
|
24
|
+
</p>
|
|
25
|
+
|
|
5
26
|
A powerful, TypeScript-native decorator library to simplify and supercharge your Model Context Protocol (MCP) server and client development.
|
|
6
27
|
|
|
7
28
|
`@ananay-nag/mcp-decorators` enables clean, declarative class-based structures, completely removing repetitive boilerplate for request handling, client calls, resource serving, notifications, autocompletions, and capabilities registration.
|
|
@@ -23,7 +44,8 @@ A powerful, TypeScript-native decorator library to simplify and supercharge your
|
|
|
23
44
|
- [Client Request/Notification Handlers](#client-requestnotification-handlers)
|
|
24
45
|
5. [Full Client Example](#full-client-example)
|
|
25
46
|
6. [Utilities](#utilities)
|
|
26
|
-
7. [
|
|
47
|
+
7. [Testing](#testing)
|
|
48
|
+
8. [Under the Hood & Advantages](#under-the-hood--advantages)
|
|
27
49
|
|
|
28
50
|
---
|
|
29
51
|
|
|
@@ -77,7 +99,7 @@ export class MyMCPServer extends Server {
|
|
|
77
99
|
```typescript
|
|
78
100
|
import { UseServer } from "@ananay-nag/mcp-decorators";
|
|
79
101
|
|
|
80
|
-
@UseServer({ name: "my-mcp-server", version: "
|
|
102
|
+
@UseServer({ name: "my-mcp-server", version: "2.0.0" })
|
|
81
103
|
export class DbHandlers {
|
|
82
104
|
server: any; // Injected server instance
|
|
83
105
|
}
|
|
@@ -261,7 +283,7 @@ export class MyMCPServer extends Server {
|
|
|
261
283
|
import { UseServer, Tool, Resource, ResourceTemplate } from "@ananay-nag/mcp-decorators";
|
|
262
284
|
import { z } from "zod";
|
|
263
285
|
|
|
264
|
-
@UseServer({ name: "my-database-mcp", version: "
|
|
286
|
+
@UseServer({ name: "my-database-mcp", version: "2.0.0" })
|
|
265
287
|
export class DbHandlers {
|
|
266
288
|
server: any; // Injected instance
|
|
267
289
|
|
|
@@ -310,7 +332,7 @@ import { DbHandlers } from "./dbHandlers.js";
|
|
|
310
332
|
async function main() {
|
|
311
333
|
// 1. Create registered server instance
|
|
312
334
|
const server = new MyMCPServer(
|
|
313
|
-
{ name: "my-database-mcp", version: "
|
|
335
|
+
{ name: "my-database-mcp", version: "2.0.0" },
|
|
314
336
|
{ capabilities: {} }
|
|
315
337
|
);
|
|
316
338
|
|
|
@@ -425,7 +447,7 @@ export class MyMCPClient extends Client {}
|
|
|
425
447
|
```typescript
|
|
426
448
|
import { UseClient, CallTool, ListTools, ReadResource, NotificationHandler } from "@ananay-nag/mcp-decorators";
|
|
427
449
|
|
|
428
|
-
@UseClient({ name: "my-mcp-client", version: "
|
|
450
|
+
@UseClient({ name: "my-mcp-client", version: "2.0.0" })
|
|
429
451
|
export class ClientController {
|
|
430
452
|
client: any; // Injected instance
|
|
431
453
|
|
|
@@ -459,7 +481,7 @@ import { ClientController } from "./service.js";
|
|
|
459
481
|
|
|
460
482
|
async function runClient() {
|
|
461
483
|
const client = new MyMCPClient(
|
|
462
|
-
{ name: "my-mcp-client", version: "
|
|
484
|
+
{ name: "my-mcp-client", version: "2.0.0" },
|
|
463
485
|
{ capabilities: {} }
|
|
464
486
|
);
|
|
465
487
|
|
|
@@ -539,7 +561,7 @@ Fetch a registered server instance programmatically.
|
|
|
539
561
|
```typescript
|
|
540
562
|
import { getServer } from "@ananay-nag/mcp-decorators";
|
|
541
563
|
|
|
542
|
-
const server = getServer({ name: "my-database-mcp", version: "
|
|
564
|
+
const server = getServer({ name: "my-database-mcp", version: "2.0.0" });
|
|
543
565
|
```
|
|
544
566
|
|
|
545
567
|
#### 6. `getClient(options)`
|
|
@@ -547,11 +569,58 @@ Fetch a registered client instance programmatically.
|
|
|
547
569
|
```typescript
|
|
548
570
|
import { getClient } from "@ananay-nag/mcp-decorators";
|
|
549
571
|
|
|
550
|
-
const client = getClient({ name: "my-mcp-client", version: "
|
|
572
|
+
const client = getClient({ name: "my-mcp-client", version: "2.0.0" });
|
|
551
573
|
```
|
|
552
574
|
|
|
553
575
|
---
|
|
554
576
|
|
|
577
|
+
## Testing
|
|
578
|
+
|
|
579
|
+
This library uses **Jest** and **ts-jest** for clean, isolated decorator verification.
|
|
580
|
+
|
|
581
|
+
### Running the Test Suite
|
|
582
|
+
|
|
583
|
+
```bash
|
|
584
|
+
# Run all test cases
|
|
585
|
+
npm run test
|
|
586
|
+
|
|
587
|
+
# Run tests with coverage reporting (excludes uncovered line numbers column)
|
|
588
|
+
npm run test:coverage
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
### Test Coverage Summary
|
|
592
|
+
|
|
593
|
+
<details>
|
|
594
|
+
<summary>📊 Click to view full coverage report</summary>
|
|
595
|
+
|
|
596
|
+
<!-- START_COVERAGE -->
|
|
597
|
+
| File | % Stmts | % Branch | % Funcs | % Lines |
|
|
598
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
599
|
+
| All files | 70.12 | 52.12 | 61.36 | 70.47 |
|
|
600
|
+
| client/decorators | 77.08 | 52.17 | 68 | 77.65 |
|
|
601
|
+
| client.decorator.ts | 74.71 | 52.38 | 61.9 | 75.29 |
|
|
602
|
+
| notification.decorator.ts | 100 | 50 | 100 | 100 |
|
|
603
|
+
| requestHandler.decorator.ts | 100 | 50 | 100 | 100 |
|
|
604
|
+
| client/utils | 70 | 62.5 | 75 | 68.42 |
|
|
605
|
+
| clientRegistry.ts | 70 | 62.5 | 75 | 68.42 |
|
|
606
|
+
| server/decorators | 72.8 | 53.15 | 62.5 | 73.25 |
|
|
607
|
+
| action.decorator.ts | 100 | 100 | 100 | 100 |
|
|
608
|
+
| completion.decorator.ts | 100 | 50 | 100 | 100 |
|
|
609
|
+
| notification.decorator.ts | 100 | 50 | 100 | 100 |
|
|
610
|
+
| prompt.decorator.ts | 100 | 50 | 100 | 100 |
|
|
611
|
+
| requestHandler.decorator.ts | 100 | 100 | 100 | 100 |
|
|
612
|
+
| resource.decorator.ts | 100 | 50 | 100 | 100 |
|
|
613
|
+
| server.decorator.ts | 66.99 | 52.29 | 35.71 | 67.33 |
|
|
614
|
+
| subscribe.decorator.ts | 100 | 100 | 100 | 100 |
|
|
615
|
+
| tool.decorator.ts | 100 | 50 | 100 | 100 |
|
|
616
|
+
| server/utils | 42.85 | 40 | 36.36 | 42.55 |
|
|
617
|
+
| serverRegistry.ts | 42.85 | 40 | 36.36 | 42.55 |
|
|
618
|
+
<!-- END_COVERAGE -->
|
|
619
|
+
|
|
620
|
+
</details>
|
|
621
|
+
|
|
622
|
+
---
|
|
623
|
+
|
|
555
624
|
## Under the Hood & Advantages
|
|
556
625
|
|
|
557
626
|
* **No Overhead Handler Overwrites**: In the standard MCP SDK, setting a request handler replaces the previous registration. `mcp-decorators` aggregates all class-level decorators (e.g. tools, prompts, resources, completions) and maps them internally inside single dispatchers. This allows you to split logic across multiple handler classes safely without breaking capabilities.
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,36 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.registerClient = exports.getClient = exports.PingServer = exports.SetLoggingLevel = exports.CompletePromptOrResource = exports.UnsubscribeResource = exports.SubscribeResource = exports.ListResourceTemplates = exports.ListResources = exports.ReadResource = exports.ListPrompts = exports.GetPrompt = exports.ListTools = exports.CallTool = exports.UseClient = exports.RegisterClient = void 0;
|
|
18
|
-
__exportStar(require("./src/server/index.js"), exports);
|
|
19
|
-
var index_js_1 = require("./src/client/index.js");
|
|
20
|
-
Object.defineProperty(exports, "RegisterClient", { enumerable: true, get: function () { return index_js_1.RegisterClient; } });
|
|
21
|
-
Object.defineProperty(exports, "UseClient", { enumerable: true, get: function () { return index_js_1.UseClient; } });
|
|
22
|
-
Object.defineProperty(exports, "CallTool", { enumerable: true, get: function () { return index_js_1.CallTool; } });
|
|
23
|
-
Object.defineProperty(exports, "ListTools", { enumerable: true, get: function () { return index_js_1.ListTools; } });
|
|
24
|
-
Object.defineProperty(exports, "GetPrompt", { enumerable: true, get: function () { return index_js_1.GetPrompt; } });
|
|
25
|
-
Object.defineProperty(exports, "ListPrompts", { enumerable: true, get: function () { return index_js_1.ListPrompts; } });
|
|
26
|
-
Object.defineProperty(exports, "ReadResource", { enumerable: true, get: function () { return index_js_1.ReadResource; } });
|
|
27
|
-
Object.defineProperty(exports, "ListResources", { enumerable: true, get: function () { return index_js_1.ListResources; } });
|
|
28
|
-
Object.defineProperty(exports, "ListResourceTemplates", { enumerable: true, get: function () { return index_js_1.ListResourceTemplates; } });
|
|
29
|
-
Object.defineProperty(exports, "SubscribeResource", { enumerable: true, get: function () { return index_js_1.SubscribeResource; } });
|
|
30
|
-
Object.defineProperty(exports, "UnsubscribeResource", { enumerable: true, get: function () { return index_js_1.UnsubscribeResource; } });
|
|
31
|
-
Object.defineProperty(exports, "CompletePromptOrResource", { enumerable: true, get: function () { return index_js_1.CompletePromptOrResource; } });
|
|
32
|
-
Object.defineProperty(exports, "SetLoggingLevel", { enumerable: true, get: function () { return index_js_1.SetLoggingLevel; } });
|
|
33
|
-
Object.defineProperty(exports, "PingServer", { enumerable: true, get: function () { return index_js_1.PingServer; } });
|
|
34
|
-
Object.defineProperty(exports, "getClient", { enumerable: true, get: function () { return index_js_1.getClient; } });
|
|
35
|
-
Object.defineProperty(exports, "registerClient", { enumerable: true, get: function () { return index_js_1.registerClient; } });
|
|
1
|
+
export * from "./src/server/index.js";
|
|
2
|
+
export { RegisterClient, UseClient, CallTool, ListTools, GetPrompt, ListPrompts, ReadResource, ListResources, ListResourceTemplates, SubscribeResource, UnsubscribeResource, CompletePromptOrResource, SetLoggingLevel, PingServer, getClient, registerClient } from "./src/client/index.js";
|
|
36
3
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,UAAU,EACV,SAAS,EACT,cAAc,EACf,MAAM,uBAAuB,CAAC"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
const notification_decorator_js_1 = require("./notification.decorator.js");
|
|
7
|
-
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
1
|
+
import { getClient, registerClient } from "../utils/clientRegistry.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { NOTIFICATION_META } from "./notification.decorator.js";
|
|
4
|
+
import { CallToolResultSchema, ListToolsResultSchema, GetPromptResultSchema, ListPromptsResultSchema, ReadResourceResultSchema, ListResourcesResultSchema, ListResourceTemplatesResultSchema, CompleteResultSchema, EmptyResultSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
8
5
|
/**
|
|
9
6
|
* Class decorator to auto-register an MCP Client instance.
|
|
10
7
|
*/
|
|
11
|
-
function RegisterClient() {
|
|
8
|
+
export function RegisterClient() {
|
|
12
9
|
return function (target) {
|
|
13
10
|
const originalConstructor = target;
|
|
14
11
|
const newConstructor = function (...args) {
|
|
@@ -17,7 +14,7 @@ function RegisterClient() {
|
|
|
17
14
|
console.log(`[Client] Registering client "${JSON.stringify(clientInfo)}"`);
|
|
18
15
|
// Relaxed check to support both SDK v1 Client and SDK v2 Client
|
|
19
16
|
if (instance && (typeof instance.connect === "function")) {
|
|
20
|
-
|
|
17
|
+
registerClient(clientInfo, instance);
|
|
21
18
|
}
|
|
22
19
|
return instance;
|
|
23
20
|
};
|
|
@@ -25,49 +22,46 @@ function RegisterClient() {
|
|
|
25
22
|
return newConstructor;
|
|
26
23
|
};
|
|
27
24
|
}
|
|
28
|
-
exports.RegisterClient = RegisterClient;
|
|
29
25
|
/**
|
|
30
26
|
* Register low-level request handlers on the client instance.
|
|
31
27
|
*/
|
|
32
|
-
function registerRequestHandlers(target, instance, client) {
|
|
28
|
+
export function registerRequestHandlers(target, instance, client) {
|
|
33
29
|
const pendingHandlers = target.prototype._pendingHandlers || [];
|
|
34
30
|
for (const { schema, methodName } of pendingHandlers) {
|
|
35
31
|
const handlerFn = instance[methodName].bind(instance);
|
|
36
32
|
let normalizedSchema = schema;
|
|
37
33
|
if (typeof schema === "string") {
|
|
38
|
-
normalizedSchema =
|
|
39
|
-
method:
|
|
40
|
-
params:
|
|
34
|
+
normalizedSchema = z.object({
|
|
35
|
+
method: z.literal(schema),
|
|
36
|
+
params: z.any().optional(),
|
|
41
37
|
});
|
|
42
38
|
}
|
|
43
39
|
client.setRequestHandler(normalizedSchema, handlerFn);
|
|
44
40
|
console.log(`[Client] ✅ Registered request handler "${typeof schema === "string" ? schema : schema.shape.method.value}" -> ${String(methodName)}`);
|
|
45
41
|
}
|
|
46
42
|
}
|
|
47
|
-
exports.registerRequestHandlers = registerRequestHandlers;
|
|
48
43
|
/**
|
|
49
44
|
* Register low-level notification handlers on the client instance.
|
|
50
45
|
*/
|
|
51
|
-
function registerNotificationHandlers(target, instance, client) {
|
|
52
|
-
const pendingNotifications = target.prototype[
|
|
46
|
+
export function registerNotificationHandlers(target, instance, client) {
|
|
47
|
+
const pendingNotifications = target.prototype[NOTIFICATION_META] || [];
|
|
53
48
|
for (const { method, methodName } of pendingNotifications) {
|
|
54
49
|
const handlerFn = instance[methodName].bind(instance);
|
|
55
50
|
let normalizedSchema = method;
|
|
56
51
|
if (typeof method === "string") {
|
|
57
|
-
normalizedSchema =
|
|
58
|
-
method:
|
|
59
|
-
params:
|
|
52
|
+
normalizedSchema = z.object({
|
|
53
|
+
method: z.literal(method),
|
|
54
|
+
params: z.any().optional(),
|
|
60
55
|
});
|
|
61
56
|
}
|
|
62
57
|
client.setNotificationHandler(normalizedSchema, handlerFn);
|
|
63
58
|
console.log(`[Client] ✅ Registered notification handler "${typeof method === "string" ? method : method.shape.method.value}" -> ${String(methodName)}`);
|
|
64
59
|
}
|
|
65
60
|
}
|
|
66
|
-
exports.registerNotificationHandlers = registerNotificationHandlers;
|
|
67
61
|
/**
|
|
68
62
|
* Class decorator to inject a registered client instance and bind decorators.
|
|
69
63
|
*/
|
|
70
|
-
function UseClient(options) {
|
|
64
|
+
export function UseClient(options) {
|
|
71
65
|
return function (target) {
|
|
72
66
|
const originalConstructor = target;
|
|
73
67
|
function newConstructor(...args) {
|
|
@@ -75,7 +69,7 @@ function UseClient(options) {
|
|
|
75
69
|
if (!options.name) {
|
|
76
70
|
throw new Error("Client name is required in @UseClient options.");
|
|
77
71
|
}
|
|
78
|
-
const client =
|
|
72
|
+
const client = getClient(options);
|
|
79
73
|
if (!client) {
|
|
80
74
|
throw new Error(`Client with name "${options.name}" not found.`);
|
|
81
75
|
}
|
|
@@ -88,7 +82,6 @@ function UseClient(options) {
|
|
|
88
82
|
return newConstructor;
|
|
89
83
|
};
|
|
90
84
|
}
|
|
91
|
-
exports.UseClient = UseClient;
|
|
92
85
|
/**
|
|
93
86
|
* Helper to build client request decorators.
|
|
94
87
|
*/
|
|
@@ -121,29 +114,29 @@ function makeRequestDecorator(method, resultSchema, getParams) {
|
|
|
121
114
|
/**
|
|
122
115
|
* Decorator to call a tool on the server.
|
|
123
116
|
*/
|
|
124
|
-
|
|
117
|
+
export const CallTool = makeRequestDecorator("tools/call", CallToolResultSchema, (args, name) => ({
|
|
125
118
|
name,
|
|
126
119
|
arguments: args
|
|
127
120
|
}));
|
|
128
121
|
/**
|
|
129
122
|
* Decorator to list available tools on the server.
|
|
130
123
|
*/
|
|
131
|
-
|
|
124
|
+
export const ListTools = makeRequestDecorator("tools/list", ListToolsResultSchema);
|
|
132
125
|
/**
|
|
133
126
|
* Decorator to get a prompt from the server.
|
|
134
127
|
*/
|
|
135
|
-
|
|
128
|
+
export const GetPrompt = makeRequestDecorator("prompts/get", GetPromptResultSchema, (args, name) => ({
|
|
136
129
|
name,
|
|
137
130
|
arguments: args
|
|
138
131
|
}));
|
|
139
132
|
/**
|
|
140
133
|
* Decorator to list available prompts on the server.
|
|
141
134
|
*/
|
|
142
|
-
|
|
135
|
+
export const ListPrompts = makeRequestDecorator("prompts/list", ListPromptsResultSchema);
|
|
143
136
|
/**
|
|
144
137
|
* Decorator to read a resource from the server.
|
|
145
138
|
*/
|
|
146
|
-
|
|
139
|
+
export const ReadResource = makeRequestDecorator("resources/read", ReadResourceResultSchema, (args) => {
|
|
147
140
|
if (typeof args === "string") {
|
|
148
141
|
return { uri: args };
|
|
149
142
|
}
|
|
@@ -152,15 +145,15 @@ exports.ReadResource = makeRequestDecorator("resources/read", types_js_1.ReadRes
|
|
|
152
145
|
/**
|
|
153
146
|
* Decorator to list available resources on the server.
|
|
154
147
|
*/
|
|
155
|
-
|
|
148
|
+
export const ListResources = makeRequestDecorator("resources/list", ListResourcesResultSchema);
|
|
156
149
|
/**
|
|
157
150
|
* Decorator to list available resource templates on the server.
|
|
158
151
|
*/
|
|
159
|
-
|
|
152
|
+
export const ListResourceTemplates = makeRequestDecorator("resources/templates/list", ListResourceTemplatesResultSchema);
|
|
160
153
|
/**
|
|
161
154
|
* Decorator to subscribe to resource updates on the server.
|
|
162
155
|
*/
|
|
163
|
-
|
|
156
|
+
export const SubscribeResource = makeRequestDecorator("resources/subscribe", EmptyResultSchema, (args) => {
|
|
164
157
|
if (typeof args === "string") {
|
|
165
158
|
return { uri: args };
|
|
166
159
|
}
|
|
@@ -169,7 +162,7 @@ exports.SubscribeResource = makeRequestDecorator("resources/subscribe", types_js
|
|
|
169
162
|
/**
|
|
170
163
|
* Decorator to unsubscribe from resource updates on the server.
|
|
171
164
|
*/
|
|
172
|
-
|
|
165
|
+
export const UnsubscribeResource = makeRequestDecorator("resources/unsubscribe", EmptyResultSchema, (args) => {
|
|
173
166
|
if (typeof args === "string") {
|
|
174
167
|
return { uri: args };
|
|
175
168
|
}
|
|
@@ -178,11 +171,11 @@ exports.UnsubscribeResource = makeRequestDecorator("resources/unsubscribe", type
|
|
|
178
171
|
/**
|
|
179
172
|
* Decorator to complete a prompt/resource template argument on the server.
|
|
180
173
|
*/
|
|
181
|
-
|
|
174
|
+
export const CompletePromptOrResource = makeRequestDecorator("completion/complete", CompleteResultSchema);
|
|
182
175
|
/**
|
|
183
176
|
* Decorator to set the server logging level.
|
|
184
177
|
*/
|
|
185
|
-
|
|
178
|
+
export const SetLoggingLevel = makeRequestDecorator("logging/setLevel", EmptyResultSchema, (args) => {
|
|
186
179
|
if (typeof args === "string") {
|
|
187
180
|
return { level: args };
|
|
188
181
|
}
|
|
@@ -191,7 +184,7 @@ exports.SetLoggingLevel = makeRequestDecorator("logging/setLevel", types_js_1.Em
|
|
|
191
184
|
/**
|
|
192
185
|
* Decorator to ping the server.
|
|
193
186
|
*/
|
|
194
|
-
function PingServer() {
|
|
187
|
+
export function PingServer() {
|
|
195
188
|
return function (target, propertyKey, descriptor) {
|
|
196
189
|
descriptor.value = async function (options) {
|
|
197
190
|
if (!this.client) {
|
|
@@ -202,5 +195,4 @@ function PingServer() {
|
|
|
202
195
|
return descriptor;
|
|
203
196
|
};
|
|
204
197
|
}
|
|
205
|
-
exports.PingServer = PingServer;
|
|
206
198
|
//# sourceMappingURL=client.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.decorator.js","sourceRoot":"","sources":["../../../../../src/client/decorators/client.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.decorator.js","sourceRoot":"","sources":["../../../../../src/client/decorators/client.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,iCAAiC,EACjC,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,oCAAoC,CAAC;AAE5C;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,UAAU,MAAW;QAC1B,MAAM,mBAAmB,GAAG,MAAM,CAAC;QAEnC,MAAM,cAAc,GAAQ,UAAU,GAAG,IAAW;YAClD,IAAI,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACzB,MAAM,QAAQ,GAAG,IAAI,mBAAmB,CAAC,GAAG,IAAI,CAAC,CAAC;YAClD,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAE3E,gEAAgE;YAChE,IAAI,QAAQ,IAAI,CAAC,OAAQ,QAAgB,CAAC,OAAO,KAAK,UAAU,CAAC,EAAE,CAAC;gBAClE,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YACvC,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAC;QAEF,cAAc,CAAC,SAAS,GAAG,mBAAmB,CAAC,SAAS,CAAC;QACzD,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAW,EAAE,QAAa,EAAE,MAAW;IAC7E,MAAM,eAAe,GAAG,MAAM,CA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mB,GAAG,oBAAoB,CAAC,uBAAuB,EAAE,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE;IAC3G,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;IACvB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,oBAAoB,CAAC,qBAAqB,EAAE,oBAAoB,CAAC,CAAC;AAE1G;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,oBAAoB,CAAC,kBAAkB,EAAE,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE;IAClG,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACzB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,MAAW,EAAE,WAA4B,EAAE,UAA8B;QACxF,UAAU,CAAC,KAAK,GAAG,KAAK,WAAsB,OAAa;YACzD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;YACjG,CAAC;YACD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var requestHandler_decorator_js_1 = require("../../server/decorators/requestHandler.decorator.js");
|
|
5
|
-
Object.defineProperty(exports, "RequestHandler", { enumerable: true, get: function () { return requestHandler_decorator_js_1.RequestHandler; } });
|
|
6
|
-
var notification_decorator_js_1 = require("../../server/decorators/notification.decorator.js");
|
|
7
|
-
Object.defineProperty(exports, "NotificationHandler", { enumerable: true, get: function () { return notification_decorator_js_1.NotificationHandler; } });
|
|
8
|
-
var client_decorator_js_1 = require("./client.decorator.js");
|
|
9
|
-
Object.defineProperty(exports, "RegisterClient", { enumerable: true, get: function () { return client_decorator_js_1.RegisterClient; } });
|
|
10
|
-
Object.defineProperty(exports, "UseClient", { enumerable: true, get: function () { return client_decorator_js_1.UseClient; } });
|
|
11
|
-
Object.defineProperty(exports, "CallTool", { enumerable: true, get: function () { return client_decorator_js_1.CallTool; } });
|
|
12
|
-
Object.defineProperty(exports, "ListTools", { enumerable: true, get: function () { return client_decorator_js_1.ListTools; } });
|
|
13
|
-
Object.defineProperty(exports, "GetPrompt", { enumerable: true, get: function () { return client_decorator_js_1.GetPrompt; } });
|
|
14
|
-
Object.defineProperty(exports, "ListPrompts", { enumerable: true, get: function () { return client_decorator_js_1.ListPrompts; } });
|
|
15
|
-
Object.defineProperty(exports, "ReadResource", { enumerable: true, get: function () { return client_decorator_js_1.ReadResource; } });
|
|
16
|
-
Object.defineProperty(exports, "ListResources", { enumerable: true, get: function () { return client_decorator_js_1.ListResources; } });
|
|
17
|
-
Object.defineProperty(exports, "ListResourceTemplates", { enumerable: true, get: function () { return client_decorator_js_1.ListResourceTemplates; } });
|
|
18
|
-
Object.defineProperty(exports, "SubscribeResource", { enumerable: true, get: function () { return client_decorator_js_1.SubscribeResource; } });
|
|
19
|
-
Object.defineProperty(exports, "UnsubscribeResource", { enumerable: true, get: function () { return client_decorator_js_1.UnsubscribeResource; } });
|
|
20
|
-
Object.defineProperty(exports, "CompletePromptOrResource", { enumerable: true, get: function () { return client_decorator_js_1.CompletePromptOrResource; } });
|
|
21
|
-
Object.defineProperty(exports, "SetLoggingLevel", { enumerable: true, get: function () { return client_decorator_js_1.SetLoggingLevel; } });
|
|
22
|
-
Object.defineProperty(exports, "PingServer", { enumerable: true, get: function () { return client_decorator_js_1.PingServer; } });
|
|
1
|
+
export { RequestHandler } from "../../server/decorators/requestHandler.decorator.js";
|
|
2
|
+
export { NotificationHandler } from "../../server/decorators/notification.decorator.js";
|
|
3
|
+
export { RegisterClient, UseClient, CallTool, ListTools, GetPrompt, ListPrompts, ReadResource, ListResources, ListResourceTemplates, SubscribeResource, UnsubscribeResource, CompletePromptOrResource, SetLoggingLevel, PingServer } from "./client.decorator.js";
|
|
23
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/client/decorators/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/client/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qDAAqD,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AACxF,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,UAAU,EACX,MAAM,uBAAuB,CAAC"}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotificationHandler = exports.NOTIFICATION_META = void 0;
|
|
4
|
-
exports.NOTIFICATION_META = Symbol("pendingNotifications");
|
|
1
|
+
export const NOTIFICATION_META = Symbol("pendingNotifications");
|
|
5
2
|
/**
|
|
6
3
|
* @description
|
|
7
4
|
* Decorator to register a method as an MCP client notification handler.
|
|
8
5
|
* @param method - Zod Schema or string method name.
|
|
9
6
|
*/
|
|
10
|
-
function NotificationHandler(method) {
|
|
7
|
+
export function NotificationHandler(method) {
|
|
11
8
|
return function (target, propertyKey) {
|
|
12
|
-
if (!target[
|
|
13
|
-
target[
|
|
9
|
+
if (!target[NOTIFICATION_META]) {
|
|
10
|
+
target[NOTIFICATION_META] = [];
|
|
14
11
|
}
|
|
15
|
-
target[
|
|
12
|
+
target[NOTIFICATION_META].push({ method, methodName: propertyKey });
|
|
16
13
|
};
|
|
17
14
|
}
|
|
18
|
-
exports.NotificationHandler = NotificationHandler;
|
|
19
15
|
//# sourceMappingURL=notification.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.decorator.js","sourceRoot":"","sources":["../../../../../src/client/decorators/notification.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notification.decorator.js","sourceRoot":"","sources":["../../../../../src/client/decorators/notification.decorator.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAEhE;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAoB;IACtD,OAAO,UAAU,MAAW,EAAE,WAA4B;QACxD,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC;QACjC,CAAC;QACD,MAAM,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RequestHandler = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @description
|
|
6
3
|
* Decorator to register a method as an MCP client request handler.
|
|
7
4
|
* @param schema - Zod Schema or string method name.
|
|
8
5
|
*/
|
|
9
|
-
function RequestHandler(schema) {
|
|
6
|
+
export function RequestHandler(schema) {
|
|
10
7
|
return function (target, propertyKey) {
|
|
11
8
|
if (!target._pendingHandlers) {
|
|
12
9
|
target._pendingHandlers = [];
|
|
@@ -14,5 +11,4 @@ function RequestHandler(schema) {
|
|
|
14
11
|
target._pendingHandlers.push({ schema, methodName: propertyKey });
|
|
15
12
|
};
|
|
16
13
|
}
|
|
17
|
-
exports.RequestHandler = RequestHandler;
|
|
18
14
|
//# sourceMappingURL=requestHandler.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestHandler.decorator.js","sourceRoot":"","sources":["../../../../../src/client/decorators/requestHandler.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"requestHandler.decorator.js","sourceRoot":"","sources":["../../../../../src/client/decorators/requestHandler.decorator.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAW;IACxC,OAAO,UAAU,MAAW,EAAE,WAA4B;QACxD,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAC7B,MAAM,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC/B,CAAC;QACD,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;IACpE,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./decorators/index.js"), exports);
|
|
18
|
-
__exportStar(require("./types/index.js"), exports);
|
|
19
|
-
__exportStar(require("./utils/index.js"), exports);
|
|
1
|
+
export * from "./decorators/index.js";
|
|
2
|
+
export * from "./types/index.js";
|
|
3
|
+
export * from "./utils/index.js";
|
|
20
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("@modelcontextprotocol/sdk/types.js"), exports);
|
|
18
|
-
__exportStar(require("./client/client.js"), exports);
|
|
1
|
+
export * from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
export * from "./client/client.js";
|
|
19
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/client/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/client/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAA;AAClD,cAAc,oBAAoB,CAAA"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getClient = exports.registerClient = void 0;
|
|
4
1
|
const clientRegistry = new Map();
|
|
5
2
|
/**
|
|
6
3
|
* Registers a client instance in the global registry.
|
|
7
4
|
*/
|
|
8
|
-
function registerClient(options, client) {
|
|
5
|
+
export function registerClient(options, client) {
|
|
9
6
|
const { name, version } = options;
|
|
10
7
|
const clientMetadata = { name, version, client };
|
|
11
8
|
const existingClients = clientRegistry.get(name) || [];
|
|
@@ -15,11 +12,10 @@ function registerClient(options, client) {
|
|
|
15
12
|
}
|
|
16
13
|
clientRegistry.set(name, [...existingClients, clientMetadata]);
|
|
17
14
|
}
|
|
18
|
-
exports.registerClient = registerClient;
|
|
19
15
|
/**
|
|
20
16
|
* Retrieves a registered client instance.
|
|
21
17
|
*/
|
|
22
|
-
function getClient(options) {
|
|
18
|
+
export function getClient(options) {
|
|
23
19
|
const { name, version } = options;
|
|
24
20
|
const clientMetadataList = clientRegistry.get(name);
|
|
25
21
|
if (!clientMetadataList || clientMetadataList.length === 0) {
|
|
@@ -34,5 +30,4 @@ function getClient(options) {
|
|
|
34
30
|
}
|
|
35
31
|
return clientMetadataList[0].client;
|
|
36
32
|
}
|
|
37
|
-
exports.getClient = getClient;
|
|
38
33
|
//# sourceMappingURL=clientRegistry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientRegistry.js","sourceRoot":"","sources":["../../../../../src/client/utils/clientRegistry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clientRegistry.js","sourceRoot":"","sources":["../../../../../src/client/utils/clientRegistry.ts"],"names":[],"mappings":"AAOA,MAAM,cAAc,GAAG,IAAI,GAAG,EAA4B,CAAC;AAE3D;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,OAA8B,EAC9B,MAAW;IAEX,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,cAAc,GAAmB,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACjE,MAAM,eAAe,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAEvD,MAAM,iBAAiB,GAAG,eAAe,CAAC,IAAI,CAC5C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAC7B,CAAC;IAEF,IAAI,iBAAiB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,qBAAqB,IAAI,kBAAkB,OAAO,0BAA0B,CAC7E,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,OAAyB;IACjD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,kBAAkB,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAA0B,CAAC;IAE7E,IAAI,CAAC,kBAAkB,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,WAAW,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,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