feat: implement fuzzy search and replace functionality with Levenshtein distance
- Added `applySearchReplace` function to handle search and replace operations with fuzzy matching capabilities. - Introduced tests for various scenarios including fuzzy matching with typos, exact matches, and handling whitespace differences. - Created a parser for search/replace blocks to facilitate the new functionality. - Updated prompts for search-replace operations to clarify usage and examples. - Added utility functions for text normalization and language detection based on file extensions. - Implemented a minimal stdio MCP server for local testing with tools for adding numbers and printing environment variables.
This commit is contained in:
44
testing/fake-stdio-mcp-server.mjs
Normal file
44
testing/fake-stdio-mcp-server.mjs
Normal file
@@ -0,0 +1,44 @@
|
||||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||
import { z } from "zod";
|
||||
|
||||
const server = new McpServer({
|
||||
name: "fake-stdio-mcp",
|
||||
version: "0.1.0",
|
||||
});
|
||||
|
||||
server.registerTool(
|
||||
"calculator_add",
|
||||
{
|
||||
title: "Calculator Add",
|
||||
description: "Add two numbers and return the sum",
|
||||
inputSchema: { a: z.number(), b: z.number() },
|
||||
},
|
||||
async ({ a, b }) => {
|
||||
const sum = a + b;
|
||||
return {
|
||||
content: [{ type: "text", text: String(sum) }],
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
server.registerTool(
|
||||
"print_envs",
|
||||
{
|
||||
title: "Print Envs",
|
||||
description: "Print the environment variables received by the server",
|
||||
inputSchema: {},
|
||||
},
|
||||
async () => {
|
||||
const envObject = Object.fromEntries(
|
||||
Object.entries(process.env).map(([key, value]) => [key, value ?? ""]),
|
||||
);
|
||||
const pretty = JSON.stringify(envObject, null, 2);
|
||||
return {
|
||||
content: [{ type: "text", text: pretty }],
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
const transport = new StdioServerTransport();
|
||||
await server.connect(transport);
|
||||
Reference in New Issue
Block a user