Forgejo MCP Server

Manage Forgejo repositories and execute commands through an MCP-compatible chat interface.

Forgejo MCP Server

Connect your AI assistant to Forgejo repositories. Manage issues, pull requests, files, and more through natural language.

What It Does

Forgejo MCP Server is an integration plugin that connects Forgejo with Model Context Protocol (MCP) systems. Once configured, you can interact with your Forgejo repositories through any MCP-compatible AI assistant like Claude, Cursor, or VS Code extensions.

Example commands you can use:

  • "List all my repositories"
  • "Create an issue titled 'Bug in login page'"
  • "Show me open pull requests in my-org/my-repo"
  • "Get the contents of README.md from the main branch"
  • "Show me the latest Actions workflow runs in goern/forgejo-mcp"

Quick Start

1. Install

Option A: Using Go (Recommended)

git clone https://codeberg.org/goern/forgejo-mcp.git
cd forgejo-mcp
go install .

Ensure $GOPATH/bin (typically ~/go/bin) is in your PATH.

Note: go install codeberg.org/goern/forgejo-mcp/v2@latest does not work currently. See Known Issues.

Option B: Download Binary

Download the latest release from the releases page.

For Arch Linux, use your favorite AUR helper:

yay -S forgejo-mcp      # builds from source
yay -S forgejo-mcp-bin  # uses pre-built binary

2. Get Your Access Token

  1. Log into your Forgejo instance
  2. Go to Settings β†’ Applications β†’ Access Tokens
  3. Create a new token with the permissions you need (repo, issue, etc.)

3. Configure Your AI Assistant

Add this to your MCP configuration file:

For stdio mode (most common):

{
  "mcpServers": {
    "forgejo": {
      "command": "forgejo-mcp",
      "args": [
        "--transport", "stdio",
        "--url", "https://your-forgejo-instance.org"
      ],
      "env": {
        "FORGEJO_ACCESS_TOKEN": "<your personal access token>",
        "FORGEJO_USER_AGENT": "forgejo-mcp/1.0.0"
      }
    }
  }
}

For SSE mode (HTTP-based):

{
  "mcpServers": {
    "forgejo": {
      "url": "http://localhost:8080/sse"
    }
  }
}

When using SSE mode, start the server first:

forgejo-mcp --transport sse --url https://your-forgejo-instance.org --token <your-token>

4. Start Using It

Open your MCP-compatible AI assistant and try:

List all my repositories

Available Tools

ToolDescription
User
get_my_user_infoGet information about the authenticated user
check_notificationsCheck and list user notifications
get_notification_threadGet detailed info on a single notification thread
mark_notification_readMark a single notification thread as read
mark_all_notifications_readAcknowledge all notifications
list_repo_notificationsFilter notifications scoped to a single repository
mark_repo_notifications_readMark all notifications in a specific repo as read
search_usersSearch for users
Repositories
list_my_reposList all repositories you own
create_repoCreate a new repository
fork_repoFork a repository
search_reposSearch for repositories
Branches
list_branchesList all branches in a repository
create_branchCreate a new branch
delete_branchDelete a branch
Files
get_file_contentGet the content of a file
create_fileCreate a new file
update_fileUpdate an existing file
delete_fileDelete a file
Commits
list_repo_commitsList commits in a repository
Issues
list_repo_issuesList issues in a repository
get_issue_by_indexGet a specific issue
create_issueCreate a new issue
add_issue_labelsAdd labels to an issue (requires numeric label IDs)
update_issueUpdate an existing issue (requires numeric milestone ID)
issue_state_changeOpen or close an issue
list_repo_milestonesList milestones with their IDs (use with update_issue)
list_repo_labelsList labels with their IDs (use with add_issue_labels)
Comments
list_issue_commentsList comments on an issue or PR
get_issue_commentGet a specific comment
create_issue_commentAdd a comment to an issue or PR
edit_issue_commentEdit a comment
delete_issue_commentDelete a comment
Pull Requests
list_repo_pull_requestsList pull requests in a repository
get_pull_request_by_indexGet a specific pull request
create_pull_requestCreate a new pull request
update_pull_requestUpdate an existing pull request
list_pull_reviewsList reviews for a pull request
get_pull_reviewGet a specific pull request review
list_pull_review_commentsList comments on a pull request review
Actions
dispatch_workflowTrigger a workflow run via workflow_dispatch event
list_workflow_runsList workflow runs with optional filtering by status, event, or SHA
get_workflow_runGet details of a specific workflow run by ID
Organizations
search_org_teamsSearch for teams in an organization
Server
get_forgejo_mcp_server_versionGet the MCP server version

CLI Mode

You can invoke any tool directly from the command line without running an MCP server. This is useful for shell scripts, CI/CD pipelines, and Claude Code skills.

# List all available tools (grouped by domain)
forgejo-mcp --cli list

