@manifest-network/manifest-mcp-core 0.9.0 → 0.10.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/dist/__test-utils__/callToolWithElicitation.d.ts +43 -0
- package/dist/__test-utils__/callToolWithElicitation.d.ts.map +1 -0
- package/dist/__test-utils__/callToolWithElicitation.js +57 -0
- package/dist/__test-utils__/callToolWithElicitation.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ToolResult } from "./callTool.js";
|
|
2
|
+
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
3
|
+
import { ElicitRequest, ElicitResult } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
|
+
|
|
6
|
+
//#region src/__test-utils__/callToolWithElicitation.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Scripted responder for incoming `elicitation/create` requests on the
|
|
9
|
+
* test-side MCP `Client`. The test author owns the mapping from request
|
|
10
|
+
* shape → result — the helper just wires it up.
|
|
11
|
+
*
|
|
12
|
+
* `respond` may be sync or async. It must return a valid `ElicitResult`
|
|
13
|
+
* (`{ action: 'accept' | 'decline' | 'cancel', content?: ... }`).
|
|
14
|
+
*/
|
|
15
|
+
interface ElicitationScript {
|
|
16
|
+
respond: (req: ElicitRequest) => ElicitResult | Promise<ElicitResult>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Mirror of `callTool` for tools that mid-execution call
|
|
20
|
+
* `server.elicitInput(...)`. Connects an MCP client (advertising the
|
|
21
|
+
* `elicitation` capability by default) to the server over an in-memory
|
|
22
|
+
* transport, registers a request handler that delegates each incoming
|
|
23
|
+
* elicitation to `script.respond`, then invokes the named tool.
|
|
24
|
+
*
|
|
25
|
+
* Cleanup always runs via the `finally` block: client and both transports
|
|
26
|
+
* are closed, then removed from `activeTransports` to prevent double-close
|
|
27
|
+
* in the caller's `afterEach`.
|
|
28
|
+
*
|
|
29
|
+
* @param server - The MCP `Server` instance (from `getServer()`)
|
|
30
|
+
* @param toolName - Name of the tool to invoke
|
|
31
|
+
* @param toolInput - Tool arguments
|
|
32
|
+
* @param script - Scripted responder for `elicitation/create` requests
|
|
33
|
+
* @param activeTransports - Optional mutable array; transports are added
|
|
34
|
+
* before the call and removed after cleanup completes.
|
|
35
|
+
* @param declareElicitationCapability - When `true` (default) the test
|
|
36
|
+
* `Client` advertises `capabilities: { elicitation: {} }`. Set to
|
|
37
|
+
* `false` to exercise the wrapper's capability-guard path (the tool
|
|
38
|
+
* should reject with `INVALID_CONFIG` before any elicitation happens).
|
|
39
|
+
*/
|
|
40
|
+
declare function callToolWithElicitation(server: Server, toolName: string, toolInput: Record<string, unknown>, script: ElicitationScript, activeTransports?: InMemoryTransport[], declareElicitationCapability?: boolean): Promise<ToolResult>;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { ElicitationScript, callToolWithElicitation };
|
|
43
|
+
//# sourceMappingURL=callToolWithElicitation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callToolWithElicitation.d.ts","names":[],"sources":["../../src/__test-utils__/callToolWithElicitation.ts"],"mappings":";;;;;;;;AAkBA;;;;;;UAAiB,iBAAA;EACf,OAAA,GAAU,GAAA,EAAK,aAAA,KAAkB,YAAA,GAAe,OAAA,CAAQ,YAAA;AAAA;;;;;;;;;AAyB1D;;;;;;;;;;;;;;iBAAsB,uBAAA,CACpB,MAAA,EAAQ,MAAA,EACR,QAAA,UACA,SAAA,EAAW,MAAA,mBACX,MAAA,EAAQ,iBAAA,EACR,gBAAA,GAAkB,iBAAA,IAClB,4BAAA,aACC,OAAA,CAAQ,UAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
3
|
+
import { ElicitRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
+
//#region src/__test-utils__/callToolWithElicitation.ts
|
|
5
|
+
/**
|
|
6
|
+
* Mirror of `callTool` for tools that mid-execution call
|
|
7
|
+
* `server.elicitInput(...)`. Connects an MCP client (advertising the
|
|
8
|
+
* `elicitation` capability by default) to the server over an in-memory
|
|
9
|
+
* transport, registers a request handler that delegates each incoming
|
|
10
|
+
* elicitation to `script.respond`, then invokes the named tool.
|
|
11
|
+
*
|
|
12
|
+
* Cleanup always runs via the `finally` block: client and both transports
|
|
13
|
+
* are closed, then removed from `activeTransports` to prevent double-close
|
|
14
|
+
* in the caller's `afterEach`.
|
|
15
|
+
*
|
|
16
|
+
* @param server - The MCP `Server` instance (from `getServer()`)
|
|
17
|
+
* @param toolName - Name of the tool to invoke
|
|
18
|
+
* @param toolInput - Tool arguments
|
|
19
|
+
* @param script - Scripted responder for `elicitation/create` requests
|
|
20
|
+
* @param activeTransports - Optional mutable array; transports are added
|
|
21
|
+
* before the call and removed after cleanup completes.
|
|
22
|
+
* @param declareElicitationCapability - When `true` (default) the test
|
|
23
|
+
* `Client` advertises `capabilities: { elicitation: {} }`. Set to
|
|
24
|
+
* `false` to exercise the wrapper's capability-guard path (the tool
|
|
25
|
+
* should reject with `INVALID_CONFIG` before any elicitation happens).
|
|
26
|
+
*/
|
|
27
|
+
async function callToolWithElicitation(server, toolName, toolInput, script, activeTransports = [], declareElicitationCapability = true) {
|
|
28
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
29
|
+
activeTransports.push(clientTransport, serverTransport);
|
|
30
|
+
const client = new Client({
|
|
31
|
+
name: "test-client",
|
|
32
|
+
version: "1.0.0"
|
|
33
|
+
}, declareElicitationCapability ? { capabilities: { elicitation: {} } } : { capabilities: {} });
|
|
34
|
+
if (declareElicitationCapability) client.setRequestHandler(ElicitRequestSchema, async (request) => {
|
|
35
|
+
return await script.respond(request);
|
|
36
|
+
});
|
|
37
|
+
try {
|
|
38
|
+
await server.connect(serverTransport);
|
|
39
|
+
await client.connect(clientTransport);
|
|
40
|
+
return await client.callTool({
|
|
41
|
+
name: toolName,
|
|
42
|
+
arguments: toolInput
|
|
43
|
+
});
|
|
44
|
+
} finally {
|
|
45
|
+
await client.close().catch(() => {});
|
|
46
|
+
await clientTransport.close().catch(() => {});
|
|
47
|
+
await serverTransport.close().catch(() => {});
|
|
48
|
+
for (const t of [clientTransport, serverTransport]) {
|
|
49
|
+
const idx = activeTransports.indexOf(t);
|
|
50
|
+
if (idx !== -1) activeTransports.splice(idx, 1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { callToolWithElicitation };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=callToolWithElicitation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callToolWithElicitation.js","names":[],"sources":["../../src/__test-utils__/callToolWithElicitation.ts"],"sourcesContent":["import { Client } from '@modelcontextprotocol/sdk/client/index.js';\nimport { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';\nimport type { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport {\n type ElicitRequest,\n ElicitRequestSchema,\n type ElicitResult,\n} from '@modelcontextprotocol/sdk/types.js';\nimport type { ToolResult } from './callTool.js';\n\n/**\n * Scripted responder for incoming `elicitation/create` requests on the\n * test-side MCP `Client`. The test author owns the mapping from request\n * shape → result — the helper just wires it up.\n *\n * `respond` may be sync or async. It must return a valid `ElicitResult`\n * (`{ action: 'accept' | 'decline' | 'cancel', content?: ... }`).\n */\nexport interface ElicitationScript {\n respond: (req: ElicitRequest) => ElicitResult | Promise<ElicitResult>;\n}\n\n/**\n * Mirror of `callTool` for tools that mid-execution call\n * `server.elicitInput(...)`. Connects an MCP client (advertising the\n * `elicitation` capability by default) to the server over an in-memory\n * transport, registers a request handler that delegates each incoming\n * elicitation to `script.respond`, then invokes the named tool.\n *\n * Cleanup always runs via the `finally` block: client and both transports\n * are closed, then removed from `activeTransports` to prevent double-close\n * in the caller's `afterEach`.\n *\n * @param server - The MCP `Server` instance (from `getServer()`)\n * @param toolName - Name of the tool to invoke\n * @param toolInput - Tool arguments\n * @param script - Scripted responder for `elicitation/create` requests\n * @param activeTransports - Optional mutable array; transports are added\n * before the call and removed after cleanup completes.\n * @param declareElicitationCapability - When `true` (default) the test\n * `Client` advertises `capabilities: { elicitation: {} }`. Set to\n * `false` to exercise the wrapper's capability-guard path (the tool\n * should reject with `INVALID_CONFIG` before any elicitation happens).\n */\nexport async function callToolWithElicitation(\n server: Server,\n toolName: string,\n toolInput: Record<string, unknown>,\n script: ElicitationScript,\n activeTransports: InMemoryTransport[] = [],\n declareElicitationCapability = true,\n): Promise<ToolResult> {\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n activeTransports.push(clientTransport, serverTransport);\n\n const client = new Client(\n { name: 'test-client', version: '1.0.0' },\n declareElicitationCapability\n ? { capabilities: { elicitation: {} } }\n : { capabilities: {} },\n );\n\n // Register BEFORE connect so the handler is in place by the time the\n // server issues its first `elicitation/create` request mid-tool.\n //\n // Skip registration when the client did NOT advertise the elicitation\n // capability — the SDK's `setRequestHandler` enforces that the client\n // must have declared the capability for the request type, and would\n // throw before the tool call ever ran. The capability-guard test path\n // (`declareElicitationCapability: false`) exercises the wrapper's\n // `assertElicitationCapability` throw — no elicitation will arrive,\n // so no handler is needed.\n if (declareElicitationCapability) {\n client.setRequestHandler(ElicitRequestSchema, async (request) => {\n return await script.respond(request);\n });\n }\n\n try {\n await server.connect(serverTransport);\n await client.connect(clientTransport);\n\n return (await client.callTool({\n name: toolName,\n arguments: toolInput,\n })) as ToolResult;\n } finally {\n await client.close().catch(() => {});\n await clientTransport.close().catch(() => {});\n await serverTransport.close().catch(() => {});\n\n // Remove by identity so afterEach won't double-close\n for (const t of [clientTransport, serverTransport]) {\n const idx = activeTransports.indexOf(t);\n if (idx !== -1) activeTransports.splice(idx, 1);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,eAAsB,wBACpB,QACA,UACA,WACA,QACA,mBAAwC,EAAE,EAC1C,+BAA+B,MACV;CACrB,MAAM,CAAC,iBAAiB,mBACtB,kBAAkB,kBAAkB;AACtC,kBAAiB,KAAK,iBAAiB,gBAAgB;CAEvD,MAAM,SAAS,IAAI,OACjB;EAAE,MAAM;EAAe,SAAS;EAAS,EACzC,+BACI,EAAE,cAAc,EAAE,aAAa,EAAE,EAAE,EAAE,GACrC,EAAE,cAAc,EAAE,EAAE,CACzB;AAYD,KAAI,6BACF,QAAO,kBAAkB,qBAAqB,OAAO,YAAY;AAC/D,SAAO,MAAM,OAAO,QAAQ,QAAQ;GACpC;AAGJ,KAAI;AACF,QAAM,OAAO,QAAQ,gBAAgB;AACrC,QAAM,OAAO,QAAQ,gBAAgB;AAErC,SAAQ,MAAM,OAAO,SAAS;GAC5B,MAAM;GACN,WAAW;GACZ,CAAC;WACM;AACR,QAAM,OAAO,OAAO,CAAC,YAAY,GAAG;AACpC,QAAM,gBAAgB,OAAO,CAAC,YAAY,GAAG;AAC7C,QAAM,gBAAgB,OAAO,CAAC,YAAY,GAAG;AAG7C,OAAK,MAAM,KAAK,CAAC,iBAAiB,gBAAgB,EAAE;GAClD,MAAM,MAAM,iBAAiB,QAAQ,EAAE;AACvC,OAAI,QAAQ,GAAI,kBAAiB,OAAO,KAAK,EAAE"}
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../src/version.ts"],"sourcesContent":["export const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../src/version.ts"],"sourcesContent":["export const VERSION = '0.10.0';\n"],"mappings":";AAAA,MAAa,UAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manifest-network/manifest-mcp-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Shared library for Cosmos SDK blockchain logic, tool functions, and server utilities (Manifest Network)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"./__test-utils__/callTool.js": {
|
|
18
18
|
"import": "./dist/__test-utils__/callTool.js",
|
|
19
19
|
"types": "./dist/__test-utils__/callTool.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./__test-utils__/callToolWithElicitation.js": {
|
|
22
|
+
"import": "./dist/__test-utils__/callToolWithElicitation.js",
|
|
23
|
+
"types": "./dist/__test-utils__/callToolWithElicitation.d.ts"
|
|
20
24
|
}
|
|
21
25
|
},
|
|
22
26
|
"scripts": {
|