mcp-google-map 0.6.0 → 0.8.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/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  Logger,
4
4
  PlacesSearcher
5
- } from "./chunk-NAUIQEK4.js";
5
+ } from "./chunk-OAML6T2D.js";
6
6
 
7
7
  // src/cli.ts
8
8
  import { config as dotenvConfig2 } from "dotenv";
@@ -1594,7 +1594,6 @@ async function checkVersionIdle(deps = {}) {
1594
1594
  case "current":
1595
1595
  lastSuccess = now();
1596
1596
  result.currentVersion = probe.currentVersion;
1597
- logger.error(red("Version check: no newer version available."));
1598
1597
  break;
1599
1598
  case "newer": {
1600
1599
  lastSuccess = now();
@@ -1653,12 +1652,116 @@ function runPackageManagerCommand(command, deps = {}) {
1653
1652
  return reportSpawnFailure(message);
1654
1653
  }
1655
1654
  }
1655
+ function parsePostUpgradeCliOutcomes(raw) {
1656
+ if (raw === void 0) {
1657
+ return void 0;
1658
+ }
1659
+ const start = raw.indexOf("{");
1660
+ if (start < 0) {
1661
+ return void 0;
1662
+ }
1663
+ let parsed;
1664
+ try {
1665
+ parsed = JSON.parse(raw.slice(start));
1666
+ } catch {
1667
+ return void 0;
1668
+ }
1669
+ if (typeof parsed !== "object" || parsed === null) {
1670
+ return void 0;
1671
+ }
1672
+ const summaries = parsed.summaries;
1673
+ const errors = parsed.errors;
1674
+ if (!Array.isArray(summaries)) {
1675
+ return void 0;
1676
+ }
1677
+ const errorTexts = Array.isArray(errors) ? errors.filter((item) => typeof item === "string") : [];
1678
+ const outcomes = [];
1679
+ for (const entry of summaries) {
1680
+ if (typeof entry !== "object" || entry === null) {
1681
+ continue;
1682
+ }
1683
+ const record = entry;
1684
+ const cli = record.cli;
1685
+ if (typeof cli !== "string" || cli.length === 0) {
1686
+ continue;
1687
+ }
1688
+ const lowered = cli.toLowerCase();
1689
+ const failed = errorTexts.some((text) => text.toLowerCase().includes(lowered));
1690
+ outcomes.push({
1691
+ cli,
1692
+ ok: !failed,
1693
+ server: typeof record.server === "number" ? record.server : void 0,
1694
+ skills: typeof record.skills === "number" ? record.skills : void 0
1695
+ });
1696
+ }
1697
+ return outcomes;
1698
+ }
1656
1699
  function runPostUpgradeSkillInstall(options, deps = {}) {
1657
1700
  const enabled = loadCliSettings(options.home).enabled;
1658
1701
  if (enabled.length === 0) {
1659
- return 0;
1702
+ return { exitCode: 0, clis: [] };
1703
+ }
1704
+ const logger = deps.logger ?? Logger;
1705
+ const spawnImpl = deps.spawn ?? spawnSync;
1706
+ const reportSpawnFailure = (message) => {
1707
+ logger.error(`Error executing ${POST_UPGRADE_INSTALL_COMMAND[0]}: ${message}`);
1708
+ logger.log(`Warning: run this command manually: ${POST_UPGRADE_INSTALL_COMMAND.join(" ")}`);
1709
+ return { exitCode: 1, clis: enabled.map((cli) => ({ cli, ok: false })) };
1710
+ };
1711
+ try {
1712
+ const result = spawnImpl(
1713
+ POST_UPGRADE_INSTALL_COMMAND[0],
1714
+ [...POST_UPGRADE_INSTALL_COMMAND.slice(1)],
1715
+ {
1716
+ stdio: ["ignore", "pipe", "inherit"],
1717
+ shell: process.platform === "win32"
1718
+ }
1719
+ );
1720
+ if (result.error) {
1721
+ return reportSpawnFailure(result.error.message);
1722
+ }
1723
+ const exitCode = result.status ?? 1;
1724
+ const stdoutText = result.stdout === void 0 ? void 0 : String(result.stdout);
1725
+ const clis = parsePostUpgradeCliOutcomes(stdoutText) ?? enabled.map((cli) => ({ cli, ok: exitCode === 0 }));
1726
+ return { exitCode, clis };
1727
+ } catch (error) {
1728
+ const message = error instanceof Error ? error.message : String(error);
1729
+ return reportSpawnFailure(message);
1730
+ }
1731
+ }
1732
+ function renderUpgradeSummary(previousVersion, updatedVersion, outcome) {
1733
+ const lines = [
1734
+ `mcp-google-map upgrade completed: ${previousVersion} -> ${updatedVersion}`
1735
+ ];
1736
+ if (outcome.clis.length === 0) {
1737
+ lines.push(
1738
+ outcome.exitCode === 0 ? "Post-upgrade install: skipped (no CLI enabled)." : `Post-upgrade install: FAILED (exit code ${outcome.exitCode}).`
1739
+ );
1740
+ return `${lines.join("\n")}
1741
+ `;
1742
+ }
1743
+ lines.push(
1744
+ outcome.exitCode === 0 ? "Post-upgrade install: completed successfully on the following CLI(s):" : `Post-upgrade install: FAILED (exit code ${outcome.exitCode}) for the following CLI(s):`
1745
+ );
1746
+ for (const entry of outcome.clis) {
1747
+ const counts = entry.server !== void 0 || entry.skills !== void 0 ? ` (server: ${entry.server ?? 0}, skills: ${entry.skills ?? 0})` : "";
1748
+ lines.push(` - ${entry.cli}: ${entry.ok ? "OK" : "FAILED"}${counts}`);
1749
+ }
1750
+ return `${lines.join("\n")}
1751
+ `;
1752
+ }
1753
+ async function resolveUpdatedVersion(options, deps) {
1754
+ const probe = await probeLatestVersion({
1755
+ ...deps.idleCheck,
1756
+ currentVersion: options.currentVersion
1757
+ });
1758
+ if (probe.status === "newer") {
1759
+ return probe.latestVersion;
1660
1760
  }
1661
- return runPackageManagerCommand(POST_UPGRADE_INSTALL_COMMAND, deps);
1761
+ if (probe.status === "current") {
1762
+ return probe.currentVersion;
1763
+ }
1764
+ return "unknown";
1662
1765
  }
1663
1766
  async function runVersionCommand(options, deps = {}) {
1664
1767
  await checkVersionIdle({
@@ -1671,12 +1774,16 @@ async function runVersionCommand(options, deps = {}) {
1671
1774
  `);
1672
1775
  return 0;
1673
1776
  }
1674
- function runUpgradeCommand(options, deps = {}) {
1777
+ async function runUpgradeCommand(options, deps = {}) {
1675
1778
  const upgraded = runPackageManagerCommand(PACKAGE_UPGRADE_COMMAND, deps);
1676
1779
  if (upgraded !== 0) {
1677
1780
  return upgraded;
1678
1781
  }
1679
- return runPostUpgradeSkillInstall(options, deps);
1782
+ const updatedVersion = await resolveUpdatedVersion(options, deps);
1783
+ const outcome = runPostUpgradeSkillInstall(options, deps);
1784
+ const stdout = deps.stdout ?? process.stdout;
1785
+ stdout.write(renderUpgradeSummary(options.currentVersion, updatedVersion, outcome));
1786
+ return outcome.exitCode;
1680
1787
  }
1681
1788
  function runUninstallCommand(deps = {}) {
1682
1789
  return runPackageManagerCommand(PACKAGE_UNINSTALL_COMMAND, deps);
@@ -1788,14 +1895,14 @@ function renderClientSnippet(options = {}) {
1788
1895
  const host = options.host ?? SNIPPET_DEFAULT_HOST;
1789
1896
  const port = options.port ?? SNIPPET_DEFAULT_PORT;
1790
1897
  entry = { url: `http://${host}:${port}/mcp` };
1791
- notes.push(`Start the server first: mcp-google-map --host ${host} --port ${port}.`);
1898
+ notes.push(`Start the server first: mcp-google-map start --host ${host} --port ${port}.`);
1792
1899
  } else {
1793
1900
  const launcher = options.launcher ?? "npx";
1794
1901
  if (launcher === "node" && !options.commandPath) {
1795
1902
  throw new Error("--launcher node requires --command <path> pointing at dist/cli.js");
1796
1903
  }
1797
1904
  const command = launcher === "npx" ? "npx" : launcher === "bin" ? "mcp-google-map" : "node";
1798
- const args = launcher === "npx" ? ["-y", "mcp-google-map", "--stdio"] : launcher === "bin" ? ["--stdio"] : [options.commandPath, "--stdio"];
1905
+ const args = launcher === "npx" ? ["-y", "mcp-google-map", "start", "--stdio"] : launcher === "bin" ? ["start", "--stdio"] : [options.commandPath, "start", "--stdio"];
1799
1906
  if (launcher === "npx") {
1800
1907
  notes.push("The npx launcher runs the published package; npm must be available on PATH.");
1801
1908
  }
@@ -2068,7 +2175,7 @@ function buildServerRegistration(apiKey) {
2068
2175
  if (apiKey !== void 0 && apiKey.length > 0) {
2069
2176
  env.GOOGLE_MAPS_API_KEY = apiKey;
2070
2177
  }
2071
- return { command: "npx", args: ["-y", MCP_SERVER_NAME, "--stdio"], env };
2178
+ return { command: "npx", args: ["-y", MCP_SERVER_NAME, "start", "--stdio"], env };
2072
2179
  }
2073
2180
  function resolveSkillsResourcesRoot(packageRoot) {
2074
2181
  const candidate = resolve3(packageRoot, "src", "resources", "skills");
@@ -2834,7 +2941,65 @@ if (isRunDirectly || isMainModule) {
2834
2941
  process.exitCode = 1;
2835
2942
  });
2836
2943
  } else {
2837
- yargs(hideBin(process.argv)).command(
2944
+ const buildServerCommandOptions = (yargs2) => yargs2.option("port", {
2945
+ alias: "p",
2946
+ type: "number",
2947
+ description: "Port to run the MCP server on",
2948
+ default: process.env.MCP_SERVER_PORT ? parseInt(process.env.MCP_SERVER_PORT) : 3e3
2949
+ }).option("host", {
2950
+ type: "string",
2951
+ description: "Hostname to bind the server to (default 127.0.0.1 loopback; 0.0.0.0 for all interfaces)",
2952
+ default: process.env.MCP_SERVER_HOST || "127.0.0.1"
2953
+ }).option("apikey", {
2954
+ alias: "k",
2955
+ type: "string",
2956
+ description: "Google Maps API key",
2957
+ default: process.env.GOOGLE_MAPS_API_KEY
2958
+ }).option("stdio", {
2959
+ type: "boolean",
2960
+ description: "Use stdio transport instead of HTTP",
2961
+ default: false
2962
+ }).example([
2963
+ ["$0 start", "Start HTTP server with default settings"],
2964
+ ['$0 start --port 3000 --apikey "your_api_key"', "Start HTTP with custom port and API key"],
2965
+ ["$0 start --host 0.0.0.0 --port 3000", "Start HTTP accessible from all interfaces"],
2966
+ ["$0 start --stdio", "Start in stdio mode (for MCP clients)"],
2967
+ ["$0 run --stdio", "Alias: run the server in stdio mode"]
2968
+ ]);
2969
+ const runServerCommand = async (argv) => {
2970
+ if (argv.apikey) {
2971
+ process.env.GOOGLE_MAPS_API_KEY = argv.apikey;
2972
+ }
2973
+ void checkVersionIdle({ currentVersion: packageVersion }).catch(() => void 0);
2974
+ const tools = filterTools(config_default[0].tools);
2975
+ if (argv.stdio) {
2976
+ const server = new BaseMcpServer(config_default[0].name, tools);
2977
+ await server.startStdio();
2978
+ } else {
2979
+ Logger.log("\u{1F5FA}\uFE0F Google Maps MCP Server");
2980
+ Logger.log(" A Model Context Protocol server for Google Maps services");
2981
+ Logger.log("");
2982
+ if (!argv.apikey) {
2983
+ Logger.log("\u26A0\uFE0F Google Maps API Key not found!");
2984
+ Logger.log(" Please provide --apikey parameter or set GOOGLE_MAPS_API_KEY in your .env file");
2985
+ Logger.log("");
2986
+ }
2987
+ startServer(argv.port, argv.apikey, argv.host).then((outcome) => {
2988
+ if (outcome.started === 0) {
2989
+ process.exit(1);
2990
+ }
2991
+ }).catch((error) => {
2992
+ Logger.error("\u274C Failed to start server:", error);
2993
+ process.exit(1);
2994
+ });
2995
+ }
2996
+ };
2997
+ const cli = yargs(hideBin(process.argv)).scriptName("mcp-google-map").usage(
2998
+ `mcp-google-map v${packageVersion}
2999
+
3000
+ Usage: mcp-google-map <command> [options]
3001
+ mcp-google-map start|run [--stdio] [options]`
3002
+ ).command(
2838
3003
  "doctor",
2839
3004
  "Check standalone CLI readiness without starting an MCP server",
2840
3005
  (yargs2) => yargs2.option("live", {
@@ -3164,67 +3329,34 @@ if (isRunDirectly || isMainModule) {
3164
3329
  process.exit(failed > 0 ? 1 : 0);
3165
3330
  }
3166
3331
  ).command(
3167
- "$0",
3332
+ "start",
3168
3333
  "Start the MCP server (HTTP by default, --stdio for stdio mode)",
3169
- (yargs2) => {
3170
- return yargs2.option("port", {
3171
- alias: "p",
3172
- type: "number",
3173
- description: "Port to run the MCP server on",
3174
- default: process.env.MCP_SERVER_PORT ? parseInt(process.env.MCP_SERVER_PORT) : 3e3
3175
- }).option("host", {
3176
- type: "string",
3177
- description: "Hostname to bind the server to (default 127.0.0.1 loopback; 0.0.0.0 for all interfaces)",
3178
- default: process.env.MCP_SERVER_HOST || "127.0.0.1"
3179
- }).option("apikey", {
3180
- alias: "k",
3181
- type: "string",
3182
- description: "Google Maps API key",
3183
- default: process.env.GOOGLE_MAPS_API_KEY
3184
- }).option("stdio", {
3185
- type: "boolean",
3186
- description: "Use stdio transport instead of HTTP",
3187
- default: false
3188
- }).example([
3189
- ["$0", "Start HTTP server with default settings"],
3190
- ['$0 --port 3000 --apikey "your_api_key"', "Start HTTP with custom port and API key"],
3191
- ["$0 --host 0.0.0.0 --port 3000", "Start HTTP accessible from all interfaces"],
3192
- ["$0 --stdio", "Start in stdio mode (for Claude Desktop, Cursor, etc.)"]
3193
- ]);
3194
- },
3195
- async (argv) => {
3196
- if (argv.apikey) {
3197
- process.env.GOOGLE_MAPS_API_KEY = argv.apikey;
3198
- }
3199
- void checkVersionIdle({ currentVersion: packageVersion }).catch(() => void 0);
3200
- const tools = filterTools(config_default[0].tools);
3201
- if (argv.stdio) {
3202
- const server = new BaseMcpServer(config_default[0].name, tools);
3203
- await server.startStdio();
3204
- } else {
3205
- Logger.log("\u{1F5FA}\uFE0F Google Maps MCP Server");
3206
- Logger.log(" A Model Context Protocol server for Google Maps services");
3207
- Logger.log("");
3208
- if (!argv.apikey) {
3209
- Logger.log("\u26A0\uFE0F Google Maps API Key not found!");
3210
- Logger.log(" Please provide --apikey parameter or set GOOGLE_MAPS_API_KEY in your .env file");
3211
- Logger.log("");
3212
- }
3213
- startServer(argv.port, argv.apikey, argv.host).then((outcome) => {
3214
- if (outcome.started === 0) {
3215
- process.exit(1);
3216
- }
3217
- }).catch((error) => {
3218
- Logger.error("\u274C Failed to start server:", error);
3219
- process.exit(1);
3220
- });
3221
- }
3334
+ buildServerCommandOptions,
3335
+ runServerCommand
3336
+ ).command(
3337
+ "run",
3338
+ "Alias of start: run the MCP server (HTTP by default, --stdio for stdio mode)",
3339
+ buildServerCommandOptions,
3340
+ runServerCommand
3341
+ ).command(
3342
+ "$0",
3343
+ "Print the help text (use start or run to launch the MCP server)",
3344
+ (yargs2) => yargs2,
3345
+ () => {
3346
+ cli.showHelp("log");
3222
3347
  }
3223
3348
  ).version(packageVersion).alias("version", "v").option("env-file", {
3224
3349
  type: "string",
3225
3350
  global: true,
3226
3351
  description: "Load environment variables from this exact file (error if missing; no implicit .env fallback)"
3227
- }).help().parse();
3352
+ }).epilog(
3353
+ `Management commands (single flags, dispatched before subcommands):
3354
+ --ver Print the installed version and force one update check
3355
+ --version Alias of --ver
3356
+ --upgrade Upgrade the global package to the latest version and refresh installed skills
3357
+ --uninstall Remove the globally installed mcp-google-map package`
3358
+ ).help();
3359
+ cli.parse();
3228
3360
  }
3229
3361
  }
3230
3362
  export {