# Invoke a tool with JSON arguments
forgejo-mcp --cli get_issue_by_index --args '{"owner":"goern","repo":"forgejo-mcp","index":1}'

# Pipe JSON arguments via stdin
echo '{"owner":"goern","repo":"forgejo-mcp"}' | forgejo-mcp --cli list_repo_issues

# List recent workflow runs (text output)
forgejo-mcp --cli list_workflow_runs \
  --args '{"owner":"goern","repo":"forgejo-mcp"}' \
  --output=text

# List only failed runs
forgejo-mcp --cli list_workflow_runs \
  --args '{"owner":"goern","repo":"forgejo-mcp","status":"failure"}' \
  --output=text

# Show a tool's parameters
forgejo-mcp --cli create_issue --help

# Control output format (json or text)
forgejo-mcp --cli list --output=json
forgejo-mcp --cli get_my_user_info --args '{}' --output=text

CLI mode requires the same FORGEJO_URL and FORGEJO_ACCESS_TOKEN configuration as MCP server mode. Tool results are written as JSON to stdout by default; errors go to stderr with a non-zero exit code.

Configuration Options

You can configure the server using command-line arguments or environment variables:

CLI ArgumentEnvironment VariableDescription
--urlFORGEJO_URLYour Forgejo instance URL
--tokenFORGEJO_ACCESS_TOKENYour personal access token
--debugFORGEJO_DEBUGEnable debug mode
--transport-Transport mode: stdio or sse
--sse-port-Port for SSE mode (default: 8080)
--cli-Enter CLI mode for direct tool invocation
--user-agentFORGEJO_USER_AGENTHTTP User-Agent header (default: forgejo-mcp/<version>)

Command-line arguments take priority over environment variables.

Troubleshooting

Enable debug mode to see detailed logs:

forgejo-mcp --transport sse --url <url> --token <token> --debug

Or set the environment variable:

export FORGEJO_DEBUG=true

Custom User-Agent: If your Forgejo instance or proxy blocks the default go-http-client user agent, set a custom one:

# Via environment variable
export FORGEJO_USER_AGENT="forgejo-mcp/1.0.0"

# Or via CLI flag
forgejo-mcp --user-agent "forgejo-mcp/1.0.0" --transport sse --url <url> --token <token>

Getting Help

For Developers

See DEVELOPER.md for build instructions, architecture overview, and contribution guidelines.

Known Issues

  • go install ...@latest fails β€” The go.mod contains a replace directive (for a forked Forgejo SDK), which prevents remote go install. Use the clone-and-build workflow shown in Quick Start instead. Tracked in #67.

Contributors

forgejo-mcp is shaped by everyone who files issues, writes code, reviews PRs, and pushes the project forward. Thank you all. πŸ™

Code contributors

ContributorHighlights
goern (Christoph GΓΆrn)Project creator and maintainer
twstagg (Tristin Stagg)User agent configuration support (PR #89)
mattdm (Matthew Miller)Logging improvements, FORGEJO_* migration, README, URL refactor
byteflavourcheck_notifications + full notification management API (PR #84, #86); feature requests #80, #85
jesterretPull request reviews and comments support (PR #51)
appleboyCustom SSE port support, bug fixes
hiifongEarly bug fixes and updates
Lunny XiaoEarly contributions
techknowlogickEarly contributions
yp05327Early contributions
mw75Owner/org support for repo creation (PR #18)
Dax KelsonIssue comment management (PR #34)
Guruprasad KulkarniArch Linux AUR installation docs (PR #69)
Mario WolffContributions
Massimo FraschettiContributions

Community contributors

Issue reporters and discussion participants who shaped the direction of the project:

ContributorContributions
byteflavourFiled #80 (milestone/label discovery), #85 (notification API proposal); active reviewer in discussions
choucavalierFiled #82 (fix skill), #70 (macOS arm64 releases), #62 (binary releases & mise support)
MalcolmMielleFiled #59 (PR review tools β€” since implemented)
redbeardFiled #60 (Actions support β€” since implemented)
c6sepl6pFiled #72 (base64 encoding), #54 (merge pull request β€” since implemented)
malikFiled #73 (version flag), #47 (Nix build fix)
a2800276Filed #74 (OpenAI compatibility)
simenandreFiled #49 (go install support)
BasdPFiled #42 (Projects support)
BoBeR182Filed #32 (wiki support)
fraschm98Early issue reports

Cyborg contributors

This project also received contributions from AI coding agents β€” submitted as regular PRs, reviewed by humans:

AgentRoleContributions
brenner-axiom (b4-dev, B4arena)AI dev agentlist_repo_milestones, list_repo_labels tools (PR #83); race condition fix (PR #78); contributors docs (PR #87, #88); filed #76; code reviews
b4mad-release-botRelease automationAutomated changelog and release tagging
the #B4mad Renovate botDependency updatesAutomated dependency upgrades

Want to contribute? Open an issue or pull request β€” all are welcome.

License

This project is open source. See the repository for license details.

Related Servers