midnight-mcp 0.1.8 → 0.1.10

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.
@@ -25,6 +25,72 @@ export declare const ErrorCodes: {
25
25
  readonly PARSE_ERROR: "PARSE_ERROR";
26
26
  readonly CHROMADB_UNAVAILABLE: "CHROMADB_UNAVAILABLE";
27
27
  readonly OPENAI_UNAVAILABLE: "OPENAI_UNAVAILABLE";
28
+ readonly MISSING_PARAM: "MISSING_PARAMETER";
29
+ readonly INVALID_VERSION: "INVALID_VERSION";
30
+ readonly SAMPLING_UNAVAILABLE: "SAMPLING_UNAVAILABLE";
31
+ };
32
+ /**
33
+ * LLM-friendly error hints that help the model self-correct
34
+ * These are designed to give the AI enough context to retry with corrected input
35
+ */
36
+ export declare const SelfCorrectionHints: {
37
+ UNKNOWN_REPO: (repo: string, validRepos: string[]) => {
38
+ error: string;
39
+ code: "UNKNOWN_REPOSITORY";
40
+ suggestion: string;
41
+ correction: {
42
+ invalidValue: string;
43
+ validValues: string[];
44
+ parameterName: string;
45
+ };
46
+ };
47
+ INVALID_VERSION: (version: string, example: string) => {
48
+ error: string;
49
+ code: "INVALID_VERSION";
50
+ suggestion: string;
51
+ correction: {
52
+ invalidValue: string;
53
+ expectedFormat: string;
54
+ example: string;
55
+ };
56
+ };
57
+ MISSING_REQUIRED_PARAM: (paramName: string, toolName: string) => {
58
+ error: string;
59
+ code: "MISSING_PARAMETER";
60
+ suggestion: string;
61
+ correction: {
62
+ missingParameter: string;
63
+ tool: string;
64
+ };
65
+ };
66
+ FILE_NOT_FOUND: (path: string, repo: string, similarPaths?: string[]) => {
67
+ error: string;
68
+ code: "RESOURCE_NOT_FOUND";
69
+ suggestion: string;
70
+ correction: {
71
+ suggestions?: string[] | undefined;
72
+ invalidPath: string;
73
+ };
74
+ };
75
+ SAMPLING_NOT_AVAILABLE: (toolName: string) => {
76
+ error: string;
77
+ code: "SAMPLING_UNAVAILABLE";
78
+ suggestion: string;
79
+ alternatives: {
80
+ "midnight-generate-contract": string;
81
+ "midnight-review-contract": string;
82
+ "midnight-document-contract": string;
83
+ };
84
+ };
85
+ RATE_LIMIT: (retryAfter?: number) => {
86
+ error: string;
87
+ code: "RATE_LIMIT_EXCEEDED";
88
+ suggestion: string;
89
+ correction: {
90
+ retryAfterSeconds?: number | undefined;
91
+ action: string;
92
+ };
93
+ };
28
94
  };
