@vibeprospecting/vpai 0.1.3 → 0.1.4

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 CHANGED
@@ -35,7 +35,7 @@ npm install -g @vibeprospecting/vpai
35
35
 
36
36
  ```bash
37
37
  git clone <repo>
38
- cd mcp-cli
38
+ cd vpai-cli
39
39
  npm install
40
40
  npm run build
41
41
  ```
@@ -136,12 +136,27 @@ OAuth runs automatically on first use (browser opens). Tokens are cached by mcpo
136
136
 
137
137
  MCP server URL, OAuth settings, and timeout are embedded in the build (`src/embedded-config.ts`). No external config files.
138
138
 
139
+ ### Error handling
140
+
141
+ All failure paths set `process.exitCode = 1` or call `process.exit(1)` so the process exits with a non-zero code:
142
+
143
+ | Failure | Behavior |
144
+ |---------|----------|
145
+ | Runtime init (`ensureRuntime`) | Logs "Failed to initialize MCP runtime", rethrows, CLI catches and exits 1 |
146
+ | List tools (`listTools`) | Logs "Failed to list tools from MCP server", rethrows, CLI catches and exits 1 |
147
+ | Schema resolution (`resolveToolSchema`) | Logs "Schema resolution failed", sets exitCode 1 |
148
+ | Tool execution (timeout, API error) | Logs "Tool execution timed out" or "Tool execution failed", sets exitCode 1 |
149
+ | Invalid `--args` JSON | Logs "Invalid JSON in --args", sets exitCode 1 |
150
+ | Non-object `--args` | Logs "--args must be a JSON object", sets exitCode 1 |
151
+
152
+ Errors are logged as JSON to stderr. No unhandled promise rejections or silent failures.
153
+
139
154
  ---
140
155
 
141
156
  ## Project Structure
142
157
 
