Skip to main content
Glama

ngit-mcp

Let an AI assistant read and work with git repositories that live on Nostr. It is safe by default.

ngit is a way to host git repos on Nostr. There is no GitHub: pull requests, issues and comments are signed events on relays. ngit-mcp connects that world to any MCP host (Claude Desktop, Cursor, Grok Bot and others), so an assistant can:

  • Read: a repo's maintainers and servers, the PR and issue lists, full threads with CI, the actual code diff of a PR, and a live feed of "what happened since…".

  • Act (only when you switch it on): open or update a PR, comment, create an issue, label, close or reopen, merge. Each action is shown to you as a plan first, and your own signer app signs it. The server never holds a key.

Why it's nice

⚑ Fast

Repeat reads take about 0.2 ms instead of about 560 ms, and stay fresh via a live relay subscription. With --warm, the first read is instant too.

πŸ‘‹ Connect in the chat

Ask for a write and you get one message: a QR for your signer app, or "just tell me your name". New to Nostr? Two questions (your name, an optional backup email) and you have an account, made on this machine, with the key never shown to the AI. There's no terminal and no config. See ONBOARDING.md.

πŸ”’ Can't post until you connect

Signing tools stay off until you pair a signer in this session, which is a physical act on your own device. Reads need no setup and run in a private, keyless home that cannot reach a signer.

🧾 Plan β†’ approve β†’ commit

Every write is a plan with an exact preview and a token. The token is a hash of the exact command, so what you approved is exactly what runs.

πŸ” Never posts twice

Before any retry it checks the relays for the event. If the relays can't be reached, it refuses instead of guessing.

πŸ›‘οΈ Prompt-injection fencing

Anything other people wrote comes back inside <untrusted author=… role=…>, so the assistant knows what is data and what is an instruction.

🀐 No secrets in output

Keys and bunker secrets are redacted from every response, including errors.

Related MCP server: GitAgentic MCP Server

Install

Requires Node β‰₯ 20 and ngit on your PATH.

git clone <this repo> ngit-mcp && cd ngit-mcp
npm install && npm run build

Add it to your MCP host

{
  "mcpServers": {
    "ngit": {
      "command": "node",
      "args": ["/path/to/ngit-mcp/dist/index.js",
               "--warm", "nostr://npub1…/relay.ngit.dev/my-repo"]
    }
  }
}

That's all the setup there is. Reading works at once. The first time you ask for a write, the assistant calls ngit_connect and shows you this:

Open your Nostr signer app and scan this. New to Nostr? Just tell me your name and I'll set you up here. β€ΉQRβ€Ί

Scan it and approve, and you get "βœ“ Connected as you". Or tell it your name: it asks one more question ("Email for your backup? (optional)") and ends with "βœ“ You're on Nostr as Ada (npub…). Nothing is posted until you approve it." From then on every write is shown to you as a plan first, and your signer app asks before signing. The full script and every failure case are in ONBOARDING.md.

Optional flags:

Flag

Effect

--allow-signing

Enables ngit_plan and ngit_commit from the start for the ngit account that is already logged in, with no pairing needed.

--read-only

No writing at all: removes ngit_connect and the signing tools. Always wins.

--secret-storage <auto|file|git-config>

Passed to ngit account login. Without an OS keychain the assistant asks before falling back to git-config.

--no-local-page

For servers that don't run on your computer: no 127.0.0.1 pairing or backup page. The QR still works, and newcomers are told their key is kept on that machine.

--signer-relay <url>

Override the pairing relays.

--warm <repo>

Preloads a repo at startup, so the first call is instant.

--lockdown

Hides text from people who are not maintainers or in --allow-npub.

--allow-npub <npub>

Marks extra people as trusted.

--repo-allowlist <repo,…>

Refuses every other repo. Entries must use npub or naddr form.

--allow-local-git

Lets ngit_pr_diff fetch over plain http from 127.0.0.1 or localhost, for a local GRASP server. Off by default, because PR clone URLs are chosen by whoever opened the PR.

--state-dir <dir>

Where caches live (default ~/.local/state/ngit-mcp).

