UNPKG

it-tools-mcp

Version:

Full MCP 2025-06-18 compliant server with 121+ IT tools, logging, ping, progress tracking, cancellation, and sampling utilities

28 lines (27 loc) 997 B
import { z } from "zod"; import fs from "fs"; export function registerGrep(server) { server.registerTool("grep", { description: "Search for patterns in files", inputSchema: { pattern: z.string().describe("Pattern to search for"), file: z.string().describe("File path") }, // VS Code compliance annotations annotations: { title: "Grep", description: "Search for patterns in files", readOnlyHint: false } }, async ({ pattern, file }) => { try { const data = fs.readFileSync(file, "utf8"); const lines = data.split("\n"); const matches = lines.filter(line => line.includes(pattern)); return { content: [{ type: "text", text: matches.join("\n") }] }; } catch (error) { return { content: [{ type: "text", text: `grep failed: ${error instanceof Error ? error.message : error}` }] }; } }); }