midnight-mcp 0.0.8 → 0.1.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/README.md +50 -20
- package/dist/server.d.ts +9 -0
- package/dist/server.js +151 -3
- package/dist/services/index.d.ts +6 -0
- package/dist/services/index.js +6 -0
- package/dist/services/sampling.d.ts +62 -0
- package/dist/services/sampling.js +256 -0
- package/dist/tools/analyze.d.ts +2 -36
- package/dist/tools/analyze.js +117 -0
- package/dist/tools/generation.d.ts +9 -0
- package/dist/tools/generation.js +282 -0
- package/dist/tools/health.d.ts +2 -25
- package/dist/tools/health.js +71 -0
- package/dist/tools/index.d.ts +4 -409
- package/dist/tools/index.js +3 -0
- package/dist/tools/repository.d.ts +2 -263
- package/dist/tools/repository.js +47 -0
- package/dist/tools/search.d.ts +2 -88
- package/dist/tools/search.js +72 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/mcp.d.ts +167 -0
- package/dist/types/mcp.js +6 -0
- package/package.json +3 -1
package/dist/tools/repository.js
CHANGED
|
@@ -492,6 +492,11 @@ export const repositoryTools = [
|
|
|
492
492
|
},
|
|
493
493
|
required: ["repo", "path"],
|
|
494
494
|
},
|
|
495
|
+
annotations: {
|
|
496
|
+
readOnlyHint: true,
|
|
497
|
+
openWorldHint: true,
|
|
498
|
+
title: "Get Repository File",
|
|
499
|
+
},
|
|
495
500
|
handler: getFile,
|
|
496
501
|
},
|
|
497
502
|
{
|
|
@@ -508,6 +513,11 @@ export const repositoryTools = [
|
|
|
508
513
|
},
|
|
509
514
|
required: [],
|
|
510
515
|
},
|
|
516
|
+
annotations: {
|
|
517
|
+
readOnlyHint: true,
|
|
518
|
+
idempotentHint: true,
|
|
519
|
+
title: "List Example Contracts",
|
|
520
|
+
},
|
|
511
521
|
handler: listExamples,
|
|
512
522
|
},
|
|
513
523
|
{
|
|
@@ -528,6 +538,11 @@ export const repositoryTools = [
|
|
|
528
538
|
},
|
|
529
539
|
required: [],
|
|
530
540
|
},
|
|
541
|
+
annotations: {
|
|
542
|
+
readOnlyHint: true,
|
|
543
|
+
openWorldHint: true,
|
|
544
|
+
title: "Get Latest Updates",
|
|
545
|
+
},
|
|
531
546
|
handler: getLatestUpdates,
|
|
532
547
|
},
|
|
533
548
|
{
|
|
@@ -543,6 +558,11 @@ export const repositoryTools = [
|
|
|
543
558
|
},
|
|
544
559
|
required: ["repo"],
|
|
545
560
|
},
|
|
561
|
+
annotations: {
|
|
562
|
+
readOnlyHint: true,
|
|
563
|
+
openWorldHint: true,
|
|
564
|
+
title: "Get Version Info",
|
|
565
|
+
},
|
|
546
566
|
handler: getVersionInfo,
|
|
547
567
|
},
|
|
548
568
|
{
|
|
@@ -562,6 +582,11 @@ export const repositoryTools = [
|
|
|
562
582
|
},
|
|
563
583
|
required: ["repo", "currentVersion"],
|
|
564
584
|
},
|
|
585
|
+
annotations: {
|
|
586
|
+
readOnlyHint: true,
|
|
587
|
+
openWorldHint: true,
|
|
588
|
+
title: "Check Breaking Changes",
|
|
589
|
+
},
|
|
565
590
|
handler: checkBreakingChanges,
|
|
566
591
|
},
|
|
567
592
|
{
|
|
@@ -585,6 +610,11 @@ export const repositoryTools = [
|
|
|
585
610
|
},
|
|
586
611
|
required: ["repo", "fromVersion"],
|
|
587
612
|
},
|
|
613
|
+
annotations: {
|
|
614
|
+
readOnlyHint: true,
|
|
615
|
+
openWorldHint: true,
|
|
616
|
+
title: "Get Migration Guide",
|
|
617
|
+
},
|
|
588
618
|
handler: getMigrationGuide,
|
|
589
619
|
},
|
|
590
620
|
{
|
|
@@ -608,6 +638,12 @@ export const repositoryTools = [
|
|
|
608
638
|
},
|
|
609
639
|
required: ["repo", "path", "version"],
|
|
610
640
|
},
|
|
641
|
+
annotations: {
|
|
642
|
+
readOnlyHint: true,
|
|
643
|
+
idempotentHint: true,
|
|
644
|
+
openWorldHint: true,
|
|
645
|
+
title: "Get File at Version",
|
|
646
|
+
},
|
|
611
647
|
handler: getFileAtVersion,
|
|
612
648
|
},
|
|
613
649
|
{
|
|
@@ -635,6 +671,12 @@ export const repositoryTools = [
|
|
|
635
671
|
},
|
|
636
672
|
required: ["repo", "path", "oldVersion"],
|
|
637
673
|
},
|
|
674
|
+
annotations: {
|
|
675
|
+
readOnlyHint: true,
|
|
676
|
+
idempotentHint: true,
|
|
677
|
+
openWorldHint: true,
|
|
678
|
+
title: "Compare Syntax Between Versions",
|
|
679
|
+
},
|
|
638
680
|
handler: compareSyntax,
|
|
639
681
|
},
|
|
640
682
|
{
|
|
@@ -650,6 +692,11 @@ export const repositoryTools = [
|
|
|
650
692
|
},
|
|
651
693
|
required: [],
|
|
652
694
|
},
|
|
695
|
+
annotations: {
|
|
696
|
+
readOnlyHint: true,
|
|
697
|
+
openWorldHint: true,
|
|
698
|
+
title: "Get Latest Syntax Reference",
|
|
699
|
+
},
|
|
653
700
|
handler: getLatestSyntax,
|
|
654
701
|
},
|
|
655
702
|
];
|
package/dist/tools/search.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import type { ExtendedToolDefinition } from "../types/index.js";
|
|
2
3
|
export declare const SearchCompactInputSchema: z.ZodObject<{
|
|
3
4
|
query: z.ZodString;
|
|
4
5
|
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
@@ -71,92 +72,5 @@ export declare function searchTypeScript(input: SearchTypeScriptInput): Promise<
|
|
|
71
72
|
* Full-text search across official Midnight documentation
|
|
72
73
|
*/
|
|
73
74
|
export declare function searchDocs(input: SearchDocsInput): Promise<{}>;
|
|
74
|
-
export declare const searchTools:
|
|
75
|
-
name: string;
|
|
76
|
-
description: string;
|
|
77
|
-
inputSchema: {
|
|
78
|
-
type: "object";
|
|
79
|
-
properties: {
|
|
80
|
-
query: {
|
|
81
|
-
type: string;
|
|
82
|
-
description: string;
|
|
83
|
-
};
|
|
84
|
-
limit: {
|
|
85
|
-
type: string;
|
|
86
|
-
description: string;
|
|
87
|
-
};
|
|
88
|
-
filter: {
|
|
89
|
-
type: string;
|
|
90
|
-
properties: {
|
|
91
|
-
repository: {
|
|
92
|
-
type: string;
|
|
93
|
-
};
|
|
94
|
-
isPublic: {
|
|
95
|
-
type: string;
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
description: string;
|
|
99
|
-
};
|
|
100
|
-
includeTypes?: undefined;
|
|
101
|
-
includeExamples?: undefined;
|
|
102
|
-
category?: undefined;
|
|
103
|
-
};
|
|
104
|
-
required: string[];
|
|
105
|
-
};
|
|
106
|
-
handler: typeof searchCompact;
|
|
107
|
-
} | {
|
|
108
|
-
name: string;
|
|
109
|
-
description: string;
|
|
110
|
-
inputSchema: {
|
|
111
|
-
type: "object";
|
|
112
|
-
properties: {
|
|
113
|
-
query: {
|
|
114
|
-
type: string;
|
|
115
|
-
description: string;
|
|
116
|
-
};
|
|
117
|
-
includeTypes: {
|
|
118
|
-
type: string;
|
|
119
|
-
description: string;
|
|
120
|
-
};
|
|
121
|
-
includeExamples: {
|
|
122
|
-
type: string;
|
|
123
|
-
description: string;
|
|
124
|
-
};
|
|
125
|
-
limit: {
|
|
126
|
-
type: string;
|
|
127
|
-
description: string;
|
|
128
|
-
};
|
|
129
|
-
filter?: undefined;
|
|
130
|
-
category?: undefined;
|
|
131
|
-
};
|
|
132
|
-
required: string[];
|
|
133
|
-
};
|
|
134
|
-
handler: typeof searchTypeScript;
|
|
135
|
-
} | {
|
|
136
|
-
name: string;
|
|
137
|
-
description: string;
|
|
138
|
-
inputSchema: {
|
|
139
|
-
type: "object";
|
|
140
|
-
properties: {
|
|
141
|
-
query: {
|
|
142
|
-
type: string;
|
|
143
|
-
description: string;
|
|
144
|
-
};
|
|
145
|
-
category: {
|
|
146
|
-
type: string;
|
|
147
|
-
enum: string[];
|
|
148
|
-
description: string;
|
|
149
|
-
};
|
|
150
|
-
limit: {
|
|
151
|
-
type: string;
|
|
152
|
-
description: string;
|
|
153
|
-
};
|
|
154
|
-
filter?: undefined;
|
|
155
|
-
includeTypes?: undefined;
|
|
156
|
-
includeExamples?: undefined;
|
|
157
|
-
};
|
|
158
|
-
required: string[];
|
|
159
|
-
};
|
|
160
|
-
handler: typeof searchDocs;
|
|
161
|
-
})[];
|
|
75
|
+
export declare const searchTools: ExtendedToolDefinition[];
|
|
162
76
|
//# sourceMappingURL=search.d.ts.map
|
package/dist/tools/search.js
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { vectorStore } from "../db/index.js";
|
|
3
3
|
import { logger, validateQuery, validateNumber, searchCache, createCacheKey, isHostedMode, searchCompactHosted, searchTypeScriptHosted, searchDocsHosted, } from "../utils/index.js";
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Common Output Schema for Search Results
|
|
6
|
+
// ============================================================================
|
|
7
|
+
const searchResultSchema = {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
results: {
|
|
11
|
+
type: "array",
|
|
12
|
+
description: "Array of search results",
|
|
13
|
+
items: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
code: { type: "string", description: "The matched code content" },
|
|
17
|
+
relevanceScore: {
|
|
18
|
+
type: "number",
|
|
19
|
+
description: "Relevance score from 0 to 1",
|
|
20
|
+
},
|
|
21
|
+
source: {
|
|
22
|
+
type: "object",
|
|
23
|
+
description: "Source location information",
|
|
24
|
+
properties: {
|
|
25
|
+
repository: { type: "string", description: "Repository name" },
|
|
26
|
+
filePath: { type: "string", description: "File path" },
|
|
27
|
+
lines: {
|
|
28
|
+
type: "string",
|
|
29
|
+
description: "Line range (e.g., 10-50)",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
codeType: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "Type of code (compact, typescript, markdown)",
|
|
36
|
+
},
|
|
37
|
+
name: { type: "string", description: "Name of the code element" },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
totalResults: {
|
|
42
|
+
type: "number",
|
|
43
|
+
description: "Total number of results returned",
|
|
44
|
+
},
|
|
45
|
+
query: { type: "string", description: "The search query used" },
|
|
46
|
+
warnings: {
|
|
47
|
+
type: "array",
|
|
48
|
+
description: "Any warnings about the search",
|
|
49
|
+
items: { type: "string" },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
required: ["results", "totalResults", "query"],
|
|
53
|
+
description: "Search results with relevance scores and source information",
|
|
54
|
+
};
|
|
55
|
+
// Common annotations for search tools
|
|
56
|
+
const searchToolAnnotations = {
|
|
57
|
+
readOnlyHint: true,
|
|
58
|
+
idempotentHint: true,
|
|
59
|
+
openWorldHint: true,
|
|
60
|
+
};
|
|
4
61
|
/**
|
|
5
62
|
* Validate and prepare common search parameters
|
|
6
63
|
* Extracts common validation logic used by all search functions
|
|
@@ -293,6 +350,11 @@ export const searchTools = [
|
|
|
293
350
|
},
|
|
294
351
|
required: ["query"],
|
|
295
352
|
},
|
|
353
|
+
outputSchema: searchResultSchema,
|
|
354
|
+
annotations: {
|
|
355
|
+
...searchToolAnnotations,
|
|
356
|
+
title: "Search Compact Contracts",
|
|
357
|
+
},
|
|
296
358
|
handler: searchCompact,
|
|
297
359
|
},
|
|
298
360
|
{
|
|
@@ -320,6 +382,11 @@ export const searchTools = [
|
|
|
320
382
|
},
|
|
321
383
|
required: ["query"],
|
|
322
384
|
},
|
|
385
|
+
outputSchema: searchResultSchema,
|
|
386
|
+
annotations: {
|
|
387
|
+
...searchToolAnnotations,
|
|
388
|
+
title: "Search TypeScript SDK",
|
|
389
|
+
},
|
|
323
390
|
handler: searchTypeScript,
|
|
324
391
|
},
|
|
325
392
|
{
|
|
@@ -344,6 +411,11 @@ export const searchTools = [
|
|
|
344
411
|
},
|
|
345
412
|
required: ["query"],
|
|
346
413
|
},
|
|
414
|
+
outputSchema: searchResultSchema,
|
|
415
|
+
annotations: {
|
|
416
|
+
...searchToolAnnotations,
|
|
417
|
+
title: "Search Documentation",
|
|
418
|
+
},
|
|
347
419
|
handler: searchDocs,
|
|
348
420
|
},
|
|
349
421
|
];
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extended MCP types for advanced features
|
|
3
|
+
* Includes tool annotations, output schemas, and resource templates
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Tool annotations provide hints about tool behavior
|
|
7
|
+
* These help clients make better decisions about tool usage
|
|
8
|
+
*/
|
|
9
|
+
export interface ToolAnnotations {
|
|
10
|
+
/**
|
|
11
|
+
* If true, the tool does not modify any state
|
|
12
|
+
* Clients can safely retry or parallelize read-only tools
|
|
13
|
+
*/
|
|
14
|
+
readOnlyHint?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* If true, calling the tool multiple times with the same input
|
|
17
|
+
* produces the same result (safe to retry)
|
|
18
|
+
*/
|
|
19
|
+
idempotentHint?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* If true, the tool may return results from external sources
|
|
22
|
+
* that could change over time
|
|
23
|
+
*/
|
|
24
|
+
openWorldHint?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* If true, the tool may take a long time to complete
|
|
27
|
+
* Clients should show progress indicators
|
|
28
|
+
*/
|
|
29
|
+
longRunningHint?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Human-readable title for display in UIs
|
|
32
|
+
*/
|
|
33
|
+
title?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* JSON Schema for structured tool outputs
|
|
37
|
+
* Enables better LLM parsing and IDE integration
|
|
38
|
+
*/
|
|
39
|
+
export interface OutputSchema {
|
|
40
|
+
type: "object" | "array" | "string" | "number" | "boolean";
|
|
41
|
+
properties?: Record<string, PropertySchema>;
|
|
42
|
+
items?: PropertySchema;
|
|
43
|
+
required?: string[];
|
|
44
|
+
description?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface PropertySchema {
|
|
47
|
+
type: "string" | "number" | "boolean" | "array" | "object";
|
|
48
|
+
description?: string;
|
|
49
|
+
items?: PropertySchema;
|
|
50
|
+
properties?: Record<string, PropertySchema>;
|
|
51
|
+
enum?: string[];
|
|
52
|
+
}
|
|
53
|
+
export interface ExtendedToolDefinition {
|
|
54
|
+
name: string;
|
|
55
|
+
description: string;
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: "object";
|
|
58
|
+
properties: Record<string, unknown>;
|
|
59
|
+
required?: string[];
|
|
60
|
+
};
|
|
61
|
+
outputSchema?: OutputSchema;
|
|
62
|
+
annotations?: ToolAnnotations;
|
|
63
|
+
handler: (input: any) => Promise<any>;
|
|
64
|
+
}
|
|
65
|
+
export interface ResourceTemplate {
|
|
66
|
+
/**
|
|
67
|
+
* URI template following RFC 6570
|
|
68
|
+
* e.g., "midnight://code/{owner}/{repo}/{path}"
|
|
69
|
+
*/
|
|
70
|
+
uriTemplate: string;
|
|
71
|
+
/**
|
|
72
|
+
* Human-readable name
|
|
73
|
+
*/
|
|
74
|
+
name: string;
|
|
75
|
+
/**
|
|
76
|
+
* Human-readable title for display
|
|
77
|
+
*/
|
|
78
|
+
title?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Description of what resources this template provides
|
|
81
|
+
*/
|
|
82
|
+
description: string;
|
|
83
|
+
/**
|
|
84
|
+
* MIME type of resources matching this template
|
|
85
|
+
*/
|
|
86
|
+
mimeType: string;
|
|
87
|
+
}
|
|
88
|
+
export interface ResourceAnnotations {
|
|
89
|
+
/**
|
|
90
|
+
* Intended audience for the resource
|
|
91
|
+
* "user" = for human consumption
|
|
92
|
+
* "assistant" = for LLM context
|
|
93
|
+
*/
|
|
94
|
+
audience?: ("user" | "assistant")[];
|
|
95
|
+
/**
|
|
96
|
+
* Priority from 0.0 (optional) to 1.0 (required)
|
|
97
|
+
*/
|
|
98
|
+
priority?: number;
|
|
99
|
+
/**
|
|
100
|
+
* ISO 8601 timestamp of last modification
|
|
101
|
+
*/
|
|
102
|
+
lastModified?: string;
|
|
103
|
+
}
|
|
104
|
+
export interface SamplingRequest {
|
|
105
|
+
messages: SamplingMessage[];
|
|
106
|
+
systemPrompt?: string;
|
|
107
|
+
modelPreferences?: ModelPreferences;
|
|
108
|
+
maxTokens?: number;
|
|
109
|
+
temperature?: number;
|
|
110
|
+
stopSequences?: string[];
|
|
111
|
+
}
|
|
112
|
+
export interface SamplingMessage {
|
|
113
|
+
role: "user" | "assistant";
|
|
114
|
+
content: TextContent | ImageContent;
|
|
115
|
+
}
|
|
116
|
+
export interface TextContent {
|
|
117
|
+
type: "text";
|
|
118
|
+
text: string;
|
|
119
|
+
}
|
|
120
|
+
export interface ImageContent {
|
|
121
|
+
type: "image";
|
|
122
|
+
data: string;
|
|
123
|
+
mimeType: string;
|
|
124
|
+
}
|
|
125
|
+
export interface ModelPreferences {
|
|
126
|
+
hints?: {
|
|
127
|
+
name: string;
|
|
128
|
+
}[];
|
|
129
|
+
costPriority?: number;
|
|
130
|
+
speedPriority?: number;
|
|
131
|
+
intelligencePriority?: number;
|
|
132
|
+
}
|
|
133
|
+
export interface SamplingResponse {
|
|
134
|
+
role: "assistant";
|
|
135
|
+
content: TextContent;
|
|
136
|
+
model: string;
|
|
137
|
+
stopReason: "endTurn" | "maxTokens" | "stopSequence";
|
|
138
|
+
}
|
|
139
|
+
export interface SearchResult {
|
|
140
|
+
content: string;
|
|
141
|
+
relevanceScore: number;
|
|
142
|
+
source: {
|
|
143
|
+
repository: string;
|
|
144
|
+
filePath: string;
|
|
145
|
+
lines: string;
|
|
146
|
+
};
|
|
147
|
+
codeType: string;
|
|
148
|
+
}
|
|
149
|
+
export interface SearchResponse {
|
|
150
|
+
results: SearchResult[];
|
|
151
|
+
totalResults: number;
|
|
152
|
+
query: string;
|
|
153
|
+
warnings?: string[];
|
|
154
|
+
}
|
|
155
|
+
export interface AnalysisResponse {
|
|
156
|
+
name: string;
|
|
157
|
+
type: string;
|
|
158
|
+
summary: string;
|
|
159
|
+
components: {
|
|
160
|
+
name: string;
|
|
161
|
+
type: string;
|
|
162
|
+
description: string;
|
|
163
|
+
}[];
|
|
164
|
+
securityNotes: string[];
|
|
165
|
+
recommendations: string[];
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=mcp.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "midnight-mcp",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Model Context Protocol Server for Midnight Blockchain Development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -38,7 +38,9 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^20.10.0",
|
|
41
|
+
"@types/tar": "^6.1.13",
|
|
41
42
|
"prettier": "^3.1.0",
|
|
43
|
+
"tar": "^7.5.2",
|
|
42
44
|
"tsx": "^4.6.2",
|
|
43
45
|
"typescript": "^5.3.2",
|
|
44
46
|
"vitest": "^1.0.0"
|