@connxio/cli 0.1.0 → 0.1.1

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/index.mjs CHANGED
@@ -31659,27 +31659,39 @@ var StdioServerTransport = class {
31659
31659
  }
31660
31660
  };
31661
31661
  //#endregion
31662
- //#region packages/cli/src/mcp/server.ts
31663
- const execFileAsync = promisify(execFile);
31662
+ //#region packages/cli/src/mcp/tools/shared.ts
31664
31663
  const contextIdSchema = string().describe("Connxio context id. Required for write tools.");
31665
31664
  const optionalContextIdSchema = string().optional().describe("Optional Connxio context id.");
31666
31665
  const confirmSchema = literal(true).describe("Must be true to confirm this destructive action.");
31667
31666
  const jsonObjectSchema = record(string(), unknown()).describe("JSON request body for the Connxio API operation.");
31668
- async function serveMcp() {
31669
- const server = new McpServer({
31670
- name: "connxio",
31671
- version: "0.1.0"
31672
- });
31673
- registerCliTools(server);
31674
- registerContextTools(server);
31675
- registerSubscriptionTools(server);
31676
- registerIntegrationTools(server);
31677
- registerCodeComponentTools(server);
31678
- registerEnvironmentVariableTools(server);
31679
- registerSecurityConfigTools(server);
31680
- const transport = new StdioServerTransport();
31681
- await server.connect(transport);
31667
+ async function getClient(contextId) {
31668
+ return new ConnxioClient(await resolveContext(contextId));
31669
+ }
31670
+ async function withToolErrors(action) {
31671
+ try {
31672
+ return jsonToolResult(await action());
31673
+ } catch (error) {
31674
+ return errorToolResult(error instanceof Error ? error.message : String(error));
31675
+ }
31676
+ }
31677
+ function jsonToolResult(value) {
31678
+ return { content: [{
31679
+ type: "text",
31680
+ text: JSON.stringify(value, null, 2)
31681
+ }] };
31682
+ }
31683
+ function errorToolResult(message) {
31684
+ return {
31685
+ content: [{
31686
+ type: "text",
31687
+ text: message
31688
+ }],
31689
+ isError: true
31690
+ };
31682
31691
  }
31692
+ //#endregion
31693
+ //#region packages/cli/src/mcp/tools/cli.ts
31694
+ const execFileAsync = promisify(execFile);
31683
31695
  function registerCliTools(server) {
31684
31696
  server.registerTool("check_cli_update", { description: "Check whether a newer version of the Connxio CLI is available on npm. Call this proactively to let the user know if an update is available." }, async () => withToolErrors(async () => {
31685
31697
  const info = await updateNotifier({
@@ -31710,79 +31722,8 @@ function registerCliTools(server) {
31710
31722
  };
31711
31723
  }));
31712
31724
  }
31713
- function registerContextTools(server) {
31714
- server.registerTool("list_contexts", { description: "List configured Connxio contexts without exposing API keys." }, async () => jsonToolResult({ contexts: await listPublicContexts() }));
31715
- server.registerTool("get_current_context", {
31716
- description: "Get the resolved Connxio context. Uses the default context when available.",
31717
- inputSchema: { contextId: optionalContextIdSchema }
31718
- }, async ({ contextId }) => withToolErrors(async () => {
31719
- const context = await resolveContext(contextId);
31720
- return { context: {
31721
- baseUrl: context.baseUrl,
31722
- companyId: context.companyId,
31723
- companyName: context.companyName,
31724
- hasCredential: await hasApiKey(context.apiKeyRef),
31725
- id: context.id,
31726
- name: context.name,
31727
- subscriptionId: context.subscriptionId,
31728
- subscriptionName: context.subscriptionName
31729
- } };
31730
- }));
31731
- }
31732
- function registerSubscriptionTools(server) {
31733
- server.registerTool("list_subscriptions", {
31734
- description: "List the Connxio subscription associated with the selected context API key.",
31735
- inputSchema: { contextId: optionalContextIdSchema }
31736
- }, async ({ contextId }) => withToolErrors(async () => ({ subscriptions: await (await getClient(contextId)).listSubscriptions() })));
31737
- server.registerTool("get_current_subscription", {
31738
- description: "Get the Connxio subscription associated with the selected context API key.",
31739
- inputSchema: { contextId: optionalContextIdSchema }
31740
- }, async ({ contextId }) => withToolErrors(async () => ({ subscription: await (await getClient(contextId)).getCurrentSubscription() })));
31741
- }
31742
- function registerIntegrationTools(server) {
31743
- server.registerTool("list_integrations", {
31744
- description: "List all Connxio integrations.",
31745
- inputSchema: { contextId: optionalContextIdSchema }
31746
- }, async ({ contextId }) => withToolErrors(async () => ({ integrations: await (await getClient(contextId)).get("/v2/integrations") })));
31747
- server.registerTool("get_integration", {
31748
- description: "Get a Connxio integration by id.",
31749
- inputSchema: {
31750
- contextId: optionalContextIdSchema,
31751
- id: string().describe("Integration id."),
31752
- replaceVariables: boolean().optional().describe("Whether to replace environment variable strings with their values.")
31753
- }
31754
- }, async ({ contextId, id, replaceVariables }) => withToolErrors(async () => ({ integration: await (await getClient(contextId)).get(`/v2/integrations/${encodeURIComponent(id)}`, { query: { replaceVariables } }) })));
31755
- server.registerTool("upsert_integration", {
31756
- description: "Create or update a Connxio integration. Requires contextId.",
31757
- inputSchema: {
31758
- contextId: contextIdSchema,
31759
- integration: jsonObjectSchema
31760
- }
31761
- }, async ({ contextId, integration }) => withToolErrors(async () => ({ result: await (await getClient(contextId)).post("/v2/integrations", { body: integration }) })));
31762
- server.registerTool("upsert_integration_no_validation", {
31763
- description: "Create or update a Connxio integration without validation. Requires contextId.",
31764
- inputSchema: {
31765
- contextId: contextIdSchema,
31766
- integration: jsonObjectSchema
31767
- }
31768
- }, async ({ contextId, integration }) => withToolErrors(async () => ({ result: await (await getClient(contextId)).post("/v2/integrations/novalidation", { body: integration }) })));
31769
- server.registerTool("update_integration", {
31770
- description: "Update an existing Connxio integration by id. Requires contextId.",
31771
- inputSchema: {
31772
- contextId: contextIdSchema,
31773
- id: string().describe("Integration id."),
31774
- integration: jsonObjectSchema
31775
- }
31776
- }, async ({ contextId, id, integration }) => withToolErrors(async () => ({ result: await (await getClient(contextId)).put(`/v2/integrations/${encodeURIComponent(id)}`, { body: integration }) })));
31777
- server.registerTool("delete_integration", {
31778
- description: "Delete a Connxio integration by id. Requires contextId and confirm: true.",
31779
- inputSchema: {
31780
- contextId: contextIdSchema,
31781
- id: string().describe("Integration id."),
31782
- confirm: confirmSchema
31783
- }
31784
- }, async ({ contextId, id }) => withToolErrors(async () => ({ result: await (await getClient(contextId)).delete(`/v2/integrations/${encodeURIComponent(id)}`) })));
31785
- }
31725
+ //#endregion
31726
+ //#region packages/cli/src/mcp/tools/code-components.ts
31786
31727
  function registerCodeComponentTools(server) {
31787
31728
  server.registerTool("list_code_components", {
31788
31729
  description: "List all Connxio code components.",
@@ -31802,8 +31743,8 @@ function registerCodeComponentTools(server) {
31802
31743
  id: string().describe("Code component id.")
31803
31744
  }
31804
31745
  }, async ({ contextId, id }) => withToolErrors(async () => ({ versions: await (await getClient(contextId)).get(`/v2/codecomponents/${encodeURIComponent(id)}/versions`) })));
31805
- server.registerTool("upsert_code_component", {
31806
- description: "Create or update a Connxio code component. Requires contextId.",
31746
+ server.registerTool("create_code_component", {
31747
+ description: "Create a Connxio code component. Requires contextId.",
31807
31748
  inputSchema: {
31808
31749
  contextId: contextIdSchema,
31809
31750
  codeComponent: jsonObjectSchema
@@ -31834,6 +31775,29 @@ function registerCodeComponentTools(server) {
31834
31775
  }
31835
31776
  }, async ({ contextId, id }) => withToolErrors(async () => ({ result: await (await getClient(contextId)).delete(`/v2/codecomponents/${encodeURIComponent(id)}`) })));
31836
31777
  }
31778
+ //#endregion
31779
+ //#region packages/cli/src/mcp/tools/contexts.ts
31780
+ function registerContextTools(server) {
31781
+ server.registerTool("list_contexts", { description: "List configured Connxio contexts without exposing API keys." }, async () => withToolErrors(async () => ({ contexts: await listPublicContexts() })));
31782
+ server.registerTool("get_current_context", {
31783
+ description: "Get the resolved Connxio context. Uses the default context when available.",
31784
+ inputSchema: { contextId: optionalContextIdSchema }
31785
+ }, async ({ contextId }) => withToolErrors(async () => {
31786
+ const context = await resolveContext(contextId);
31787
+ return { context: {
31788
+ baseUrl: context.baseUrl,
31789
+ companyId: context.companyId,
31790
+ companyName: context.companyName,
31791
+ hasCredential: await hasApiKey(context.apiKeyRef),
31792
+ id: context.id,
31793
+ name: context.name,
31794
+ subscriptionId: context.subscriptionId,
31795
+ subscriptionName: context.subscriptionName
31796
+ } };
31797
+ }));
31798
+ }
31799
+ //#endregion
31800
+ //#region packages/cli/src/mcp/tools/environment-variables.ts
31837
31801
  function registerEnvironmentVariableTools(server) {
31838
31802
  server.registerTool("list_environment_variables", {
31839
31803
  description: "List all Connxio environment variables.",
@@ -31846,8 +31810,8 @@ function registerEnvironmentVariableTools(server) {
31846
31810
  id: string().describe("Environment variable id.")
31847
31811
  }
31848
31812
  }, async ({ contextId, id }) => withToolErrors(async () => ({ environmentVariable: await (await getClient(contextId)).get(`/v2/environmentvariables/${encodeURIComponent(id)}`) })));
31849
- server.registerTool("upsert_environment_variable", {
31850
- description: "Create or update a Connxio environment variable. Requires contextId.",
31813
+ server.registerTool("create_environment_variable", {
31814
+ description: "Create a Connxio environment variable. Requires contextId.",
31851
31815
  inputSchema: {
31852
31816
  contextId: contextIdSchema,
31853
31817
  environmentVariable: jsonObjectSchema
@@ -31862,6 +31826,54 @@ function registerEnvironmentVariableTools(server) {
31862
31826
  }
31863
31827
  }, async ({ contextId, id }) => withToolErrors(async () => ({ result: await (await getClient(contextId)).delete(`/v2/environmentvariables/${encodeURIComponent(id)}`) })));
31864
31828
  }
31829
+ //#endregion
31830
+ //#region packages/cli/src/mcp/tools/integrations.ts
31831
+ function registerIntegrationTools(server) {
31832
+ server.registerTool("list_integrations", {
31833
+ description: "List all Connxio integrations.",
31834
+ inputSchema: { contextId: optionalContextIdSchema }
31835
+ }, async ({ contextId }) => withToolErrors(async () => ({ integrations: await (await getClient(contextId)).get("/v2/integrations") })));
31836
+ server.registerTool("get_integration", {
31837
+ description: "Get a Connxio integration by id.",
31838
+ inputSchema: {
31839
+ contextId: optionalContextIdSchema,
31840
+ id: string().describe("Integration id."),
31841
+ replaceVariables: boolean().optional().describe("Whether to replace environment variable strings with their values.")
31842
+ }
31843
+ }, async ({ contextId, id, replaceVariables }) => withToolErrors(async () => ({ integration: await (await getClient(contextId)).get(`/v2/integrations/${encodeURIComponent(id)}`, { query: { replaceVariables } }) })));
31844
+ server.registerTool("create_integration", {
31845
+ description: "Create a Connxio integration. Requires contextId.",
31846
+ inputSchema: {
31847
+ contextId: contextIdSchema,
31848
+ integration: jsonObjectSchema
31849
+ }
31850
+ }, async ({ contextId, integration }) => withToolErrors(async () => ({ result: await (await getClient(contextId)).post("/v2/integrations", { body: integration }) })));
31851
+ server.registerTool("create_integration_no_validation", {
31852
+ description: "Create a Connxio integration without validation. Requires contextId.",
31853
+ inputSchema: {
31854
+ contextId: contextIdSchema,
31855
+ integration: jsonObjectSchema
31856
+ }
31857
+ }, async ({ contextId, integration }) => withToolErrors(async () => ({ result: await (await getClient(contextId)).post("/v2/integrations/novalidation", { body: integration }) })));
31858
+ server.registerTool("update_integration", {
31859
+ description: "Update an existing Connxio integration by id. Requires contextId.",
31860
+ inputSchema: {
31861
+ contextId: contextIdSchema,
31862
+ id: string().describe("Integration id."),
31863
+ integration: jsonObjectSchema
31864
+ }
31865
+ }, async ({ contextId, id, integration }) => withToolErrors(async () => ({ result: await (await getClient(contextId)).put(`/v2/integrations/${encodeURIComponent(id)}`, { body: integration }) })));
31866
+ server.registerTool("delete_integration", {
31867
+ description: "Delete a Connxio integration by id. Requires contextId and confirm: true.",
31868
+ inputSchema: {
31869
+ contextId: contextIdSchema,
31870
+ id: string().describe("Integration id."),
31871
+ confirm: confirmSchema
31872
+ }
31873
+ }, async ({ contextId, id }) => withToolErrors(async () => ({ result: await (await getClient(contextId)).delete(`/v2/integrations/${encodeURIComponent(id)}`) })));
31874
+ }
31875
+ //#endregion
31876
+ //#region packages/cli/src/mcp/tools/security-configs.ts
31865
31877
  function registerSecurityConfigTools(server) {
31866
31878
  server.registerTool("list_security_configs", {
31867
31879
  description: "List all Connxio security configurations.",
@@ -31874,8 +31886,8 @@ function registerSecurityConfigTools(server) {
31874
31886
  id: string().describe("Security configuration id.")
31875
31887
  }
31876
31888
  }, async ({ contextId, id }) => withToolErrors(async () => ({ securityConfig: await (await getClient(contextId)).get(`/v2/securityconfigs/${encodeURIComponent(id)}`) })));
31877
- server.registerTool("upsert_security_config", {
31878
- description: "Create or update a Connxio security configuration. Requires contextId.",
31889
+ server.registerTool("create_security_config", {
31890
+ description: "Create a Connxio security configuration. Requires contextId.",
31879
31891
  inputSchema: {
31880
31892
  contextId: contextIdSchema,
31881
31893
  securityConfig: jsonObjectSchema
@@ -31890,30 +31902,34 @@ function registerSecurityConfigTools(server) {
31890
31902
  }
31891
31903
  }, async ({ contextId, id }) => withToolErrors(async () => ({ result: await (await getClient(contextId)).delete(`/v2/securityconfigs/${encodeURIComponent(id)}`) })));
31892
31904
  }
31893
- async function getClient(contextId) {
31894
- return new ConnxioClient(await resolveContext(contextId));
31895
- }
31896
- async function withToolErrors(action) {
31897
- try {
31898
- return jsonToolResult(await action());
31899
- } catch (error) {
31900
- return errorToolResult(error instanceof Error ? error.message : String(error));
31901
- }
31902
- }
31903
- function jsonToolResult(value) {
31904
- return { content: [{
31905
- type: "text",
31906
- text: JSON.stringify(value, null, 2)
31907
- }] };
31905
+ //#endregion
31906
+ //#region packages/cli/src/mcp/tools/subscriptions.ts
31907
+ function registerSubscriptionTools(server) {
31908
+ server.registerTool("list_subscriptions", {
31909
+ description: "List the Connxio subscription associated with the selected context API key.",
31910
+ inputSchema: { contextId: optionalContextIdSchema }
31911
+ }, async ({ contextId }) => withToolErrors(async () => ({ subscriptions: await (await getClient(contextId)).listSubscriptions() })));
31912
+ server.registerTool("get_current_subscription", {
31913
+ description: "Get the Connxio subscription associated with the selected context API key.",
31914
+ inputSchema: { contextId: optionalContextIdSchema }
31915
+ }, async ({ contextId }) => withToolErrors(async () => ({ subscription: await (await getClient(contextId)).getCurrentSubscription() })));
31908
31916
  }
31909
- function errorToolResult(message) {
31910
- return {
31911
- content: [{
31912
- type: "text",
31913
- text: message
31914
- }],
31915
- isError: true
31916
- };
31917
+ //#endregion
31918
+ //#region packages/cli/src/mcp/server.ts
31919
+ async function serveMcp() {
31920
+ const server = new McpServer({
31921
+ name: "connxio",
31922
+ version: "0.1.0"
31923
+ });
31924
+ registerCliTools(server);
31925
+ registerContextTools(server);
31926
+ registerSubscriptionTools(server);
31927
+ registerIntegrationTools(server);
31928
+ registerCodeComponentTools(server);
31929
+ registerEnvironmentVariableTools(server);
31930
+ registerSecurityConfigTools(server);
31931
+ const transport = new StdioServerTransport();
31932
+ await server.connect(transport);
31917
31933
  }
31918
31934
  //#endregion
31919
31935
  //#region packages/cli/src/cli/commands/mcp.ts