Skip to main content
Glama

get-markdown-file

Retrieve a Markdown file by specifying its absolute file path. This tool on the Markdownify MCP Server enables quick extraction of Markdown-formatted content for further use or conversion.

Instructions

Get a markdown file by absolute file path

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYesAbsolute path to file of markdown'd text

Implementation Reference

  • Core handler function that reads and validates the markdown file content using fs.promises.readFile
    static async get({ filePath, }: { filePath: string; }): Promise<MarkdownResult> { // Check file type is *.md or *.markdown const normPath = this.normalizePath(path.resolve(expandHome(filePath))); const markdownExt = [".md", ".markdown"]; if (!markdownExt.includes(path.extname(normPath))) { throw new Error("Required file is not a Markdown file."); } if (process.env?.MD_SHARE_DIR) { const allowedShareDir = this.normalizePath( path.resolve(expandHome(process.env.MD_SHARE_DIR)), ); if (!normPath.startsWith(allowedShareDir)) { throw new Error(`Only files in ${allowedShareDir} are allowed.`); } } if (!fs.existsSync(filePath)) { throw new Error("File does not exist"); } const text = await fs.promises.readFile(filePath, "utf-8"); return { path: filePath, text: text, }; }
  • Dispatch handler in CallToolRequestSchema that calls Markdownify.get for the get-markdown-file tool
    case tools.GetMarkdownFileTool.name: if (!validatedArgs.filepath) { throw new Error("File path is required for this tool"); } result = await Markdownify.get({ filePath: validatedArgs.filepath, }); break;
  • Tool schema defining input parameters for get-markdown-file
    export const GetMarkdownFileTool = ToolSchema.parse({ name: "get-markdown-file", description: "Get a markdown file by absolute file path", inputSchema: { type: "object", properties: { filepath: { type: "string", description: "Absolute path to file of markdown'd text", }, }, required: ["filepath"], }, });
  • src/server.ts:33-37 (registration)
    Registration of all tools including get-markdown-file via Object.values(tools) in ListToolsRequest handler
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: Object.values(tools), }; });

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/zcaceres/markdownify-mcp'

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