@mcpc-tech/cli 0.1.8-beta.3 → 0.1.10

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/bin/mcpc.mjs CHANGED
@@ -827,6 +827,7 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
827
827
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
828
828
  import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
829
829
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
830
+ import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
830
831
 
831
832
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/registory.js
832
833
  function connectToSmitheryServer(smitheryConfig) {
@@ -862,54 +863,75 @@ var mcpClientPool = /* @__PURE__ */ new Map();
862
863
  var mcpClientConnecting = /* @__PURE__ */ new Map();
863
864
  var shortHash = (s) => createHash("sha256").update(s).digest("hex").slice(0, 8);
864
865
  function defSignature(def) {
865
- return JSON.stringify(def);
866
- }
867
- async function getOrCreateMcpClient(defKey, def) {
868
- const pooled = mcpClientPool.get(defKey);
869
- if (pooled) {
870
- pooled.refCount += 1;
871
- return pooled.client;
866
+ const defCopy = {
867
+ ...def
868
+ };
869
+ if (defCopy.transportType === "memory" || defCopy.transport) {
870
+ return `memory:${Date.now()}:${Math.random()}`;
872
871
  }
873
- const existingConnecting = mcpClientConnecting.get(defKey);
874
- if (existingConnecting) {
875
- const client = await existingConnecting;
876
- const entry = mcpClientPool.get(defKey);
877
- if (entry) entry.refCount += 1;
878
- return client;
872
+ return JSON.stringify(defCopy);
873
+ }
874
+ function createTransport(def) {
875
+ const defAny = def;
876
+ const explicitType = defAny.transportType || defAny.type;
877
+ if (explicitType === "memory") {
878
+ if (!defAny.server) {
879
+ throw new Error("In-memory transport requires a 'server' field with a Server instance");
880
+ }
881
+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
882
+ defAny.server.connect(serverTransport).catch((err) => {
883
+ console.error("Error connecting in-memory server:", err);
884
+ });
885
+ return clientTransport;
879
886
  }
880
- let transport2;
881
- if (typeof def.transportType === "string" && def.transportType === "sse") {
887
+ if (explicitType === "sse") {
882
888
  const options = {};
883
- if (def.headers) {
889
+ if (defAny.headers) {
884
890
  options.requestInit = {
885
- headers: def.headers
891
+ headers: defAny.headers
886
892
  };
887
893
  options.eventSourceInit = {
888
- headers: def.headers
894
+ headers: defAny.headers
889
895
  };
890
896
  }
891
- transport2 = new SSEClientTransport(new URL(def.url), options);
892
- } else if ("url" in def && typeof def.url === "string") {
897
+ return new SSEClientTransport(new URL(defAny.url), options);
898
+ }
899
+ if (defAny.url && typeof defAny.url === "string") {
893
900
  const options = {};
894
- if (def.headers) {
901
+ if (defAny.headers) {
895
902
  options.requestInit = {
896
- headers: def.headers
903
+ headers: defAny.headers
897
904
  };
898
905
  }
899
- transport2 = new StreamableHTTPClientTransport(new URL(def.url), options);
900
- } else if (typeof def.transportType === "string" && def.transportType === "stdio" || "command" in def) {
901
- transport2 = new StdioClientTransport({
902
- command: def.command,
903
- args: def.args,
906
+ return new StreamableHTTPClientTransport(new URL(defAny.url), options);
907
+ }
908
+ if (explicitType === "stdio" || defAny.command) {
909
+ return new StdioClientTransport({
910
+ command: defAny.command,
911
+ args: defAny.args,
904
912
  env: {
905
913
  ...process3.env,
906
- ...def.env ?? {}
914
+ ...defAny.env ?? {}
907
915
  },
908
916
  cwd: cwd()
909
917
  });
910
- } else {
911
- throw new Error(`Unsupported transport type: ${JSON.stringify(def)}`);
912
918
  }
919
+ throw new Error(`Unsupported transport configuration: ${JSON.stringify(def)}`);
920
+ }
921
+ async function getOrCreateMcpClient(defKey, def) {
922
+ const pooled = mcpClientPool.get(defKey);
923
+ if (pooled) {
924
+ pooled.refCount += 1;
925
+ return pooled.client;
926
+ }
927
+ const existingConnecting = mcpClientConnecting.get(defKey);
928
+ if (existingConnecting) {
929
+ const client = await existingConnecting;
930
+ const entry = mcpClientPool.get(defKey);
931
+ if (entry) entry.refCount += 1;
932
+ return client;
933
+ }
934
+ const transport2 = createTransport(def);
913
935
  const connecting = (async () => {
914
936
  const client = new Client({
915
937
  name: `mcp_${shortHash(defSignature(def))}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/cli",
3
- "version": "0.1.8-beta.3",
3
+ "version": "0.1.10",
4
4
  "homepage": "https://jsr.io/@mcpc/cli",
5
5
  "type": "module",
6
6
  "dependencies": {
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,SAAS,WAAW,4BAAwC;AAI5D,cAAc,mBAAmB,0BAA0D;AAC3F,cAAc,UAAU,6BAA6B;AAErD,OAAO,cAAM,eACX,SAAS,eACR,QAAQ,qBA8BT;AAEF,OAAO,cAAM,iBAAgB,YAO3B"}
1
+ {"version":3,"file":"app.d.ts","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,SAAS,WAAW,4BAAwC;AAI5D,cAAc,mBAAmB,0BAAmD;AACpF,cAAc,UAAU,6BAA6B;AAErD,OAAO,cAAM,eACX,SAAS,eACR,QAAQ,qBA8BT;AAEF,OAAO,cAAM,iBAAgB,YAO3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sources":["../../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CC,GAED,cAAc,iBAAiB,0BAAuC;AAKtE,iBAAiB;EACf;;GAEC,GACD,OAAO,MAAM;EACb;;GAEC,GACD,UAAU,MAAM;EAChB;;GAEC,GACD;IACE,QAAQ,OAAO,MAAM,EAAE,OAAO;IAC9B,WAAW,OAAO,MAAM,EAAE,OAAO;;EAEnC;;GAEC,GACD,QAAQ;;AAwHV;;;CAGC,GACD,OAAO,iBAAe,cAAc,QAAQ,aAAa,IAAI;AAoK7D;;CAEC,GACD,OAAO,iBAAS,eAAe,QAAQ,UAAU,GAAG,IAAI"}
1
+ {"version":3,"file":"loader.d.ts","sources":["../../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CC,GAED,cAAc,iBAAiB,0BAAgC;AAK/D,iBAAiB;EACf;;GAEC,GACD,OAAO,MAAM;EACb;;GAEC,GACD,UAAU,MAAM;EAChB;;GAEC,GACD;IACE,QAAQ,OAAO,MAAM,EAAE,OAAO;IAC9B,WAAW,OAAO,MAAM,EAAE,OAAO;;EAEnC;;GAEC,GACD,QAAQ;;AAwHV;;;CAGC,GACD,OAAO,iBAAe,cAAc,QAAQ,aAAa,IAAI;AAoK7D;;CAEC,GACD,OAAO,iBAAS,eAAe,QAAQ,UAAU,GAAG,IAAI"}