mcp-google-api 0.22.0 → 0.23.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/CHANGELOG.md +164 -0
- package/README.md +33 -11
- package/bin/mcp-google-api.mjs +53 -0
- package/dist/cli.d.ts +8 -2
- package/dist/cli.js +211 -92
- package/dist/cli.js.map +1 -1
- package/docs/CONFIGURATION.md +22 -0
- package/package.json +6 -4
package/dist/cli.js
CHANGED
|
@@ -17,7 +17,6 @@ var DEFAULT_SETTINGS_ENABLED_TOOLS = "*";
|
|
|
17
17
|
var SETTINGS_PROGRAM_NAME = "mcp-google-api";
|
|
18
18
|
var CLI_SETTINGS_RELATIVE = [".config", SETTINGS_PROGRAM_NAME, "config.json"];
|
|
19
19
|
var MCP_SERVER_NAME = "mcp-google-api";
|
|
20
|
-
var INSTALL_API_KEY_PLACEHOLDER = "__RUN_mcp-google-api_api-key_TO_CONFIGURE_YOUR_API_KEY__";
|
|
21
20
|
function resolveCliSettingsPath(home) {
|
|
22
21
|
const root = home ?? (process.env.HOME ?? process.cwd());
|
|
23
22
|
return resolve(root, ...CLI_SETTINGS_RELATIVE);
|
|
@@ -53,7 +52,7 @@ function defaultSettings() {
|
|
|
53
52
|
};
|
|
54
53
|
}
|
|
55
54
|
function isUnsetApiKey(value) {
|
|
56
|
-
return value === void 0 || value === null || value.trim().length === 0
|
|
55
|
+
return value === void 0 || value === null || value.trim().length === 0;
|
|
57
56
|
}
|
|
58
57
|
function uniqueStrings(value) {
|
|
59
58
|
if (!Array.isArray(value)) return [];
|
|
@@ -1501,6 +1500,7 @@ var AUTO_UPDATE_DISABLED_ENV = "MCP_AUTO_UPDATE_DISABLED";
|
|
|
1501
1500
|
var DEFAULT_PACKAGE_NAME = "mcp-google-api";
|
|
1502
1501
|
var DEFAULT_REGISTRY_BASE_URL = "https://registry.npmjs.org";
|
|
1503
1502
|
var DEFAULT_UPDATE_CHECK_TIMEOUT_MS = 2e3;
|
|
1503
|
+
var DEFAULT_PACKUMENT_ACCEPT_HEADER = "application/vnd.npm.install-v1+json";
|
|
1504
1504
|
async function probeLatestVersion(deps = {}) {
|
|
1505
1505
|
const env = deps.env;
|
|
1506
1506
|
if (env !== void 0 && isAutoUpdateDisabled(env)) {
|
|
@@ -1541,6 +1541,48 @@ async function probeLatestVersion(deps = {}) {
|
|
|
1541
1541
|
return { status: "error", message };
|
|
1542
1542
|
}
|
|
1543
1543
|
}
|
|
1544
|
+
async function probeLatestManifestVersion(deps = {}) {
|
|
1545
|
+
const env = deps.env;
|
|
1546
|
+
if (env !== void 0 && isAutoUpdateDisabled(env)) {
|
|
1547
|
+
return { status: "disabled" };
|
|
1548
|
+
}
|
|
1549
|
+
const currentVersion = deps.currentVersion;
|
|
1550
|
+
if (!currentVersion) {
|
|
1551
|
+
return { status: "unknown-version" };
|
|
1552
|
+
}
|
|
1553
|
+
const packageName = deps.packageName ?? DEFAULT_PACKAGE_NAME;
|
|
1554
|
+
const registryBaseUrl = deps.registryBaseUrl ?? DEFAULT_REGISTRY_BASE_URL;
|
|
1555
|
+
const timeoutMs = deps.timeoutMs ?? DEFAULT_UPDATE_CHECK_TIMEOUT_MS;
|
|
1556
|
+
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
1557
|
+
try {
|
|
1558
|
+
const response = await fetchImpl(`${registryBaseUrl}/${packageName}`, {
|
|
1559
|
+
headers: { accept: DEFAULT_PACKUMENT_ACCEPT_HEADER },
|
|
1560
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
1561
|
+
});
|
|
1562
|
+
if (!response.ok) {
|
|
1563
|
+
return {
|
|
1564
|
+
status: "error",
|
|
1565
|
+
message: `registry manifest responded with HTTP ${response.status}.`
|
|
1566
|
+
};
|
|
1567
|
+
}
|
|
1568
|
+
const payload = await response.json();
|
|
1569
|
+
const distTags = payload?.["dist-tags"];
|
|
1570
|
+
const latest = distTags !== null && typeof distTags === "object" ? distTags.latest : void 0;
|
|
1571
|
+
if (typeof latest !== "string" || latest.trim() === "") {
|
|
1572
|
+
return {
|
|
1573
|
+
status: "error",
|
|
1574
|
+
message: "registry manifest has no dist-tags.latest field."
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
if (!isNewerVersion(latest, currentVersion)) {
|
|
1578
|
+
return { status: "current", currentVersion };
|
|
1579
|
+
}
|
|
1580
|
+
return { status: "newer", currentVersion, latestVersion: latest };
|
|
1581
|
+
} catch (error) {
|
|
1582
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1583
|
+
return { status: "error", message };
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1544
1586
|
function isAutoUpdateDisabled(env = process.env) {
|
|
1545
1587
|
const raw = env[AUTO_UPDATE_DISABLED_ENV];
|
|
1546
1588
|
return typeof raw === "string" && /^(1|true|yes)$/i.test(raw.trim());
|
|
@@ -1595,7 +1637,7 @@ async function probeLatestGitHubVersion(deps = {}) {
|
|
|
1595
1637
|
if (!version) {
|
|
1596
1638
|
return { status: "error", message: "GitHub release tag carries no version." };
|
|
1597
1639
|
}
|
|
1598
|
-
return { status: "ok", version };
|
|
1640
|
+
return { status: "ok", version, tag: payload.tag_name };
|
|
1599
1641
|
} catch (error) {
|
|
1600
1642
|
const message = error instanceof Error ? error.message : String(error);
|
|
1601
1643
|
return { status: "error", message };
|
|
@@ -1618,6 +1660,10 @@ var PACKAGE_UPGRADE_COMMAND = [
|
|
|
1618
1660
|
"-g",
|
|
1619
1661
|
`${DEFAULT_PACKAGE_NAME}@latest`
|
|
1620
1662
|
];
|
|
1663
|
+
var GITHUB_UPGRADE_REPOSITORY = "Ogekuri/mcp-google-api";
|
|
1664
|
+
function buildDevelopUpgradeCommand(tag) {
|
|
1665
|
+
return ["npm", "install", "-g", `github:${GITHUB_UPGRADE_REPOSITORY}#${tag}`];
|
|
1666
|
+
}
|
|
1621
1667
|
var PACKAGE_UNINSTALL_COMMAND = [
|
|
1622
1668
|
"npm",
|
|
1623
1669
|
"uninstall",
|
|
@@ -1724,15 +1770,25 @@ async function checkVersionIdle(deps = {}) {
|
|
|
1724
1770
|
return result;
|
|
1725
1771
|
}
|
|
1726
1772
|
function parseManagementCommand(args) {
|
|
1727
|
-
if (args.length
|
|
1773
|
+
if (args.length === 1) {
|
|
1774
|
+
const arg = args[0];
|
|
1775
|
+
if (arg === "--ver" || arg === "--version" || arg === "--upgrade" || arg === "--uninstall") {
|
|
1776
|
+
return arg;
|
|
1777
|
+
}
|
|
1728
1778
|
return void 0;
|
|
1729
1779
|
}
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1780
|
+
if (args.length === 2) {
|
|
1781
|
+
const hasUpgrade = args.includes("--upgrade");
|
|
1782
|
+
const hasDevelop = args.includes("--develop") || args.includes("--dev");
|
|
1783
|
+
if (hasUpgrade && hasDevelop) {
|
|
1784
|
+
return "--upgrade";
|
|
1785
|
+
}
|
|
1733
1786
|
}
|
|
1734
1787
|
return void 0;
|
|
1735
1788
|
}
|
|
1789
|
+
function parseUpgradeChannel(args) {
|
|
1790
|
+
return args.includes("--develop") || args.includes("--dev") ? "develop" : "npm";
|
|
1791
|
+
}
|
|
1736
1792
|
function runPackageManagerCommand(command, deps = {}) {
|
|
1737
1793
|
const logger = deps.logger ?? Logger;
|
|
1738
1794
|
const spawnImpl = deps.spawn ?? spawnSync;
|
|
@@ -1743,6 +1799,7 @@ function runPackageManagerCommand(command, deps = {}) {
|
|
|
1743
1799
|
};
|
|
1744
1800
|
try {
|
|
1745
1801
|
const result = spawnImpl(command[0], [...command.slice(1)], {
|
|
1802
|
+
cwd: homedir(),
|
|
1746
1803
|
stdio: "inherit",
|
|
1747
1804
|
shell: process.platform === "win32"
|
|
1748
1805
|
});
|
|
@@ -1755,6 +1812,50 @@ function runPackageManagerCommand(command, deps = {}) {
|
|
|
1755
1812
|
return reportSpawnFailure(message);
|
|
1756
1813
|
}
|
|
1757
1814
|
}
|
|
1815
|
+
var REIFY_ENOENT_SIGNATURE = /\bENOENT\b/;
|
|
1816
|
+
function toStreamText(value) {
|
|
1817
|
+
return typeof value === "string" ? value : value?.toString("utf8") ?? "";
|
|
1818
|
+
}
|
|
1819
|
+
function runCapturedPackageManagerCommand(command, deps) {
|
|
1820
|
+
const logger = deps.logger ?? Logger;
|
|
1821
|
+
const spawnImpl = deps.spawn ?? spawnSync;
|
|
1822
|
+
const reportSpawnFailure = (message) => {
|
|
1823
|
+
logger.error(`Error executing ${command[0]}: ${message}`);
|
|
1824
|
+
logger.log(`Warning: run this command manually: ${command.join(" ")}`);
|
|
1825
|
+
return { code: 1, stderr: "" };
|
|
1826
|
+
};
|
|
1827
|
+
try {
|
|
1828
|
+
const result = spawnImpl(command[0], [...command.slice(1)], {
|
|
1829
|
+
cwd: homedir(),
|
|
1830
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
1831
|
+
shell: process.platform === "win32",
|
|
1832
|
+
maxBuffer: 16 * 1024 * 1024
|
|
1833
|
+
});
|
|
1834
|
+
if (result.error) {
|
|
1835
|
+
return reportSpawnFailure(result.error.message);
|
|
1836
|
+
}
|
|
1837
|
+
const stdoutText = toStreamText(result.stdout).replace(/\n+$/, "");
|
|
1838
|
+
const stderrText = toStreamText(result.stderr).replace(/\n+$/, "");
|
|
1839
|
+
if (stdoutText.length > 0) {
|
|
1840
|
+
logger.log(stdoutText);
|
|
1841
|
+
}
|
|
1842
|
+
if (stderrText.length > 0) {
|
|
1843
|
+
logger.error(stderrText);
|
|
1844
|
+
}
|
|
1845
|
+
return { code: result.status ?? 1, stderr: toStreamText(result.stderr) };
|
|
1846
|
+
} catch (error) {
|
|
1847
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1848
|
+
return reportSpawnFailure(message);
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
function runPackageUpdateCommand(command, deps) {
|
|
1852
|
+
const first = runCapturedPackageManagerCommand(command, deps);
|
|
1853
|
+
if (first.code === 0 || !REIFY_ENOENT_SIGNATURE.test(first.stderr)) {
|
|
1854
|
+
return first.code;
|
|
1855
|
+
}
|
|
1856
|
+
runPackageManagerCommand(PACKAGE_UNINSTALL_COMMAND, deps);
|
|
1857
|
+
return runCapturedPackageManagerCommand(command, deps).code;
|
|
1858
|
+
}
|
|
1758
1859
|
function parsePostUpgradeCliOutcomes(raw) {
|
|
1759
1860
|
if (raw === void 0 || !raw.includes("install report:")) {
|
|
1760
1861
|
return void 0;
|
|
@@ -1853,7 +1954,7 @@ async function resolveUpdatedVersion(options, deps) {
|
|
|
1853
1954
|
}
|
|
1854
1955
|
async function runVersionCommand(options, deps = {}) {
|
|
1855
1956
|
const [npmProbe, githubProbe] = await Promise.all([
|
|
1856
|
-
|
|
1957
|
+
probeLatestManifestVersion({ ...deps.idleCheck, currentVersion: options.currentVersion }),
|
|
1857
1958
|
probeLatestGitHubVersion(deps.githubCheck)
|
|
1858
1959
|
]);
|
|
1859
1960
|
const installedVersion = options.currentVersion || "unknown";
|
|
@@ -1866,23 +1967,23 @@ GitHub latest: ${githubLatest}
|
|
|
1866
1967
|
`);
|
|
1867
1968
|
return 0;
|
|
1868
1969
|
}
|
|
1869
|
-
function isUpgradeNecessary(status) {
|
|
1870
|
-
return status !== "current";
|
|
1871
|
-
}
|
|
1872
1970
|
async function runUpgradeCommand(options, deps = {}) {
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1971
|
+
if ((options.channel ?? "npm") === "develop") {
|
|
1972
|
+
const githubProbe = await probeLatestGitHubVersion(deps.githubCheck);
|
|
1973
|
+
if (githubProbe.status !== "ok") {
|
|
1974
|
+
(deps.logger ?? Logger).error(`GitHub upgrade channel probe failed: ${githubProbe.message}`);
|
|
1975
|
+
return 1;
|
|
1976
|
+
}
|
|
1977
|
+
const upgraded2 = runPackageUpdateCommand(buildDevelopUpgradeCommand(githubProbe.tag), deps);
|
|
1978
|
+
if (upgraded2 !== 0) {
|
|
1979
|
+
return upgraded2;
|
|
1980
|
+
}
|
|
1981
|
+
const outcome2 = runPostUpgradeSkillInstall(options, deps);
|
|
1878
1982
|
const stdout2 = deps.stdout ?? process.stdout;
|
|
1879
|
-
stdout2.write(
|
|
1880
|
-
|
|
1881
|
-
`
|
|
1882
|
-
);
|
|
1883
|
-
return 0;
|
|
1983
|
+
stdout2.write(renderUpgradeSummary(options.currentVersion, githubProbe.version, outcome2));
|
|
1984
|
+
return outcome2.exitCode;
|
|
1884
1985
|
}
|
|
1885
|
-
const upgraded =
|
|
1986
|
+
const upgraded = runPackageUpdateCommand(PACKAGE_UPGRADE_COMMAND, deps);
|
|
1886
1987
|
if (upgraded !== 0) {
|
|
1887
1988
|
return upgraded;
|
|
1888
1989
|
}
|
|
@@ -2066,12 +2167,19 @@ var CLAUDE_TARGET = {
|
|
|
2066
2167
|
mcpConfigPath: (home) => join3(homeRoot(home), ".claude.json"),
|
|
2067
2168
|
skillsDir: (home) => join3(homeRoot(home), ".claude", "skills")
|
|
2068
2169
|
};
|
|
2170
|
+
var COPILOT_TARGET = {
|
|
2171
|
+
id: "copilot",
|
|
2172
|
+
configFormat: "json",
|
|
2173
|
+
mcpConfigPath: (home) => join3(homeRoot(home), ".copilot", "mcp.json"),
|
|
2174
|
+
skillsDir: (home) => join3(homeRoot(home), ".copilot", "skills")
|
|
2175
|
+
};
|
|
2069
2176
|
var CLI_TARGETS = {
|
|
2070
2177
|
pi: PI_TARGET,
|
|
2071
2178
|
openclaw: OPENCLAW_TARGET,
|
|
2072
2179
|
codex: CODEX_TARGET,
|
|
2073
2180
|
antigravity: ANTIGRAVITY_TARGET,
|
|
2074
|
-
claude: CLAUDE_TARGET
|
|
2181
|
+
claude: CLAUDE_TARGET,
|
|
2182
|
+
copilot: COPILOT_TARGET
|
|
2075
2183
|
};
|
|
2076
2184
|
function resolveCliTarget(name) {
|
|
2077
2185
|
return CLI_TARGETS[name.trim().toLowerCase()];
|
|
@@ -2570,24 +2678,24 @@ function installShutdownHandlers(servers) {
|
|
|
2570
2678
|
process.on("SIGTERM", () => void handler("SIGTERM"));
|
|
2571
2679
|
}
|
|
2572
2680
|
var EXEC_TOOLS = [
|
|
2573
|
-
"
|
|
2574
|
-
"
|
|
2575
|
-
"
|
|
2576
|
-
"
|
|
2577
|
-
"
|
|
2578
|
-
"
|
|
2579
|
-
"
|
|
2580
|
-
"
|
|
2581
|
-
"
|
|
2582
|
-
"
|
|
2583
|
-
"
|
|
2584
|
-
"
|
|
2585
|
-
"
|
|
2586
|
-
"
|
|
2587
|
-
"
|
|
2588
|
-
"
|
|
2589
|
-
"
|
|
2590
|
-
"
|
|
2681
|
+
"maps_geocode",
|
|
2682
|
+
"maps_reverse_geocode",
|
|
2683
|
+
"maps_search_nearby",
|
|
2684
|
+
"maps_search_places",
|
|
2685
|
+
"maps_place_details",
|
|
2686
|
+
"maps_directions",
|
|
2687
|
+
"maps_distance_matrix",
|
|
2688
|
+
"maps_elevation",
|
|
2689
|
+
"maps_timezone",
|
|
2690
|
+
"maps_weather",
|
|
2691
|
+
"maps_explore_area",
|
|
2692
|
+
"maps_plan_route",
|
|
2693
|
+
"maps_compare_places",
|
|
2694
|
+
"maps_air_quality",
|
|
2695
|
+
"maps_static_map",
|
|
2696
|
+
"maps_batch_geocode",
|
|
2697
|
+
"maps_search_along_route",
|
|
2698
|
+
"maps_local_rank_tracker"
|
|
2591
2699
|
];
|
|
2592
2700
|
function isExecFailureResponse(result) {
|
|
2593
2701
|
return typeof result === "object" && result !== null && "success" in result && result.success === false;
|
|
@@ -2604,17 +2712,12 @@ function getExecFailureMessage(toolName, result) {
|
|
|
2604
2712
|
async function execTool(toolName, params, apiKey) {
|
|
2605
2713
|
const searcher = new PlacesSearcher(apiKey);
|
|
2606
2714
|
switch (toolName) {
|
|
2607
|
-
case "geocode":
|
|
2608
2715
|
case "maps_geocode":
|
|
2609
2716
|
return searcher.geocode(params.address);
|
|
2610
|
-
case "reverse-geocode":
|
|
2611
2717
|
case "maps_reverse_geocode":
|
|
2612
2718
|
return searcher.reverseGeocode(params.latitude, params.longitude);
|
|
2613
|
-
case "search-nearby":
|
|
2614
|
-
case "search_nearby":
|
|
2615
2719
|
case "maps_search_nearby":
|
|
2616
2720
|
return searcher.searchNearby(params);
|
|
2617
|
-
case "search-places":
|
|
2618
2721
|
case "maps_search_places":
|
|
2619
2722
|
return searcher.searchText({
|
|
2620
2723
|
query: params.query,
|
|
@@ -2629,11 +2732,8 @@ async function execTool(toolName, params, apiKey) {
|
|
|
2629
2732
|
languageCode: params.languageCode,
|
|
2630
2733
|
includeRaw: params.includeRaw
|
|
2631
2734
|
});
|
|
2632
|
-
case "place-details":
|
|
2633
|
-
case "get_place_details":
|
|
2634
2735
|
case "maps_place_details":
|
|
2635
2736
|
return searcher.getPlaceDetails(params.placeId, params.maxPhotos || 0, params.includeRaw || false);
|
|
2636
|
-
case "directions":
|
|
2637
2737
|
case "maps_directions":
|
|
2638
2738
|
return searcher.getDirections(
|
|
2639
2739
|
params.origin,
|
|
@@ -2644,7 +2744,6 @@ async function execTool(toolName, params, apiKey) {
|
|
|
2644
2744
|
params.avoid_tolls,
|
|
2645
2745
|
params.avoid_highways
|
|
2646
2746
|
);
|
|
2647
|
-
case "distance-matrix":
|
|
2648
2747
|
case "maps_distance_matrix":
|
|
2649
2748
|
return searcher.calculateDistanceMatrix(
|
|
2650
2749
|
params.origins,
|
|
@@ -2654,13 +2753,10 @@ async function execTool(toolName, params, apiKey) {
|
|
|
2654
2753
|
params.avoid_tolls,
|
|
2655
2754
|
params.avoid_highways
|
|
2656
2755
|
);
|
|
2657
|
-
case "elevation":
|
|
2658
2756
|
case "maps_elevation":
|
|
2659
2757
|
return searcher.getElevation(params.locations);
|
|
2660
|
-
case "timezone":
|
|
2661
2758
|
case "maps_timezone":
|
|
2662
2759
|
return searcher.getTimezone(params.latitude, params.longitude, params.timestamp);
|
|
2663
|
-
case "weather":
|
|
2664
2760
|
case "maps_weather":
|
|
2665
2761
|
return searcher.getWeather(
|
|
2666
2762
|
params.latitude,
|
|
@@ -2669,16 +2765,12 @@ async function execTool(toolName, params, apiKey) {
|
|
|
2669
2765
|
params.forecastDays,
|
|
2670
2766
|
params.forecastHours
|
|
2671
2767
|
);
|
|
2672
|
-
case "explore-area":
|
|
2673
2768
|
case "maps_explore_area":
|
|
2674
2769
|
return searcher.exploreArea(params);
|
|
2675
|
-
case "plan-route":
|
|
2676
2770
|
case "maps_plan_route":
|
|
2677
2771
|
return searcher.planRoute(params);
|
|
2678
|
-
case "compare-places":
|
|
2679
2772
|
case "maps_compare_places":
|
|
2680
2773
|
return searcher.comparePlaces(params);
|
|
2681
|
-
case "air-quality":
|
|
2682
2774
|
case "maps_air_quality":
|
|
2683
2775
|
return searcher.getAirQuality(
|
|
2684
2776
|
params.latitude,
|
|
@@ -2686,10 +2778,8 @@ async function execTool(toolName, params, apiKey) {
|
|
|
2686
2778
|
params.includeHealthRecommendations,
|
|
2687
2779
|
params.includePollutants
|
|
2688
2780
|
);
|
|
2689
|
-
case "static-map":
|
|
2690
2781
|
case "maps_static_map":
|
|
2691
2782
|
return searcher.getStaticMap(params);
|
|
2692
|
-
case "batch-geocode-tool":
|
|
2693
2783
|
case "maps_batch_geocode": {
|
|
2694
2784
|
const results = await Promise.all(
|
|
2695
2785
|
params.addresses.map(async (address) => {
|
|
@@ -2707,10 +2797,8 @@ async function execTool(toolName, params, apiKey) {
|
|
|
2707
2797
|
data: { total: params.addresses.length, succeeded, failed: params.addresses.length - succeeded, results }
|
|
2708
2798
|
};
|
|
2709
2799
|
}
|
|
2710
|
-
case "search-along-route":
|
|
2711
2800
|
case "maps_search_along_route":
|
|
2712
2801
|
return searcher.searchAlongRoute(params);
|
|
2713
|
-
case "local-rank-tracker":
|
|
2714
2802
|
case "maps_local_rank_tracker":
|
|
2715
2803
|
return searcher.localRankTracker(params);
|
|
2716
2804
|
default:
|
|
@@ -2734,12 +2822,12 @@ async function runExecCommand(toolName, params, apiKey, runner = execTool, strea
|
|
|
2734
2822
|
}
|
|
2735
2823
|
}
|
|
2736
2824
|
var DOCTOR_PROBES = [
|
|
2737
|
-
{ id: "geocoding", name: "geocoding-api", tool: "
|
|
2738
|
-
{ id: "places-new", name: "places-api-new", tool: "
|
|
2825
|
+
{ id: "geocoding", name: "geocoding-api", tool: "maps_geocode", params: { address: "Tokyo Tower" } },
|
|
2826
|
+
{ id: "places-new", name: "places-api-new", tool: "maps_search_places", params: { query: "Tokyo Tower" } },
|
|
2739
2827
|
{
|
|
2740
2828
|
id: "routes",
|
|
2741
2829
|
name: "routes-api",
|
|
2742
|
-
tool: "
|
|
2830
|
+
tool: "maps_directions",
|
|
2743
2831
|
params: { origin: "Tokyo Tower", destination: "Tokyo Station", mode: "walking" }
|
|
2744
2832
|
}
|
|
2745
2833
|
];
|
|
@@ -3112,9 +3200,34 @@ function isEntryMainModule() {
|
|
|
3112
3200
|
return false;
|
|
3113
3201
|
}
|
|
3114
3202
|
}
|
|
3115
|
-
|
|
3203
|
+
function describeUndispatchedServerStart(args) {
|
|
3204
|
+
const isServerStart = (args.includes("start") || args.includes("run")) && args.includes("--stdio");
|
|
3205
|
+
if (!isServerStart) {
|
|
3206
|
+
return void 0;
|
|
3207
|
+
}
|
|
3208
|
+
return "CLI dispatch was skipped for this server-start launch: the running artifact is not the mcp-google-api entrypoint (stale build after a distribution rename). Rebuild the local artifact with 'npm run build' (or 'npm run verify'), or refresh the global installation with 'npm install -g mcp-google-api@latest', then reconnect the MCP client.";
|
|
3209
|
+
}
|
|
3210
|
+
function handleUndispatchedEntry(args, streams = process) {
|
|
3211
|
+
const error = describeUndispatchedServerStart(args);
|
|
3212
|
+
if (error === void 0) {
|
|
3213
|
+
return 0;
|
|
3214
|
+
}
|
|
3215
|
+
streams.stderr.write(
|
|
3216
|
+
JSON.stringify(
|
|
3217
|
+
{
|
|
3218
|
+
error,
|
|
3219
|
+
requestedEntry: process.argv[1] ?? null,
|
|
3220
|
+
modulePath: fileURLToPath(import.meta.url),
|
|
3221
|
+
remediation: ["npm run build", "npm install -g mcp-google-api@latest"]
|
|
3222
|
+
},
|
|
3223
|
+
null,
|
|
3224
|
+
2
|
|
3225
|
+
) + "\n"
|
|
3226
|
+
);
|
|
3227
|
+
return 1;
|
|
3228
|
+
}
|
|
3116
3229
|
var isMainModule = isEntryMainModule();
|
|
3117
|
-
if (
|
|
3230
|
+
if (isMainModule) {
|
|
3118
3231
|
let packageVersion = "0.0.0";
|
|
3119
3232
|
try {
|
|
3120
3233
|
const packageJsonPath = resolve5(__dirname, "../package.json");
|
|
@@ -3125,7 +3238,8 @@ if (isRunDirectly || isMainModule) {
|
|
|
3125
3238
|
}
|
|
3126
3239
|
const managementCommand = parseManagementCommand(hideBin(process.argv));
|
|
3127
3240
|
if (managementCommand !== void 0) {
|
|
3128
|
-
|
|
3241
|
+
const upgradeChannel = parseUpgradeChannel(hideBin(process.argv));
|
|
3242
|
+
void runManagementCommand(managementCommand, { currentVersion: packageVersion, channel: upgradeChannel }).then((code) => {
|
|
3129
3243
|
process.exitCode = code;
|
|
3130
3244
|
}).catch((error) => {
|
|
3131
3245
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -3138,11 +3252,11 @@ if (isRunDirectly || isMainModule) {
|
|
|
3138
3252
|
return yargs2.option("port", {
|
|
3139
3253
|
alias: "p",
|
|
3140
3254
|
type: "number",
|
|
3141
|
-
description: "Port to run the MCP server on (default:
|
|
3255
|
+
description: "Port to run the MCP server on (default: configured 'port' setting or 3000)",
|
|
3142
3256
|
default: settings.port
|
|
3143
3257
|
}).option("host", {
|
|
3144
3258
|
type: "string",
|
|
3145
|
-
description: "Hostname to bind the server to (default:
|
|
3259
|
+
description: "Hostname to bind the server to (default: configured 'host' setting or 127.0.0.1; 0.0.0.0 for all interfaces)",
|
|
3146
3260
|
default: settings.host
|
|
3147
3261
|
}).option("stdio", {
|
|
3148
3262
|
type: "boolean",
|
|
@@ -3215,7 +3329,7 @@ Usage: mcp-google-api <command> [options]
|
|
|
3215
3329
|
}).option("apikey", {
|
|
3216
3330
|
alias: "k",
|
|
3217
3331
|
type: "string",
|
|
3218
|
-
description: "Google Maps API key override for live probes (default:
|
|
3332
|
+
description: "Google Maps API key override for live probes (default: configured api-key setting)"
|
|
3219
3333
|
}).example([
|
|
3220
3334
|
["$0 doctor", "Check local runtime and API key configuration without network calls"],
|
|
3221
3335
|
["$0 doctor --live", "Also verify three Google Maps APIs with billable requests"],
|
|
@@ -3256,7 +3370,7 @@ Usage: mcp-google-api <command> [options]
|
|
|
3256
3370
|
description: "stdio launcher command"
|
|
3257
3371
|
}).option("command", {
|
|
3258
3372
|
type: "string",
|
|
3259
|
-
description: "Absolute path to
|
|
3373
|
+
description: "Absolute path to the CLI entry script (required for --launcher node)"
|
|
3260
3374
|
}).option("host", {
|
|
3261
3375
|
type: "string",
|
|
3262
3376
|
default: "127.0.0.1",
|
|
@@ -3293,7 +3407,7 @@ Usage: mcp-google-api <command> [options]
|
|
|
3293
3407
|
describe: `CLI name: ${supportedCliNames()}`
|
|
3294
3408
|
}).option("home", {
|
|
3295
3409
|
type: "string",
|
|
3296
|
-
description: "Home-directory override
|
|
3410
|
+
description: "Home-directory override (default: user home)"
|
|
3297
3411
|
}).example([["$0 enable pi", "Enable pi for install/uninstall/show"]]),
|
|
3298
3412
|
(argv) => {
|
|
3299
3413
|
process.exitCode = runEnableDisableCliCommand(argv.cli, true, {
|
|
@@ -3308,7 +3422,7 @@ Usage: mcp-google-api <command> [options]
|
|
|
3308
3422
|
describe: `CLI name: ${supportedCliNames()}`
|
|
3309
3423
|
}).option("home", {
|
|
3310
3424
|
type: "string",
|
|
3311
|
-
description: "Home-directory override
|
|
3425
|
+
description: "Home-directory override (default: user home)"
|
|
3312
3426
|
}).example([["$0 disable claude", "Disable claude for install/uninstall/show"]]),
|
|
3313
3427
|
(argv) => {
|
|
3314
3428
|
process.exitCode = runEnableDisableCliCommand(argv.cli, false, {
|
|
@@ -3317,16 +3431,16 @@ Usage: mcp-google-api <command> [options]
|
|
|
3317
3431
|
}
|
|
3318
3432
|
).command(
|
|
3319
3433
|
"auto-update <state>",
|
|
3320
|
-
"Enable or disable the automatic update check
|
|
3434
|
+
"Enable or disable the automatic update check at startup",
|
|
3321
3435
|
(yargs2) => yargs2.positional("state", {
|
|
3322
3436
|
type: "string",
|
|
3323
3437
|
describe: "New state: enable or disable (1 and 0 accepted)"
|
|
3324
3438
|
}).option("home", {
|
|
3325
3439
|
type: "string",
|
|
3326
|
-
description: "Home-directory override
|
|
3440
|
+
description: "Home-directory override (default: user home)"
|
|
3327
3441
|
}).example([[
|
|
3328
3442
|
"$0 auto-update disable",
|
|
3329
|
-
"Disable the automatic update check
|
|
3443
|
+
"Disable the automatic update check"
|
|
3330
3444
|
]]),
|
|
3331
3445
|
(argv) => {
|
|
3332
3446
|
process.exitCode = runAutoUpdateCommand(argv.state, {
|
|
@@ -3335,13 +3449,13 @@ Usage: mcp-google-api <command> [options]
|
|
|
3335
3449
|
}
|
|
3336
3450
|
).command(
|
|
3337
3451
|
"tools <tools>",
|
|
3338
|
-
"
|
|
3452
|
+
"Set the enabled tools ('*' = all 18 tools)",
|
|
3339
3453
|
(yargs2) => yargs2.positional("tools", {
|
|
3340
3454
|
type: "string",
|
|
3341
3455
|
describe: "Comma-separated tool names (e.g. maps_geocode,maps_search_places) or '*' for all"
|
|
3342
3456
|
}).option("home", {
|
|
3343
3457
|
type: "string",
|
|
3344
|
-
description: "Home-directory override
|
|
3458
|
+
description: "Home-directory override (default: user home)"
|
|
3345
3459
|
}).example([
|
|
3346
3460
|
["$0 tools '*'", "Expose every registered tool (default)"],
|
|
3347
3461
|
["$0 tools maps_geocode,maps_search_places", "Expose only the named tools"]
|
|
@@ -3353,13 +3467,13 @@ Usage: mcp-google-api <command> [options]
|
|
|
3353
3467
|
}
|
|
3354
3468
|
).command(
|
|
3355
3469
|
"host <host>",
|
|
3356
|
-
"
|
|
3470
|
+
"Set the HTTP bind host (default 127.0.0.1)",
|
|
3357
3471
|
(yargs2) => yargs2.positional("host", {
|
|
3358
3472
|
type: "string",
|
|
3359
3473
|
describe: "Bind hostname (e.g. 127.0.0.1 loopback; 0.0.0.0 for all interfaces)"
|
|
3360
3474
|
}).option("home", {
|
|
3361
3475
|
type: "string",
|
|
3362
|
-
description: "Home-directory override
|
|
3476
|
+
description: "Home-directory override (default: user home)"
|
|
3363
3477
|
}).example([["$0 host 0.0.0.0", "Bind the HTTP server on all interfaces"]]),
|
|
3364
3478
|
(argv) => {
|
|
3365
3479
|
process.exitCode = runHostCommand(argv.host, {
|
|
@@ -3368,13 +3482,13 @@ Usage: mcp-google-api <command> [options]
|
|
|
3368
3482
|
}
|
|
3369
3483
|
).command(
|
|
3370
3484
|
"port <port>",
|
|
3371
|
-
"
|
|
3485
|
+
"Set the HTTP listen port (default 3000)",
|
|
3372
3486
|
(yargs2) => yargs2.positional("port", {
|
|
3373
3487
|
type: "number",
|
|
3374
3488
|
describe: "Listen port (integer 1-65535)"
|
|
3375
3489
|
}).option("home", {
|
|
3376
3490
|
type: "string",
|
|
3377
|
-
description: "Home-directory override
|
|
3491
|
+
description: "Home-directory override (default: user home)"
|
|
3378
3492
|
}).example([["$0 port 3100", "Serve Streamable HTTP on port 3100"]]),
|
|
3379
3493
|
(argv) => {
|
|
3380
3494
|
process.exitCode = runPortCommand(argv.port === void 0 ? void 0 : String(argv.port), {
|
|
@@ -3383,13 +3497,13 @@ Usage: mcp-google-api <command> [options]
|
|
|
3383
3497
|
}
|
|
3384
3498
|
).command(
|
|
3385
3499
|
"api-key <key>",
|
|
3386
|
-
"Save the Google Maps API key
|
|
3500
|
+
"Save the Google Maps API key and refresh every enabled CLI registration",
|
|
3387
3501
|
(yargs2) => yargs2.positional("key", {
|
|
3388
3502
|
type: "string",
|
|
3389
3503
|
describe: "Google Maps API key (20-50 characters: letters, digits, hyphens, underscores)"
|
|
3390
3504
|
}).option("home", {
|
|
3391
3505
|
type: "string",
|
|
3392
|
-
description: "Home-directory override
|
|
3506
|
+
description: "Home-directory override (default: user home)"
|
|
3393
3507
|
}).example([["$0 api-key AIzaSy...", "Save the key and reinstall every enabled CLI"]]),
|
|
3394
3508
|
(argv) => {
|
|
3395
3509
|
process.exitCode = runApiKeyCommand(argv.key, {
|
|
@@ -3402,7 +3516,7 @@ Usage: mcp-google-api <command> [options]
|
|
|
3402
3516
|
"Register the mcp-google-api stdio server and install packaged skills for every enabled CLI",
|
|
3403
3517
|
(yargs2) => yargs2.option("home", {
|
|
3404
3518
|
type: "string",
|
|
3405
|
-
description: "Home-directory override
|
|
3519
|
+
description: "Home-directory override (default: user home)"
|
|
3406
3520
|
}).option("debug-skills", {
|
|
3407
3521
|
type: "boolean",
|
|
3408
3522
|
description: "Append each skill's packaged debug overlay to the installed SKILL.md",
|
|
@@ -3423,7 +3537,7 @@ Usage: mcp-google-api <command> [options]
|
|
|
3423
3537
|
"Remove the mcp-google-api server entry and managed skills from every enabled CLI",
|
|
3424
3538
|
(yargs2) => yargs2.option("home", {
|
|
3425
3539
|
type: "string",
|
|
3426
|
-
description: "Home-directory override
|
|
3540
|
+
description: "Home-directory override (default: user home)"
|
|
3427
3541
|
}).example([["$0 uninstall", "Reciprocal removal of install for every enabled CLI"]]),
|
|
3428
3542
|
(argv) => {
|
|
3429
3543
|
process.exitCode = runInstallUninstallCommand("uninstall", {
|
|
@@ -3436,7 +3550,7 @@ Usage: mcp-google-api <command> [options]
|
|
|
3436
3550
|
"Show CLI configuration and installation status tables (human-readable)",
|
|
3437
3551
|
(yargs2) => yargs2.option("home", {
|
|
3438
3552
|
type: "string",
|
|
3439
|
-
description: "Home-directory override
|
|
3553
|
+
description: "Home-directory override (default: user home)"
|
|
3440
3554
|
}).example([["$0 show", "Print CLI Configuration and Installation Status tables"]]),
|
|
3441
3555
|
(argv) => {
|
|
3442
3556
|
process.exitCode = runShowCommand({
|
|
@@ -3455,12 +3569,12 @@ Usage: mcp-google-api <command> [options]
|
|
|
3455
3569
|
type: "string",
|
|
3456
3570
|
describe: "JSON parameters string"
|
|
3457
3571
|
}).example([
|
|
3458
|
-
[`$0 exec
|
|
3572
|
+
[`$0 exec maps_geocode '{"address":"Tokyo Tower"}'`, "Geocode an address"],
|
|
3459
3573
|
[
|
|
3460
|
-
`$0 exec
|
|
3574
|
+
`$0 exec maps_search_nearby '{"center":{"value":"35.68,139.74","isCoordinates":true},"keyword":"restaurant"}'`,
|
|
3461
3575
|
"Search nearby"
|
|
3462
3576
|
],
|
|
3463
|
-
[`$0 exec
|
|
3577
|
+
[`$0 exec maps_search_places '{"query":"ramen in Tokyo"}'`, "Text search"]
|
|
3464
3578
|
]);
|
|
3465
3579
|
},
|
|
3466
3580
|
async (argv) => {
|
|
@@ -3597,20 +3711,25 @@ Usage: mcp-google-api <command> [options]
|
|
|
3597
3711
|
cli.showHelp("log");
|
|
3598
3712
|
}
|
|
3599
3713
|
).version(packageVersion).alias("version", "v").epilog(
|
|
3600
|
-
`Management commands (single flags
|
|
3601
|
-
--ver Print the installed
|
|
3714
|
+
`Management commands (single flags):
|
|
3715
|
+
--ver Print the installed, npmjs-latest, and GitHub-latest versions
|
|
3602
3716
|
--version Alias of --ver
|
|
3603
3717
|
--upgrade Upgrade the global package to the latest version and refresh installed skills
|
|
3718
|
+
--develop | --dev: install the latest tagged GitHub release (any branch)
|
|
3604
3719
|
--uninstall Remove the globally installed mcp-google-api package`
|
|
3605
3720
|
).help();
|
|
3606
3721
|
cli.parse();
|
|
3607
3722
|
}
|
|
3723
|
+
} else {
|
|
3724
|
+
process.exitCode = handleUndispatchedEntry(process.argv.slice(2));
|
|
3608
3725
|
}
|
|
3609
3726
|
export {
|
|
3610
3727
|
DOCTOR_PROBES,
|
|
3611
3728
|
EXEC_TOOLS,
|
|
3612
3729
|
createShutdownHandler,
|
|
3730
|
+
describeUndispatchedServerStart,
|
|
3613
3731
|
execTool,
|
|
3732
|
+
handleUndispatchedEntry,
|
|
3614
3733
|
installShutdownHandlers,
|
|
3615
3734
|
parseDoctorProbes,
|
|
3616
3735
|
runApiKeyCommand,
|