143
158
  ```
144
- mcp-cli/
159
+ vpai-cli/
145
160
  ├── src/
146
161
  │ ├── cli.ts # Entry point
147
162
  │ ├── proxy.ts # Tool registration
package/dist/vpai CHANGED
Binary file
package/dist/vpai.js CHANGED
@@ -41003,6 +41003,12 @@ async function executeTool(options) {
41003
41003
  args,
41004
41004
  timeoutMs
41005
41005
  });
41006
+ const raw = result?.raw;
41007
+ if (raw && typeof raw === "object" && raw.isError === true) {
41008
+ const content = raw.content;
41009
+ const msg = Array.isArray(content) && content[0] && typeof content[0].text === "string" ? String(content[0].text) : "Tool returned error";
41010
+ throw new Error(msg);
41011
+ }
41006
41012
  printResult(result);
41007
41013
  }
41008
41014
 
@@ -41058,33 +41064,46 @@ var logger = {
41058
41064
  var ALL_PARAMS_HELP = "Show input and output schemas instead of calling the tool. Use before --args to inspect parameters.";
41059
41065
  var ARGS_HELP = `JSON object with tool arguments. Example: --args '{"country_code":{"values":["US"]}}'`;
41060
41066
  var JSON_HELP = "With --all-parameters, output schemas as JSON.";
41061
- function closeRuntime(runtime, serverName) {
41062
- runtime.close(serverName).catch((err) => {
41063
- logger.warn("Failed to close runtime", {
41064
- serverName,
41065
- error: err instanceof Error ? err.message : String(err)
41066
- });
41067
- });
41068
- }
41069
41067
  async function registerProxyCommands(program2, ctx) {
41070
- const runtime = await ensureRuntime();
41071
- const tools = await runtime.listTools(ctx.serverName, {
41072
- includeSchema: false,
41073
- autoAuthorize: true,
41074
- allowCachedAuth: true
41075
- });
41068
+ let runtime;
41069
+ try {
41070
+ runtime = await ensureRuntime();
41071
+ } catch (error49) {
41072
+ const msg = error49 instanceof Error ? error49.message : String(error49);
41073
+ logger.error(msg, { context: "MCP runtime initialization" });
41074
+ throw error49;
41075
+ }
41076
+ let tools;
41077
+ try {
41078
+ tools = await runtime.listTools(ctx.serverName, {
41079
+ includeSchema: false,
41080
+ autoAuthorize: true,
41081
+ allowCachedAuth: true
41082
+ });
41083
+ } catch (error49) {
41084
+ const msg = error49 instanceof Error ? error49.message : String(error49);
41085
+ logger.error(msg, { serverName: ctx.serverName, context: "list tools" });
41086
+ throw error49;
41087
+ }
41076
41088
  for (const tool of tools) {
41077
41089
  const name = tool.name;
41078
41090
  const description = tool.description ?? tool.name;
41079
41091
  program2.command(name).description(description).usage("[options]").option("--all-parameters", ALL_PARAMS_HELP).option("--args <json>", ARGS_HELP).option("--json", JSON_HELP).action(async (cmdOpts) => {
41080
- const rt = await ensureRuntime();
41081
41092
  try {
41082
41093
  if (cmdOpts.allParameters && !cmdOpts.args) {
41083
- const resolved = await resolveToolSchema({
41084
- runtime: rt,
41085
- serverName: ctx.serverName,
41086
- toolName: name
41087
- });
41094
+ let resolved;
41095
+ try {
41096
+ resolved = await resolveToolSchema({
41097
+ runtime,
41098
+ serverName: ctx.serverName,
41099
+ toolName: name
41100
+ });
41101
+ } catch (error49) {
41102
+ const msg = error49 instanceof Error ? error49.message : String(error49);
41103
+ logger.error(msg, { toolName: name, serverName: ctx.serverName });
41104
+ process.exitCode = 1;
41105
+ return;
41106
+ }
41088
41107
  if (resolved) {
41089
41108
  printToolSchemas({
41090
41109
  toolName: resolved.name,
@@ -41099,20 +41118,45 @@ async function registerProxyCommands(program2, ctx) {
41099
41118
  }
41100
41119
  return;
41101
41120
  }
41102
- const args = cmdOpts.args ? JSON.parse(cmdOpts.args) : {};
41103
- await executeTool({
41104
- runtime: rt,
41105
- serverName: ctx.serverName,
41106
- toolName: name,
41107
- args,
41108
- timeoutMs: ctx.defaultTimeout
41109
- });
41110
- } finally {
41111
- closeRuntime(rt, ctx.serverName);
41121
+ let args = {};
41122
+ if (cmdOpts.args != null) {
41123
+ let parsed;
41124
+ try {
41125
+ parsed = JSON.parse(cmdOpts.args);
41126
+ } catch (error49) {
41127
+ const msg = error49 instanceof Error ? error49.message : String(error49);
41128
+ logger.error(msg, { args: cmdOpts.args });
41129
+ process.exitCode = 1;
41130
+ return;
41131
+ }
41132
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
41133
+ logger.error("--args must be a JSON object", { args: cmdOpts.args });
41134
+ process.exitCode = 1;
41135
+ return;
41136
+ }
41137
+ args = parsed;
41138
+ }
41139
+ try {
41140
+ await executeTool({
41141
+ runtime,
41142
+ serverName: ctx.serverName,
41143
+ toolName: name,
41144
+ args,
41145
+ timeoutMs: ctx.defaultTimeout
41146
+ });
41147
+ } catch (error49) {
41148
+ const msg = error49 instanceof Error ? error49.message : String(error49);
41149
+ logger.error(`Tool call failed: ${msg}`, { toolName: name, serverName: ctx.serverName });
41150
+ process.exitCode = 1;
41151
+ }
41152
+ } catch (error49) {
41153
+ const msg = error49 instanceof Error ? error49.message : String(error49);
41154
+ logger.error(`Command failed: ${msg}`, { toolName: name });
41155
+ process.exitCode = 1;
41112
41156
  }
41113
41157
  });
41114
41158
  }
41115
- closeRuntime(runtime, ctx.serverName);
41159
+ return runtime;
41116
41160
  }
41117
41161
  // src/config.ts
41118
41162
  var TIMEOUT_MIN_MS = 1000;
@@ -41126,6 +41170,14 @@ function loadConfig() {
41126
41170
  }
41127
41171
 
41128
41172
  // src/cli.ts
41173
+ function closeRuntime(runtime, serverName) {
41174
+ runtime.close(serverName).catch((err) => {
41175
+ logger.warn("Failed to close runtime", {
41176
+ serverName,
41177
+ error: err instanceof Error ? err.message : String(err)
41178
+ });
41179
+ });
41180
+ }
41129
41181
  var config3 = loadConfig();
41130
41182
  var program2 = new Command;
41131
41183
  program2.name(CLI_NAME);
@@ -41144,18 +41196,22 @@ Examples:
41144
41196
  `);
41145
41197
  var ctx = { serverName: DEFAULT_SERVER_NAME, defaultTimeout: config3.timeout };
41146
41198
  async function runCli() {
41147
- await registerProxyCommands(program2, ctx);
41148
- const args = process.argv.slice(2);
41149
- if (args.length === 0) {
41150
- program2.outputHelp();
41151
- return;
41199
+ const runtime = await registerProxyCommands(program2, ctx);
41200
+ try {
41201
+ const args = process.argv.slice(2);
41202
+ if (args.length === 0) {
41203
+ program2.outputHelp();
41204
+ return;
41205
+ }
41206
+ await program2.parseAsync(process.argv);
41207
+ } finally {
41208
+ closeRuntime(runtime, ctx.serverName);
41152
41209
  }
41153
- await program2.parseAsync(process.argv);
41154
41210
  }
41155
41211
  if (process.env.MCPORTER_DISABLE_AUTORUN !== "1") {
41156
41212
  runCli().catch((error49) => {
41157
41213
  const message = error49 instanceof Error ? error49.message : String(error49);
41158
- logger.error("CLI execution failed", { error: message });
41159
- process.exit(1);
41214
+ logger.error(`CLI execution failed: ${message}`, { context: "CLI execution" });
41215
+ process.exitCode = 1;
41160
41216
  });
41161
41217
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibeprospecting/vpai",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Power your chat with B2B data to create lead lists, research companies, personalize your outreach, and more. Search any company or professional to access emails, phone numbers, roles, growth signals, tech stack details, business events, website changes, and more.",
5
5
  "type": "module",
6
6
  "license": "MIT",