Gitea MCP Server is an integration plugin designed to connect Gitea with Model Context Protocol (MCP) systems. This allows for seamless command execution and repository management through an MCP-compatible chat interface.
Gitea MCP Server
A Model Context Protocol (MCP) server for reviewing Gitea pull requests.
Quick Start
1. Build the Server
dotnet build
2. Set Environment Variables
- Generate gitea private token with read/write access.
- Add token and root link in to Environmental variable (GITEA_BASE_URL, GITEA_TOKEN)
[or]
# Set your Gitea instance URL (without trailing slash)
$env:GITEA_BASE_URL = "https://your-gitea-instance.com"
# Set your Gitea personal access token (with repo read/write permissions)
$env:GITEA_TOKEN = "your-token-here"
3. Run Manual Test
Test the server directly using PowerShell:
# Navigate to project directory
cd d:\Projects\GiteaMcpServer
# Run the test script
.\test-mcp.ps1
Available Tools
Tools
The server exposes the following tools via MCP tools.list / tools.call.
-
list_pull_requests— List pull requests in a repository.- Parameters:
owner(string, optional),repo(string, optional),repository(string, optional, "owner/repo"),state(string, default "open"),summary(bool, default true),per_page(int, default 50),base_url(string, optional).
- Parameters:
-
get_pull_request_diff— Get the unified diff for a PR.- Parameters:
owner(string),repo(string),pr_number(integer),base_url(string, optional).
- Parameters:
-
get_pull_request_description— Return PRtitleanddescription. If the PR body is empty, falls back to the author's first comment.- Parameters:
owner(string),repo(string),pr_number(integer),base_url(string, optional).
- Parameters:
-
add_pull_request_comment— Add a general comment to a PR (issue comment).- Parameters:
owner(string),repo(string),pr_number(integer),body(string),base_url(string, optional).
- Parameters:
-
add_pull_request_inline_comment— Add an inline code review comment at a specific file and line. If the Gitea instance does not support inline PR comments, the server falls back to posting an issue comment that includes the file and line context.- Parameters:
owner,repo,pr_number,body,path,line(all required); optionalposition,commit_id,base_url.
- Parameters:
-
manage_pull_request_labels— Add, remove, or replace labels on a PR (issue).- Parameters:
owner,repo,pr_number(required);add_labels(array of strings),remove_labels(array of strings),set_labels(array of strings),base_url(optional).
- Parameters:
-
list_org_labels— List labels defined for an organization or repository (useful to pick labels when updating PRs).- Parameters:
owner(organization/owner, required), optionalrepo(string) to list repo labels instead,base_url(optional).
- Parameters:
-
create_branch— Create a branch in the repository (from a base branch or default branch).- Parameters:
owner,repo,new_branch(required); optionalbase_branch,base_url.
- Parameters:
-
commit_files— Commit one or more files to a branch. Each file must be provided withpathandcontent(UTF-8 plain text); the server will create or update the files.- Parameters:
owner,repo,branch,commit_message,files(array of objects withpath+content),base_url(optional).
- Parameters:
Use these tools together to inspect PRs, post suggestions (inline or general comments), modify labels, create branches and push small patch commits so suggested fixes can be reviewed.
Configuration for MCP Clients
Claude Desktop Configuration
Add to your Claude Desktop config file (%APPDATA%\Claude\claude_desktop_config.json):
{
"mcpServers": {
"gitea": {
"command": "dotnet",
"args": [
"run",
"--project",
"d:\\Projects\\GiteaMcpServer\\GiteaMcpServer.csproj"
],
"env": {
"GITEA_BASE_URL": "https://your-gitea-instance.com",
"GITEA_TOKEN": "your-token-here"
}
}
}
}
Code Studio / Cline Configuration
See the document .help
- Build and deploy the project at you local machine, take exe path.
- At codestudio Chat -> settings -> MCP Servers -> Custom Servers -> + Add Custom Server
- Paste ..\GiteaMcpServer\bin\debug\GiteaMcpServer.exe, Name the server. the below file will generate.
{
"servers": {
"Gitea_MCP_server": {
"type": "stdio",
"command": "D:\\MCPServer\\GiteaMCPServer\\GiteaMCPServer2_0\\bin\\Debug\\net10.0\\GiteaMCPServer2_0.exe",
"args": []
}
},
"inputs": []
}
Testing Tips
- Check Environment Variables: Ensure
GITEA_BASE_URLandGITEA_TOKENare set correctly - Verify Token Permissions: Your token needs read access for listing PRs and diffs, write access for comments
- Check Gitea API Version: This server is tested with Gitea v1.x API
- Monitor Logs: Server logs are written to stderr and visible in the MCP client logs
Troubleshooting
- "GITEA_BASE_URL not set": Environment variables aren't configured
- Empty PR list: Check repository name, token permissions, or PR state filter
- 401/403 errors: Token is invalid or lacks required permissions
- Connection errors: Verify GITEA_BASE_URL is correct and accessible