Skip to main content
Glama
LarouTech

MCP Server TypeScript Boilerplate

by LarouTech
FileReadTool.ts1 kB
// src/tools/FileReadTool.ts - File reading tool import { BaseTool } from "./BaseTool"; import { promises as fs } from "fs"; import { logger } from "../utils/logger"; export class FileReadTool extends BaseTool { readonly name = "read_file"; readonly description = "Read contents of a file"; readonly inputSchema = { type: "object", properties: { path: { type: "string", description: "Path to the file to read", }, }, required: ["path"], }; async execute(args: { path: string }): Promise<any> { try { const content = await fs.readFile(args.path, "utf-8"); return { content: [ { type: "text", text: content, }, ], }; } catch (error) { logger.error(`Failed to read file: ${args.path}`, error); const errorMessage = error instanceof Error ? error.message : String(error); throw new Error(`Failed to read file: ${errorMessage}`); } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/LarouTech/mcp-server-boilerplate'

If you have feedback or need assistance with the MCP directory API, please join our Discord server