Skip to main content
Glama
Hint-Services

MCP Private GitHub Search

getFileContents

Retrieve the contents of a specific file from an Obsidian vault stored in a private GitHub repository, enabling direct access to your knowledge base content through a provided file path.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the file within the repository.

Implementation Reference

  • Registration of the 'getFileContents' tool using server.tool(), including schema, hints, and the full handler implementation.
    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 }],
        };
      }
    );
  • The handler function that retrieves the raw file contents from the GitHub repository using the Octokit API and returns it as 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 schema defining the input parameter 'filePath' for the tool.
    {
      filePath: z
        .string()
        .describe("Path to the file within the repository."),
    },
Install Server

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/mcp-private-github-search'

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