Tools

Tool

What it does

ngit_repo

Name, maintainers, git servers, health

ngit_list

type: pr | issue, with optional status, label and author filters

ngit_get

One PR or issue with its comment thread (PRs include CI)

ngit_pr_diff

Diffstat and unified diff of a PR, fetched straight from its git servers

ngit_activity

New PRs, issues, comments, status changes and updates since a time (live)

ngit_connect

Connects your identity. It returns the QR (as an image and as text) and waits with wait_s, or takes a pasted bunker:// link, or creates a new account from name (+ email) with ngit account create. backup points to the local backup page. Refuses anything that looks like a private key.

ngit_plan

(signing) Builds an exact plan and token for pr_open, pr_update, comment, issue_create, status, label or merge. Publishes nothing.

ngit_commit

(signing) Runs a plan by token. Your signer app asks you to approve. Call it again with the same token to check progress; it never publishes twice.

Every read accepts fresh: true to force a network round trip. Repos can be written as nostr://<npub>/<relay>/<id>, naddr1…, or with a NIP-05 owner such as nostr://dan@gitworkshop.dev/relay.ngit.dev/ngit.

Demo (real output, read-only, against a public repo)

> tools: ngit_repo, ngit_list, ngit_get, ngit_pr_diff, ngit_activity
> ngit_repo  (610.7 ms, fetched)
  name=<untrusted author="npub1m5tu…" role="maintainer">routstrd-remote</untrusted>  maintainers=1
> ngit_list type=pr  (555.3 ms, fetched)  count=2
  [open] <untrusted author="npub1626p…" role="other">feat(npubs): per-npub model allowlist and expiry</untrusted>
  [applied] <untrusted author="npub1m5tu…" role="maintainer">feat(admin): seed the container's own identity as the first admin</untrusted>
> ngit_list type=pr again  (0.9 ms, memory)
> ngit_get type=pr  (549.0 ms)  comments=0
> ngit_pr_diff  (1455 ms cold / 1.4 ms warm)   6 files changed, 667 insertions(+), 30 deletions(-)
> ngit_activity since=0  (2.5 ms)  events=5

To reproduce it, run npx tsx scripts/demo.ts [repo]. A signing session looks like this:

assistant β†’ ngit_plan {action:"comment", on:"pr", id:"nevent1…", body:"LGTM"}
server    ← {token:"ngp_3f…", signer:"npub1you…", preview:{what:"Comment on pr", body:"LGTM"},
             commands:[["ngit","--repo","nostr://…","pr","comment","nevent1…","--body=LGTM","--json"]]}
assistant: "I'll post 'LGTM' on PR #… as npub1you… β€” OK?"   you: "yes"
assistant β†’ ngit_commit {token:"ngp_3f…"}          (your phone asks you to approve; you tap Approve)
server    ← {state:"done", attempt:1, result:{…}}

Speed (real MCP round trips, routstrd-pro on relay.ngit.dev)

Tool

Raw ngit CLI

ngit-mcp cold

ngit-mcp warm p50

with --warm, first call

repo

545–1361 ms

1215 ms

0.22 ms

7 ms

pr list

β‰ˆ570 ms

540 ms

0.35 ms

1 ms

pr view

β‰ˆ560 ms

553 ms

0.44 ms

β€”

issue list

β‰ˆ560 ms

539 ms

0.12 ms

1 ms

pr diff

(no equivalent)

1484 ms

1.5–1.9 ms

β€”

activity

(no equivalent)

2 ms

0.6 ms

β€”

A cold read is ngit itself, because ngit stays the source of truth. Every later read is served from memory and refreshed in the background. A live relay subscription marks it stale as soon as anything changes. Raw numbers are in bench/ (npm run bench).

Tests

npm test               # 60 tests (25 property suites, a 5,040-run model check of the
                       # signing protocol, the real server process); fakes, no network (β‰ˆ55 s)
./test/e2e/run.sh      # 28 tests: real ngit + git-remote-nostr + real signatures with a
                       # throwaway key, against a local relay AND a local GRASP server
                       # (relay + git smart-HTTP enforcing GRASP push rules), inside a
                       # network namespace with NO internet (needs unshare)