29
95
  /**
30
96
  * Create user-friendly error from various error types
@@ -33,6 +33,76 @@ export const ErrorCodes = {
33
33
  PARSE_ERROR: "PARSE_ERROR",
34
34
  CHROMADB_UNAVAILABLE: "CHROMADB_UNAVAILABLE",
35
35
  OPENAI_UNAVAILABLE: "OPENAI_UNAVAILABLE",
36
+ MISSING_PARAM: "MISSING_PARAMETER",
37
+ INVALID_VERSION: "INVALID_VERSION",
38
+ SAMPLING_UNAVAILABLE: "SAMPLING_UNAVAILABLE",
39
+ };
40
+ /**
41
+ * LLM-friendly error hints that help the model self-correct
42
+ * These are designed to give the AI enough context to retry with corrected input
43
+ */
44
+ export const SelfCorrectionHints = {
45
+ UNKNOWN_REPO: (repo, validRepos) => ({
46
+ error: `Unknown repository: '${repo}'`,
47
+ code: ErrorCodes.UNKNOWN_REPO,
48
+ suggestion: `Try one of these instead: ${validRepos.slice(0, 8).join(", ")}`,
49
+ correction: {
50
+ invalidValue: repo,
51
+ validValues: validRepos,
52
+ parameterName: "repo",
53
+ },
54
+ }),
55
+ INVALID_VERSION: (version, example) => ({
56
+ error: `Invalid version format: '${version}'`,
57
+ code: ErrorCodes.INVALID_VERSION,
58
+ suggestion: `Version should be like '${example}'. Check available versions with midnight-get-version-info first.`,
59
+ correction: {
60
+ invalidValue: version,
61
+ expectedFormat: "v1.0.0 or 0.14.0",
62
+ example,
63
+ },
64
+ }),
65
+ MISSING_REQUIRED_PARAM: (paramName, toolName) => ({
66
+ error: `Missing required parameter: '${paramName}'`,
67
+ code: ErrorCodes.MISSING_PARAM,
68
+ suggestion: `The '${paramName}' parameter is required for ${toolName}. Please provide it.`,
69
+ correction: {
70
+ missingParameter: paramName,
71
+ tool: toolName,
72
+ },
73
+ }),
74
+ FILE_NOT_FOUND: (path, repo, similarPaths) => ({
75
+ error: `File not found: '${path}' in ${repo}`,
76
+ code: ErrorCodes.NOT_FOUND,
77
+ suggestion: similarPaths?.length
78
+ ? `Did you mean: ${similarPaths.join(", ")}?`
79
+ : `Check the file path. Use midnight-get-file with a different path or list directory contents first.`,
80
+ correction: {
81
+ invalidPath: path,
82
+ ...(similarPaths && { suggestions: similarPaths }),
83
+ },
84
+ }),
85
+ SAMPLING_NOT_AVAILABLE: (toolName) => ({
86
+ error: `Sampling capability not available`,
87
+ code: ErrorCodes.SAMPLING_UNAVAILABLE,
88
+ suggestion: `${toolName} requires a client that supports sampling (e.g., Claude Desktop). Use a non-AI alternative or switch clients.`,
89
+ alternatives: {
90
+ "midnight-generate-contract": "Use midnight-search-compact to find similar contracts as templates",
91
+ "midnight-review-contract": "Use midnight-analyze-contract for static analysis",
92
+ "midnight-document-contract": "Manual documentation or inline comments",
93
+ },
94
+ }),
95
+ RATE_LIMIT: (retryAfter) => ({
96
+ error: "GitHub API rate limit exceeded",
97
+ code: ErrorCodes.RATE_LIMIT,
98
+ suggestion: retryAfter
99
+ ? `Wait ${retryAfter} seconds before retrying. Or add GITHUB_TOKEN for higher limits.`
100
+ : "Add GITHUB_TOKEN to increase from 60 to 5000 requests/hour.",
101
+ correction: {
102
+ action: "wait_and_retry",
103
+ ...(retryAfter && { retryAfterSeconds: retryAfter }),
104
+ },
105
+ }),
36
106
  };
37
107
  /**
38
108
  * Create user-friendly error from various error types
@@ -2,7 +2,7 @@ export { config, isHostedMode, isLocalMode } from "./config.js";
2
2
  export type { Config, RepositoryConfig } from "./config.js";
3
3
  export { DEFAULT_REPOSITORIES } from "./config.js";
4
4
  export { logger } from "./logger.js";
5
- export { MCPError, ErrorCodes, createUserError, formatErrorResponse, withErrorHandling, } from "./errors.js";
5
+ export { MCPError, ErrorCodes, createUserError, formatErrorResponse, withErrorHandling, SelfCorrectionHints, } from "./errors.js";
6
6
  export { validateQuery, validateRepository, validatePath, validateRef, validateNumber, validateToolArgs, sanitizeString, } from "./validation.js";
7
7
  export type { ValidationResult } from "./validation.js";
8
8
  export { getHealthStatus, getQuickHealthStatus } from "./health.js";
@@ -1,7 +1,7 @@
1
1
  export { config, isHostedMode, isLocalMode } from "./config.js";
2
2
  export { DEFAULT_REPOSITORIES } from "./config.js";
3
3
  export { logger } from "./logger.js";
4
- export { MCPError, ErrorCodes, createUserError, formatErrorResponse, withErrorHandling, } from "./errors.js";
4
+ export { MCPError, ErrorCodes, createUserError, formatErrorResponse, withErrorHandling, SelfCorrectionHints, } from "./errors.js";
5
5
  // Validation utilities
6
6
  export { validateQuery, validateRepository, validatePath, validateRef, validateNumber, validateToolArgs, sanitizeString, } from "./validation.js";
7
7
  // Health check utilities
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "midnight-mcp",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Model Context Protocol Server for Midnight Blockchain Development",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",