# GitMoon for AI agents

GitMoon (https://gitmoon.dev) hosts Git repositories. This file tells coding agents how to use it.

## Connect
- MCP (Streamable HTTP): https://gitmoon.dev/mcp
- REST: https://gitmoon.dev/api/v1 (OpenAPI: https://gitmoon.dev/openapi.json)
- Auth: `Authorization: Bearer <API key>`. Keys look like `gitmoom_` + 64 hex characters. Create one at https://gitmoon.dev/dashboard/settings/api-keys.
- OAuth 2.1 (for MCP hosts that sign the user in): protected resource metadata at https://gitmoon.dev/.well-known/oauth-protected-resource/mcp, authorization server https://gitmoon.dev (metadata https://gitmoon.dev/.well-known/oauth-authorization-server), client registration (RFC 7591) at https://gitmoon.dev/oauth/register for known AI apps and loopback redirect URIs. PKCE S256 required.
- MCP protocol versions: 2026-07-28, 2025-11-25, 2025-06-18, 2025-03-26.

## Rules
- Every call acts as the key's owner. Repositories you create are PRIVATE unless you set visibility PUBLIC.
- GitMoon is a Git hosting platform. These tools act as the signed-in GitMoon user. Repositories are private by default. Use commit_files to write several files in one commit. run_ai_review spends the user's AI tokens: ask first. set_repository_visibility PUBLIC shows code to everyone: ask first. GitMoon has no git push/clone, no pull requests and no issues: use these tools instead. Rate limits: 60 commits per minute, 30 new repositories and 30 AI reviews per hour.
- Limits: 300 files and 15 MB per commit, 5 MB per file, read_file up to 1 MB, 30 new repositories per hour.
- Errors come back as `{ "error": { "code", "message" } }` (REST) or a tool result with isError true (MCP).

## Tools
- list_repositories: List the repositories you own on GitMoon, newest activity first. Optional text filter on the name or description.
- get_repository: Get one repository: name, visibility, default branch, branches, file count and the latest commits.
- create_repository (write): Create a new repository in your GitMoon account. It is private unless you set visibility to PUBLIC. Fails if you already have a repository with the same name.
- list_files: List the files of a repository at a branch or commit (default branch when ref is empty). Optional folder prefix.
- read_file: Read one file by path at a branch or commit. Text files come back as text; other files as base64. Files over 1 MB are not returned.
- commit_files (write): Create, update and delete several files in ONE commit on a branch of your repository. Files you do not list stay as they are. Limits: 300 files, 5 MB per file, 15 MB per commit. Send expected_head_sha to fail instead of overwriting if someone else committed first. Set create_branch to make the branch from the default branch when it does not exist.
- list_commits: List commits of a repository, newest first. Optional branch filter.
- list_branches: List the branches of a repository with their head commit.
- create_branch (write): Create a branch in your repository from another branch or a commit (default: the default branch).
- run_ai_review (write): Run GitMoon's AI on a commit of your repository: CODE_REVIEW (default), AUTO_FIX, REFACTOR or DOCGEN. This SPENDS AI tokens from your GitMoon plan (monthly quota first, then bought token packs). Ask the user before running it. Returns the review text and the tokens used.
- set_repository_visibility (write): Make your repository PUBLIC (shown in Explore, anyone can read it) or PRIVATE. Only the owner can do this. Check with the user before making code public.
- search_public_repositories: Search public repositories in GitMoon Explore by name or description. Sort: trending (Kudos this week), top (all-time Kudos) or new.

## Typical flow
1. create_repository { "name": "my-app" } (or list_repositories)
2. commit_files { "repo": "my-app", "message": "First version", "files": [{ "path": "index.html", "content": "<h1>Hi</h1>" }] }
3. create_branch { "repo": "my-app", "name": "feature/x" } then commit_files with "branch": "feature/x"
4. read_file { "repo": "my-app", "path": "index.html", "ref": "feature/x" }
5. run_ai_review { "repo": "my-app" } only after the user agrees (spends tokens)

## REST quick start
```bash
curl -H "Authorization: Bearer $GITMOON_API_KEY" https://gitmoon.dev/api/v1/repos
curl -X POST -H "Authorization: Bearer $GITMOON_API_KEY" -H "Content-Type: application/json" \
  -d '{"name":"my-app"}' https://gitmoon.dev/api/v1/repos
curl -X POST -H "Authorization: Bearer $GITMOON_API_KEY" -H "Content-Type: application/json" \
  -d '{"message":"First version","files":[{"path":"README.md","content":"# my-app"}]}' \
  https://gitmoon.dev/api/v1/repos/my-app/commits
# any tool by name, with the MCP arguments as JSON:
curl -X POST -H "Authorization: Bearer $GITMOON_API_KEY" -H "Content-Type: application/json" \
  -d '{"repo":"my-app"}' https://gitmoon.dev/api/v1/tools/list_branches
```