The onboarding e2e pairs real ngit with a scripted NIP-46 signer (throwaway keys) in these modes: ok, asleep, never answers, rejects, no keychain, already logged in, and a pasted promenade-style bunker followed by a signed issue through it. It also runs the newcomer wizard (with and without email, and hosted) using real ngit account create against a local relay. That covers the backup page (its ncryptsec decrypts to the exact key ngit stores) and a signed issue with the new key, and it checks every byte of tool output for the key.

The e2e covers the whole PR lifecycle: open β†’ diff β†’ update (revision) β†’ stale-plan refusal β†’ comment β†’ draft/ready β†’ merge and publish. It also checks that a rogue push is rejected by the GRASP rules. INVARIANTS.md lists the 19 invariants, how each is proved or checked, and the 15 bugs that the tests found. LOOPS.md is the build diary.

Limitations

  • A cold read costs one ngit call (about 0.55–1.2 s). Use --warm for the repos you care about.

  • A key created in the chat signs without asking on a device; the approval is the plan step in the chat. Move it to your phone (backup page) for a second factor. On a hosted agent the key lives on the host. See ONBOARDING.md, limits.

  • The signer is whichever ngit account is active in your environment. The connector never holds keys, and it has only been tested with throwaway keys. It has not been tested with a real phone signer.

  • Plans live in memory. After a restart, make a new plan. The new plan warns (possible_duplicate) if you published a matching event in the last 10 minutes.

  • The GRASP server used in the e2e is a minimal test implementation written for this project, not ngit-grasp itself. ngit 3.2.0 and git-remote-nostr are the real thing.

  • ngit_pr_diff fetches from https clone URLs named in the PR. That means it can reach any https host the PR author chose, but only to read git objects.

  • Short lowercase words (≀20 letters, such as status values) are left unfenced by design.

Available Tools

6 tools
ngit_activityB
Read-only

What happened since a time: new PRs/issues, comments, status changes, PR updates (live). Use to watch for replies.

Inputs: repo (required), id, fresh, since.

ngit_connectA

Connect the user's Nostr identity. Call with no arguments, show say (and the QR, or qr_text if you cannot show images), then wait_s=50 until connected. For a new user, pass name and then email as say asks (email="" to skip). Never ask for, accept or repeat an nsec.

Inputs: name, email, backup, bunker, +5 more.

ngit_getB
Read-only

One PR or issue with its full comment thread (PRs include CI results in ci).

Inputs: id (required), repo (required), type (required), fresh.

ngit_listA
Read-only

List pull requests or issues (default: open + draft). Text written by others is wrapped in tags.

Inputs: repo (required), type (required), fresh, label, +2 more.

ngit_pr_diffB
Read-only

The code change of a PR: diffstat + unified diff (merge-base..tip), fetched from its git servers.

Inputs: id (required), repo (required), fresh, max_bytes.

ngit_repoA
Read-only

Repository metadata: name, maintainers (confirmed/invited), git servers, health, default branch tip.

Inputs: repo (required), fresh.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 6 tools

    Disambiguation4/5

    The tools mostly target distinct resources and actions: repo metadata, listing, single-item retrieval, PR diff, activity feed, and identity connection. The boundary between ngit_list (current open/draft PRs and issues) and ngit_activity (changes since a timestamp) could be confused, but descriptions help clarify.

    Naming Consistency4/5

    All names share the same ngit_ prefix and snake_case style, making them readable and predictable. However, the suffix pattern mixes verbs (list, get, connect) and nouns (repo, activity, pr_diff), so it is not a strict verb_noun convention throughout.

    Tool Count5/5

    Six tools is well-scoped for a PR/issue browsing and monitoring server, with each tool covering a distinct capability. There is no obvious redundancy or bloated surface.

    Completeness3/5

    The surface covers repo metadata, listing/fetching PRs and issues, PR diffs, activity monitoring, and identity connection. But it appears read-only: there are no tools to create issues/PRs, comment, update status, or merge, which are notable gaps for a collaboration workflow.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers