Skip to main content
Glama
Hint-Services

Obsidian GitHub MCP

getFileContents

Retrieve the contents of a specific file from your Obsidian vault stored in GitHub. Input the file path to access and analyze documentation or notes directly.

Instructions

Retrieve the contents of a specific note, document, or file from your Obsidian vault stored in GitHub (my-organization/obsidian-vault). Perfect for accessing your knowledge base content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the file within the repository.

Implementation Reference

  • The main execution handler for the getFileContents tool. It fetches the raw file content from the GitHub repository using Octokit.repos.getContent with raw media type and returns it as MCP text content.
    async ({ filePath }) => { const fileContent = await this.handleRequest(async () => { return this.octokit.repos.getContent({ owner: this.config.owner, repo: this.config.repo, path: filePath, // Request raw content to avoid base64 decoding complexities for now mediaType: { format: "raw", }, }); }); // The raw format returns the content directly as a string if (typeof fileContent !== "string") { throw new Error( "Received unexpected content format from GitHub API." ); } return { content: [{ type: "text" as const, text: fileContent }], }; }
  • Zod input schema for the tool, defining the required 'filePath' parameter.
    filePath: z .string() .describe("Path to the file within the repository."),
  • Registration of the getFileContents tool via server.tool() call, including name, description, input schema, execution hints, and handler function.
    server.tool( "getFileContents", `Retrieve the contents of a specific note, document, or file from your Obsidian vault stored in GitHub (${this.config.owner}/${this.config.repo}). Perfect for accessing your knowledge base content.`, { filePath: z .string() .describe("Path to the file within the repository."), }, { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, async ({ filePath }) => { const fileContent = await this.handleRequest(async () => { return this.octokit.repos.getContent({ owner: this.config.owner, repo: this.config.repo, path: filePath, // Request raw content to avoid base64 decoding complexities for now mediaType: { format: "raw", }, }); }); // The raw format returns the content directly as a string if (typeof fileContent !== "string") { throw new Error( "Received unexpected content format from GitHub API." ); } return { content: [{ type: "text" as const, text: fileContent }], }; } );

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/Hint-Services/obsidian-github-mcp'

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