midnight-mcp 0.2.2 → 0.2.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.
@@ -1594,7 +1594,7 @@ async function checkGitHubAPI() {
1594
1594
  }
1595
1595
  async function checkVectorStore() {
1596
1596
  try {
1597
- const { vectorStore: vectorStore2 } = await import("./db-YDGUWI5K.js");
1597
+ const { vectorStore: vectorStore2 } = await import("./db-K7ADM57F.js");
1598
1598
  if (vectorStore2) {
1599
1599
  return {
1600
1600
  status: "pass",
@@ -1899,6 +1899,39 @@ setInterval(pruneAllCaches, 5 * 60 * 1e3);
1899
1899
 
1900
1900
  // src/utils/hosted-api.ts
1901
1901
  var API_TIMEOUT = 1e4;
1902
+ function getActionableErrorMessage(status, endpoint, serverMessage) {
1903
+ const baseMessages = {
1904
+ 400: `Bad request to ${endpoint}. Check your query parameters are valid.`,
1905
+ 401: `Authentication failed. If you have an API key configured, verify it's correct.`,
1906
+ 403: `Access denied to ${endpoint}. This resource may require authentication.`,
1907
+ 404: `Resource not found at ${endpoint}. Use midnight-list-examples to see available resources.`,
1908
+ 408: `Request timed out. The hosted service may be under heavy load - try again in a moment.`,
1909
+ 429: `Rate limited. Try again in a few minutes, or set MIDNIGHT_LOCAL=true for unlimited local search (requires ChromaDB + OpenAI API key).`,
1910
+ 500: `Server error. This is temporary - try again shortly or report at github.com/Olanetsoft/midnight-mcp/issues`,
1911
+ 502: `Bad gateway. The hosted API may be restarting - try again in 30 seconds.`,
1912
+ 503: `Service temporarily unavailable. The hosted API may be under maintenance - try again later or use MIDNIGHT_LOCAL=true for local mode.`,
1913
+ 504: `Gateway timeout. The request took too long - try a simpler query or try again later.`
1914
+ };
1915
+ const actionableMessage = baseMessages[status] || `API error (${status}). Try again or report at github.com/Olanetsoft/midnight-mcp/issues`;
1916
+ if (serverMessage && !actionableMessage.includes(serverMessage)) {
1917
+ return `${actionableMessage} Server said: "${serverMessage}"`;
1918
+ }
1919
+ return actionableMessage;
1920
+ }
1921
+ async function parseApiError(response, endpoint) {
1922
+ let serverMessage;
1923
+ try {
1924
+ const errorData = await response.json();
1925
+ serverMessage = errorData.error || errorData.message;
1926
+ } catch {
1927
+ }
1928
+ const actionableMessage = getActionableErrorMessage(
1929
+ response.status,
1930
+ endpoint,
1931
+ serverMessage
1932
+ );
1933
+ return new Error(actionableMessage);
1934
+ }
1902
1935
  async function apiRequest(endpoint, options = {}) {
1903
1936
  const url = `${config.hostedApiUrl}${endpoint}`;
1904
1937
  const controller = new AbortController();
@@ -1914,14 +1947,21 @@ async function apiRequest(endpoint, options = {}) {
1914
1947
  }
1915
1948
  });
1916
1949
  if (!response.ok) {
1917
- const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
1918
- throw new Error(errorData.error || `API error: ${response.status}`);
1950
+ throw await parseApiError(response, endpoint);
1919
1951
  }
1920
1952
  return await response.json();
1921
1953
  } catch (error) {
1922
1954
  if (error instanceof Error && error.name === "AbortError") {
1923
1955
  throw new Error(
1924
- "API request timed out. The hosted service may be unavailable."
1956
+ `Request to ${endpoint} timed out after ${API_TIMEOUT / 1e3}s. The hosted service may be unavailable. Try again or set MIDNIGHT_LOCAL=true for local search.`
1957
+ );
1958
+ }
1959
+ if (error instanceof Error && error.message.includes("github.com/Olanetsoft")) {
1960
+ throw error;
1961
+ }
1962
+ if (error instanceof Error) {
1963
+ throw new Error(
1964
+ `Failed to connect to hosted API: ${error.message}. Check your internet connection or set MIDNIGHT_LOCAL=true for local search.`
1925
1965
  );
1926
1966
  }
1927
1967
  throw error;
@@ -1985,7 +2025,7 @@ function serialize(data) {
1985
2025
  }
1986
2026
 
1987
2027
  // src/utils/version.ts
1988
- var CURRENT_VERSION = "0.2.2";
2028
+ var CURRENT_VERSION = "0.2.4";
1989
2029
 
1990
2030
  // src/db/vectorStore.ts
1991
2031
  var VectorStore = class {
@@ -2194,4 +2234,4 @@ export {
2194
2234
  serialize,
2195
2235
  CURRENT_VERSION
2196
2236
  };
2197
- //# sourceMappingURL=chunk-HOWO4K5A.js.map
2237
+ //# sourceMappingURL=chunk-KB6HV57P.js.map
@@ -0,0 +1,7 @@
1
+ import {
2
+ vectorStore
3
+ } from "./chunk-KB6HV57P.js";
4
+ export {
5
+ vectorStore
6
+ };
7
+ //# sourceMappingURL=db-K7ADM57F.js.map
package/dist/index.js CHANGED
@@ -9,10 +9,10 @@ import {
9
9
  promptDefinitions,
10
10
  startHttpServer,
11
11
  startServer
12
- } from "./chunk-S7G4OHA4.js";
12
+ } from "./chunk-5DMOVW6Q.js";
13
13
  import {
14
14
  logger
15
- } from "./chunk-HOWO4K5A.js";
15
+ } from "./chunk-KB6HV57P.js";
16
16
  export {
17
17
  allResources,
18
18
  allTools,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "midnight-mcp",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Model Context Protocol Server for Midnight Blockchain Development",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,7 +0,0 @@
1
- import {
2
- vectorStore
3
- } from "./chunk-HOWO4K5A.js";
4
- export {
5
- vectorStore
6
- };
7
- //# sourceMappingURL=db-YDGUWI5K.js.map