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 }],
        };
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves contents but doesn't mention aspects like read-only nature (implied but not explicit), error handling for missing files, authentication needs for GitHub access, rate limits, or output format. For a tool with no annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence, followed by contextual information. It uses two sentences efficiently without unnecessary elaboration. However, the second sentence could be more integrated or omitted if not adding critical value, slightly reducing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (simple retrieval), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what 'contents' entail (e.g., raw text, metadata), error scenarios, or how it interacts with the GitHub repository structure. For a tool with no structured behavioral data, more detail is needed to be fully helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the parameter 'filePath' documented as 'Path to the file within the repository.' The description adds minimal value beyond this, only implying the file must be in the Obsidian vault. Since the schema already covers the parameter adequately, the baseline score of 3 is appropriate, as the description doesn't significantly enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'retrieve' and the resource 'contents of a specific note, document, or file', making the purpose evident. It specifies the source as 'Obsidian vault stored in GitHub', which helps distinguish it from generic file retrieval tools. However, it doesn't explicitly differentiate from sibling tools like 'searchFiles' or 'getCommitHistory', keeping it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions 'Perfect for accessing your knowledge base content', which implies a use case but doesn't provide explicit guidance on when to use this tool versus alternatives like 'searchFiles' for broader queries or 'getCommitHistory' for version tracking. No when-not-to-use scenarios or prerequisites are stated, leaving gaps in usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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

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