Skip to main content
Glama

readFile

Retrieve file contents by specifying the file path using this tool, designed for managing Expo-based React Native applications in the Expo MCP Server environment.

Instructions

Read the contents of a file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesThe path to the file to read

Implementation Reference

  • The readFile tool handler function that reads and returns the content of the specified file.
    export async function readFile(args: { filePath: string }, { log }: LogContext) { try { log.info(`Reading file at path: ${args.filePath}`); const normalizedPath = path.normalize(args.filePath); const fileContent = await fs.promises.readFile(normalizedPath, "utf8"); log.info(`Successfully read file: ${normalizedPath}`); return { content: [ { type: "text", text: fileContent, }, ], }; } catch (error: any) { log.error(`Error reading file: ${error.message}`); throw new Error(`Failed to read file: ${error.message}`); } }
  • src/index.ts:18-25 (registration)
    Registration of the readFile tool on the MCP server, including schema definition and handler reference.
    addTool({ name: "readFile", description: "Read the contents of a file", parameters: z.object({ filePath: z.string().describe("The path to the file to read"), }), execute: readFile, });

Other Tools

Related Tools

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/mattlemmone/expo-mcp'

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