@morphllm/morphmcp 0.8.31 → 0.8.33
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/index.js +29 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
-
import { CallToolRequestSchema, ListToolsRequestSchema,
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, RootsListChangedNotificationSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
5
|
import fs from "fs/promises";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import os from 'os';
|
|
@@ -22,13 +22,13 @@ const args = process.argv.slice(2);
|
|
|
22
22
|
// Only expose Morph-specific tools
|
|
23
23
|
const ALL_TOOLS = [
|
|
24
24
|
'edit_file',
|
|
25
|
-
'
|
|
25
|
+
'warpgrep_codebase_search',
|
|
26
26
|
'codebase_search'
|
|
27
27
|
];
|
|
28
|
-
// Default to edit_file and
|
|
28
|
+
// Default to edit_file and warpgrep_codebase_search
|
|
29
29
|
const DEFAULT_TOOLS = [
|
|
30
30
|
'edit_file',
|
|
31
|
-
'
|
|
31
|
+
'warpgrep_codebase_search'
|
|
32
32
|
];
|
|
33
33
|
// Parse ENABLED_TOOLS env var: comma-separated list or 'all'
|
|
34
34
|
const ENABLED_TOOLS = process.env.ENABLED_TOOLS
|
|
@@ -234,8 +234,8 @@ const MorphEditFileArgsSchema = z.object({
|
|
|
234
234
|
dryRun: z.boolean().default(false).describe('Preview changes without applying them.')
|
|
235
235
|
});
|
|
236
236
|
const WarpGrepArgsSchema = z.object({
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
repo_path: z.string().describe("Path to the repository root"),
|
|
238
|
+
search_string: z.string().describe("Natural language query describing the code context needed"),
|
|
239
239
|
});
|
|
240
240
|
const CodebaseSearchArgsSchema = z.object({
|
|
241
241
|
query: z.string().describe('Natural language query to search for code'),
|
|
@@ -245,7 +245,6 @@ const CodebaseSearchArgsSchema = z.object({
|
|
|
245
245
|
target_directories: z.array(z.string()).default([]).describe('Filter to specific directories, empty for all'),
|
|
246
246
|
limit: z.number().optional().default(10).describe('Max results to return')
|
|
247
247
|
});
|
|
248
|
-
const ToolInputSchema = ToolSchema.shape.inputSchema;
|
|
249
248
|
// Server setup
|
|
250
249
|
const server = new Server({
|
|
251
250
|
name: "morph-mcp",
|
|
@@ -510,7 +509,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
510
509
|
requiresApiKey: true,
|
|
511
510
|
},
|
|
512
511
|
{
|
|
513
|
-
name: "
|
|
512
|
+
name: "warpgrep_codebase_search",
|
|
514
513
|
description: "ALWAYS use Warp Grep when you need to search a large chunk of code. " +
|
|
515
514
|
"Warp Grep is a fast and accurate tool that can search for all relevant context in a codebase. " +
|
|
516
515
|
"Warp Grep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type",
|
|
@@ -649,7 +648,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
649
648
|
};
|
|
650
649
|
}
|
|
651
650
|
}
|
|
652
|
-
case "
|
|
651
|
+
case "warpgrep_codebase_search": {
|
|
653
652
|
const parsed = WarpGrepArgsSchema.safeParse(args);
|
|
654
653
|
if (!parsed.success) {
|
|
655
654
|
return {
|
|
@@ -658,10 +657,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
658
657
|
};
|
|
659
658
|
}
|
|
660
659
|
try {
|
|
661
|
-
const repoRoot = path.resolve(parsed.data.
|
|
660
|
+
const repoRoot = path.resolve(parsed.data.repo_path);
|
|
662
661
|
const provider = new LocalRipgrepProvider(repoRoot);
|
|
663
662
|
const result = await runWarpGrep({
|
|
664
|
-
query: parsed.data.
|
|
663
|
+
query: parsed.data.search_string,
|
|
665
664
|
repoRoot,
|
|
666
665
|
model: "morph-warp-grep",
|
|
667
666
|
apiKey: MORPH_API_KEY,
|
|
@@ -720,7 +719,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
720
719
|
// 4. XML formatted file contents
|
|
721
720
|
const xmlBlocks = [];
|
|
722
721
|
for (const file of files) {
|
|
723
|
-
const filePath = path.resolve(parsed.data.
|
|
722
|
+
const filePath = path.resolve(parsed.data.repo_path, file.path);
|
|
724
723
|
try {
|
|
725
724
|
const content = await fs.readFile(filePath, { encoding: "utf-8" });
|
|
726
725
|
const lines = content.split(/\r?\n/);
|
|
@@ -752,17 +751,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
752
751
|
error_message: errorMessages,
|
|
753
752
|
error_type: 'FileReadError',
|
|
754
753
|
context: {
|
|
755
|
-
tool: '
|
|
756
|
-
repo_path: parsed.data.
|
|
757
|
-
query: parsed.data.
|
|
754
|
+
tool: 'warpgrep_codebase_search',
|
|
755
|
+
repo_path: parsed.data.repo_path,
|
|
756
|
+
query: parsed.data.search_string,
|
|
758
757
|
model: 'morph-warp-grep',
|
|
759
758
|
termination_reason: 'completed_with_file_errors',
|
|
760
759
|
error_count: fileReadErrors.length,
|
|
761
760
|
is_timeout: false,
|
|
762
761
|
request_content: {
|
|
763
|
-
query: parsed.data.
|
|
764
|
-
|
|
765
|
-
repoRoot: path.resolve(parsed.data.
|
|
762
|
+
query: parsed.data.search_string,
|
|
763
|
+
repo_path: parsed.data.repo_path,
|
|
764
|
+
repoRoot: path.resolve(parsed.data.repo_path),
|
|
766
765
|
model: 'morph-warp-grep'
|
|
767
766
|
},
|
|
768
767
|
files_requested: files.map((f) => f.path)
|
|
@@ -785,17 +784,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
785
784
|
error_message: errorMessages,
|
|
786
785
|
error_type: isTimeout ? 'TimeoutError' : (firstError?.constructor?.name || 'WarpGrepError'),
|
|
787
786
|
context: {
|
|
788
|
-
tool: '
|
|
789
|
-
repo_path: parsed.data.
|
|
790
|
-
query: parsed.data.
|
|
787
|
+
tool: 'warpgrep_codebase_search',
|
|
788
|
+
repo_path: parsed.data.repo_path,
|
|
789
|
+
query: parsed.data.search_string,
|
|
791
790
|
model: 'morph-warp-grep',
|
|
792
791
|
termination_reason: result.terminationReason,
|
|
793
792
|
error_count: result.errors.length,
|
|
794
793
|
is_timeout: isTimeout,
|
|
795
794
|
request_content: {
|
|
796
|
-
query: parsed.data.
|
|
797
|
-
|
|
798
|
-
repoRoot: path.resolve(parsed.data.
|
|
795
|
+
query: parsed.data.search_string,
|
|
796
|
+
repo_path: parsed.data.repo_path,
|
|
797
|
+
repoRoot: path.resolve(parsed.data.repo_path),
|
|
799
798
|
model: 'morph-warp-grep'
|
|
800
799
|
},
|
|
801
800
|
messages: result.messages?.map((m) => ({
|
|
@@ -826,15 +825,15 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
826
825
|
error_message: errorMessage,
|
|
827
826
|
error_type: isTimeout ? 'TimeoutError' : (error instanceof Error ? error.constructor.name : 'UnknownError'),
|
|
828
827
|
context: {
|
|
829
|
-
tool: '
|
|
830
|
-
repo_path: parsed.data.
|
|
831
|
-
query: parsed.data.
|
|
828
|
+
tool: 'warpgrep_codebase_search',
|
|
829
|
+
repo_path: parsed.data.repo_path,
|
|
830
|
+
query: parsed.data.search_string,
|
|
832
831
|
model: 'morph-warp-grep',
|
|
833
832
|
is_timeout: isTimeout,
|
|
834
833
|
request_content: {
|
|
835
|
-
query: parsed.data.
|
|
836
|
-
|
|
837
|
-
repoRoot: path.resolve(parsed.data.
|
|
834
|
+
query: parsed.data.search_string,
|
|
835
|
+
repo_path: parsed.data.repo_path,
|
|
836
|
+
repoRoot: path.resolve(parsed.data.repo_path),
|
|
838
837
|
model: 'morph-warp-grep'
|
|
839
838
|
}
|
|
840
839
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morphllm/morphmcp",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.33",
|
|
4
4
|
"description": "Fast & accurate MCP server with AI-powered file editing and intelligent code search. Prevents context pollution and saves time for a better user experience.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Morph (https://morphllm.com)",
|