Skip to main content
Glama
forgejo-vault-mcp

forgejo-vault-mcp

by alexradunet

forgejo-vault-mcp

A stateless MCP bridge for Obsidian vaults stored on Forgejo / Gitea / Codeberg. One file, zero dependencies, ~0 EUR/month on serverless.

If your Obsidian vault lives in a git repository, this project turns it into a Model Context Protocol server your AI assistant can read and (with your approval) write. Deploy it as a serverless function, register it as a custom connector, and your assistant can list, read, search and append to your vault from anywhere. Your notes stay in git the entire time; every write is a real commit.

How it works

graph LR
    A["MCP client<br/>(Claude, Vibe, ...)"] -->|"HTTPS + Bearer key"| B["Serverless function<br/>forgejo-vault-mcp"]
    B -->|"Forgejo REST API"| C[("Obsidian vault<br/>(git repository)")]
  • Stateless: speaks MCP Streamable HTTP with plain JSON responses, so it runs on any scale-to-zero platform.

  • No dependencies: one JavaScript file, no npm packages, no build step.

  • Git-native: every write is one commit; history is your audit log.

  • Host-agnostic: defaults to Codeberg, works with any Forgejo or Gitea instance.

Related MCP server: Obsidian MCP Server

Tools

Tool

What it does

list_files

List vault files, optionally under one folder (paged: offset, limit)

read_note

Read a note; long notes come in parts (start_line, max_lines)

read_many

Read up to 50 notes in one call, within one shared size budget

search_vault

Case-insensitive text search over all markdown notes and file names (path to narrow, limit = max matches)

write_note

Create or fully replace a note

append_note

Append to a note, creating it if missing

journal_append

Append to today's daily note (timezone-aware, path template configurable)

move_note

Move or rename a note or attachment in one commit

delete_note / create_folder

Delete a note / create a folder via a _folder.md placeholder

get_note_history

Commit history of a note

vault_stats / recent_journal

Vault overview and latest daily notes

Every result is capped at about 40,000 characters and says how to get the rest, so results fit inside MCP client limits.

Deploy on Scaleway (about 10 minutes)

  1. Serverless -> Functions -> Create: Node.js 20 or newer runtime, 256 MB, min scale 0, timeout 300 s.

  2. Privacy: Public (the function guards itself with your Bearer key), HTTPS-only: Enabled, POST.

  3. Paste vault-mcp.js into the inline editor; handler string <filename>.handle.

  4. Set the environment variables below (mark secrets as Secrets).

  5. Deploy, then run the smoke test.

Environment variables

Variable

Required

Default

Purpose

VAULT_REPO

yes

-

owner/repo of the vault repository

FORGEJO_TOKEN

yes (secret)

-

token with read/write on that repository

MCP_API_KEY

yes (secret)

-

Bearer key clients must present (openssl rand -hex 32)

FORGEJO_URL

no

https://codeberg.org

any Forgejo/Gitea instance

VAULT_BRANCH

no

repository default

branch to read and write

VAULT_TZ

no

Europe/Bucharest

timezone for daily notes

JOURNAL_TEMPLATE

no

Journal/{Y}/{M}/{Y}-{M}-{D}.md

daily-note path; must contain {Y}, {M} and {D}

VAULT_READONLY

no

off

1 hides and refuses every tool that writes

MCP_INSTRUCTIONS

no

generic guidance

instructions sent to the MCP client

Smoke test

curl -s "$URL" -H "Authorization: Bearer $MCP_API_KEY" -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"vault_stats","arguments":{}}}'

You should get a JSON-RPC result with your file counts. Without the header you get a 401.

Run it anywhere else

vault-mcp.js is also a standalone server (Node 20 or newer):

VAULT_REPO=me/vault FORGEJO_TOKEN=... MCP_API_KEY=... node vault-mcp.js

It listens on 127.0.0.1:8787 (HOST, PORT to change) and speaks plain HTTP: put a TLS reverse proxy in front before exposing it. For other serverless platforms, call the exported handle({ httpMethod, headers, body }); it returns { statusCode, headers, body }.

Use with Claude

Claude Code

claude mcp add --transport http vault https://<your-function-url> \
  --header "Authorization: Bearer <MCP_API_KEY>"

claude.ai / Claude Desktop: Settings -> Connectors -> Add custom connector. Enter the function URL, choose No sign-in, and add a request header named authorization with the value Bearer <MCP_API_KEY>.

The read tools are marked read-only, so clients can pre-approve them and keep the writing tools on manual approval. Other clients (Vibe, ...) work the same way: function URL plus Bearer key.

Security model

  • The function URL is reachable by necessity; every request must carry Authorization: Bearer <MCP_API_KEY> or it receives a 401 before the code touches the git host.

  • Note paths are validated: . and .. segments, backslashes and control characters are rejected, and every request to the git host is checked to stay inside the vault repository. A prompt-injected note cannot steer a tool at another repository or API endpoint.

  • Give FORGEJO_TOKEN access to the vault repository only (Forgejo: repository-scoped access token; on hosts without those, a dedicated account that is a collaborator on that one repository).

  • Rotate MCP_API_KEY on the platform and in your client to revoke access instantly.

  • VAULT_READONLY=1 turns the server into a read-only view.

How it stays fast and correct

  • The file list is cached per head commit and re-checked with one cheap request at most every 15 seconds, so notes pushed from another device show up without re-reading the whole tree.

  • Note content is cached by git blob id (which never changes). The first search downloads the vault as one archive; later searches only fetch what changed.

  • Writes are read-modify-write with the file's sha. If the note changed in between, the write is recomputed on top of the new version. If the host's answer is lost, the server checks whether the commit landed before sending it again, so a journal entry is never duplicated.

Limitations (honest ones)

  • All caches live in the memory of a warm instance; a cold start re-reads the file list, and the first search after it downloads the archive again.

  • Vaults over 32 MB (attachments included) skip the archive and read notes one by one; a search then has a 20-second budget per call and tells you if it could not cover everything (repeat the call to continue).

  • Search is plain substring matching per line: no regular expressions, no ranking.

  • move_note does not rewrite links in other notes.

Development

npm test    # node --test, zero dependencies, runs against an in-memory fake Forgejo

Rules for changing this project are in AGENTS.md.

License

MIT - see LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables AI assistants to read, write, search, and navigate Obsidian vault notes with support for CRUD operations, full-text search, graph navigation, daily notes, and frontmatter management.
      3,650 npm
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables LLMs like Claude and ChatGPT to access and manage git-backed Obsidian vaults through tools for file operations, search, tags, and journal logging.
      17
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Provides AI agents with direct filesystem access to an Obsidian vault for note management, task orchestration, context persistence, and git synchronization.
      27
      38 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables agents to search, read, and write notes in an Obsidian vault, including creating and updating notes in an inbox and syncing changes with Gitea/GitHub.
      MIT