Gitea MCP Multitenant Proxy Server
by homeserverhq
README.md
# Gitea MCP Multitenant Proxy Server
This repository contains a Model Context Protocol (MCP) server that acts
as a secure, multi-tenant proxy between an AI Assistant and the Gitea
backend API. It exposes **317 MCP tools** covering **23 resource domains**
with full CRUD, search, and repository management.
## โจ Features
- **๐ Identity Passthrough** โ Extracts the `Authorization: Bearer <token>`
header from incoming HTTP requests and forwards it to the Gitea API
without server-side authentication.
- **๐ฅ Multi-Tenancy** โ Uses Python `contextvars` to maintain thread-safe
user identity isolation, ensuring all AI-driven actions are scoped to
the authenticated user's permissions.
- **๐ Full Gitea Coverage** โ 317 text-only tools mapped to Gitea API
endpoints across 23 resource domains.
- **โก TOON Optimization** โ Bulk list responses are automatically compressed
using TOON (Token-Optimized Object Notation) to reduce token consumption
and maximize context window efficiency.
- **๐ Efficient Gets** โ GET responses return only commonly used fields by
default. Full objects are available via an `include_all_fields` flag.
- **๐งช Comprehensive Testing** โ 364 automated tests covering all tool
domains, run via the test runner pipeline.
- **๐ท๏ธ Tool Annotations** โ All tools expose standard MCP ToolAnnotations hints (readOnlyHint, destructiveHint, idempotentHint, openWorldHint). The tags field carries grouping metadata (basic/primary/advanced + gitea).
## ๐ง Environment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| `GITEA_BASE_URL` | Yes | Docker-internal URL of the Gitea API (e.g. `http://gitea-app:3000/api/v1`) |
| `MCP_SERVER_PORT` | Yes | Port number the MCP server listens on |
| `ALLOW_ALL_AGGREGATE` | No | When `true`, aggregate listing tools honor the `include_all_fields` parameter. When `false` (default), the parameter is silently forced to `False` for aggregate list operations. |
| `IS_STATEFUL` | No | When `true`, uses stateful Streamable HTTP with session tracking. When `false` (default), uses stateless mode. |
## ๐ฆ Installation & Local Development
1. Ensure you have Python 3.12+ installed.
2. Install dependencies:
```bash
pip install fastmcp httpx pydantic uvicorn toon-mcp-server
```
3. Run the server:
```bash
export GITEA_BASE_URL=http://gitea-app:3000/api/v1
export MCP_SERVER_PORT=80
python -m src.main
```
## ๐ณ Docker Deployment
Build and run the server using Docker:
```bash
docker build -t gitea-mcp:latest .
docker run -d --name gitea-mcp \
-e GITEA_BASE_URL="http://gitea-app:3000/api/v1" \
-e MCP_SERVER_PORT=80 \
gitea-mcp:latest
```
The MCP server serves at `http://gitea-mcp:80/mcp` (Streamable HTTP).
## โ ๏ธ Important Notes
- **๐ `include_all_fields`** โ The `include_all_fields` parameter (available
on all `get_*` and `list_*` tools) controls whether all available fields
are included in responses. Defaults to `False` for performance; set to
`True` only when additional fields are needed.
- **๐ `ALLOW_ALL_AGGREGATE`** โ Controls whether aggregate listing tools respect the `include_all_fields` parameter. When set to `false` (default), all aggregate list operations silently return only default fields regardless of the caller's request.
- **โก TOON Compression** โ All bulk list responses are automatically
compressed using TOON to reduce token consumption by 30โ60%.
- **๐ Required Fields & Defaults** โ Each `create_*` tool requires specific
key fields. `description` is mandatory on create tools that expose it, and
`body` is mandatory for issue, pull request, release, and comment creation.
All other fields default to empty strings or reasonable values. Datetime
values use ISO 8601 with an explicit offset.
## ๐ ๏ธ API Tool Mapping
The server implements 257 MCP tools organized into the following categories:
### ๐๏ธ Repositories (23 tools)
- `get_version` โ Get the Gitea server version
- `create_current_user_repo` โ Create a repository for the authenticated user
- `create_org_repo` โ Create a repository in an organization
- `create_org_repo_deprecated` โ Create a repository in an organization using the deprecated /org route
- `repo_get` โ Get a repository
- `repo_get_by_id` โ Get a repository by ID
- `repo_search` โ Search for repositories
- `repo_edit` โ Edit a repository's properties
- `repo_delete` โ Delete a repository
- `repo_migrate` โ Migrate a remote git repository
- `generate_repo` โ Create a repository using a template
- `create_fork` โ Fork a repository
- `list_forks` โ List a repository's forks
- `repo_merge_upstream` โ Merge a branch from upstream
- `repo_get_assignees` โ List users who can be assigned to issues in a repository
- `repo_get_reviewers` โ List users who can be requested as reviewers
- `repo_get_languages` โ Get repository language statistics
- `repo_get_licenses` โ Get repository licenses
- `repo_list_activity_feeds` โ List a repository's activity feeds
- `repo_get_issue_templates` โ Get available issue templates for a repository
- `repo_list_pinned_issues` โ List pinned issues
- `repo_list_pinned_pull_requests` โ List pinned pull requests
- `repo_check_assignee` โ Check whether a user can be assigned to issues in a repository
### ๐ฟ Branches & Tags (10 tools)
- `repo_list_branches` โ List repository branches
- `repo_create_branch` โ Create a branch
- `repo_delete_branch` โ Delete a branch
- `repo_get_branch` โ Get a repository branch, including effective branch protection
- `repo_rename_branch` โ Rename a branch
- `repo_list_tags` โ List repository tags
- `repo_create_tag` โ Create a git tag
- `repo_delete_tag` โ Delete a tag by name
- `repo_get_tag` โ Get a repository tag by name
- `repo_update_branch` โ Update a branch reference to a new commit
### ๐ Contents, Commits & Git (19 tools)
- `repo_get_contents_list` โ Get metadata for all entries in the repository root
- `repo_get_contents` โ Get repository file or directory contents
- `repo_create_file` โ Create a file in a repository
- `repo_update_file` โ Update a file in a repository if SHA is set, or create the file if SHA is not set
- `repo_delete_file` โ Delete a file in a repository
- `repo_change_files` โ Modify multiple files in a repository
- `repo_apply_diff_patch` โ Apply diff patch to repository
- `repo_get_all_commits` โ Get a list of all commits from a repository
- `repo_get_single_commit` โ Get a single commit from a repository, it has a GitHub-compatible alias "/repos/{owner}/{repo}/commits/{ref}"
- `repo_compare_diff` โ Get commit comparison information
- `repo_get_combined_status_by_ref` โ Get a commit's combined status, by branch/tag/commit reference
- `repo_list_statuses_by_ref` โ Get a commit's statuses, by branch/tag/commit reference
- `repo_list_statuses` โ Get a commit's statuses
- `repo_create_status` โ Create a commit status
- `get_blob` โ Get a repository blob
- `get_tree` โ Get a repository tree
- `repo_list_all_git_refs` โ List all git refs
- `repo_list_git_refs` โ List git refs matching a reference
- `get_annotated_tag` โ Get an annotated tag object
### ๐ Issues (9 tools)
- `issue_search_issues` โ Search for issues across the repositories that the user has access to
- `issue_list_issues` โ List a repository's issues
- `issue_create_issue` โ Create an issue
- `issue_get_issue` โ Get an issue
- `issue_edit_issue` โ Edit an issue
- `issue_delete` โ Delete an issue
- `issue_add_assignees` โ Add assignees to an issue
- `issue_remove_assignees` โ Remove assignees from an issue
- `issue_check_assignee` โ Check whether a user is assigned to an issue
### ๐ฌ Issue Comments & Timeline (9 tools)
- `issue_get_repo_comments` โ List issue comments across a repository
- `issue_get_comments` โ List comments on an issue
- `issue_get_comment` โ Get an issue comment by comment ID
- `issue_create_comment` โ Create a comment on an issue
- `issue_edit_comment` โ Edit a repository issue comment by comment ID
- `issue_delete_comment` โ Delete a repository issue comment by comment ID
- `issue_edit_comment_deprecated` โ Edit an issue comment by issue number and comment ID using the deprecated route
- `issue_delete_comment_deprecated` โ Delete an issue comment by issue number and comment ID using the deprecated route
- `issue_get_comments_and_timeline` โ List comments and timeline events for an issue
### ๐ท๏ธ Labels (15 tools)
- `org_list_labels` โ List organization labels
- `org_create_label` โ Create an organization label
- `org_delete_label` โ Delete an organization label
- `org_get_label` โ Get an organization label
- `org_edit_label` โ Update an organization label
- `issue_clear_labels` โ Remove all labels from an issue
- `issue_get_labels` โ List labels on an issue
- `issue_add_label` โ Add labels to an issue
- `issue_replace_labels` โ Replace labels on an issue
- `issue_remove_label` โ Remove a label from an issue
- `issue_list_labels` โ List repository labels
- `issue_create_label` โ Create a repository label
- `issue_delete_label` โ Delete a repository label
- `issue_get_label` โ Get a repository label
- `issue_edit_label` โ Update a repository label
### ๐ฏ Milestones (5 tools)
- `issue_get_milestones_list` โ Get all of a repository's opened milestones
- `issue_create_milestone` โ Create a milestone
- `issue_delete_milestone` โ Delete a milestone
- `issue_get_milestone` โ Get a milestone
- `issue_edit_milestone` โ Update a milestone
### ๐ Issue Reactions & Subscriptions (10 tools)
- `issue_delete_comment_reaction` โ Remove a reaction from a comment of an issue
- `issue_get_comment_reactions` โ Get a list of reactions from a comment of an issue
- `issue_post_comment_reaction` โ Add a reaction to a comment of an issue
- `issue_delete_issue_reaction` โ Remove a reaction from an issue
- `issue_get_issue_reactions` โ Get a list reactions of an issue
- `issue_post_issue_reaction` โ Add a reaction to an issue
- `issue_subscriptions` โ Get users who subscribed on an issue
- `issue_check_subscription` โ Check if user is subscribed to an issue
- `issue_delete_subscription` โ Unsubscribe user from issue
- `issue_add_subscription` โ Subscribe user to issue
### โฑ๏ธ Time Tracking & Stopwatches (11 tools)
- `issue_reset_time` โ Reset a tracked time of an issue
- `issue_tracked_times` โ List an issue's tracked times
- `issue_add_time` โ Add tracked time to a issue
- `issue_delete_time` โ Delete specific tracked time
- `issue_delete_stop_watch` โ Delete an issue's existing stopwatch
- `issue_start_stop_watch` โ Start stopwatch on an issue
- `issue_stop_stop_watch` โ Stop an issue's existing stopwatch
- `repo_tracked_times` โ List a repo's tracked times
- `user_tracked_times` โ List a user's tracked times in a repo
- `user_current_tracked_times` โ List the current user's tracked times
- `user_get_stop_watches` โ Get list of all existing stopwatches
### ๐ Issue Relationships & Workflow (12 tools)
- `issue_remove_issue_blocking` โ Unblock the issue given in the body by the issue in path
- `issue_list_blocks` โ List issues that are blocked by this issue
- `issue_create_issue_blocking` โ Block the issue given in the body by the issue in path
- `issue_edit_issue_deadline` โ Set an issue deadline
- `issue_remove_issue_dependencies` โ Remove an issue dependency
- `issue_list_issue_dependencies` โ List an issue's dependencies, i.e all issues that block this issue
- `issue_create_issue_dependencies` โ Make the issue in the url depend on the issue in the form
- `issue_unlock_issue` โ Unlock an issue
- `issue_lock_issue` โ Lock an issue
- `unpin_issue` โ Unpin an Issue
- `pin_issue` โ Pin an Issue
- `move_issue_pin` โ Moves the Pin to the given Position
### ๐ Pull Requests (12 tools)
- `repo_get_commit_pull_request` โ Get the merged pull request of the commit
- `repo_list_pull_requests` โ List a repo's pull requests
- `repo_create_pull_request` โ Create a pull request
- `repo_get_pull_request_by_base_head` โ Get a pull request by base and head
- `repo_get_pull_request` โ Get a pull request
- `repo_edit_pull_request` โ Update a pull request
- `repo_pull_request_is_merged` โ Check if a pull request has been merged
- `repo_merge_pull_request` โ Merge a pull request
- `repo_update_pull_request` โ Merge PR's baseBranch into headBranch
- `repo_get_pull_request_commits` โ Get commits for a pull request
- `repo_get_pull_request_files` โ Get changed files for a pull request
- `repo_cancel_scheduled_auto_merge` โ Cancel the scheduled auto merge for the given pull request
### ๐ Pull Request Reviews (13 tools)
- `repo_delete_pull_review_requests` โ Cancel review requests for a pull request
- `repo_create_pull_review_requests` โ Create review requests for a pull request
- `repo_list_pull_reviews` โ List all reviews for a pull request
- `repo_create_pull_review` โ Create a review to a pull request
- `repo_delete_pull_review` โ Delete a specific review from a pull request
- `repo_get_pull_review` โ Get a specific review for a pull request
- `repo_submit_pull_review` โ Submit a pending review to a pull request
- `repo_get_pull_review_comments` โ List comments for a specific pull request review
- `repo_dismiss_pull_review` โ Dismiss a review for a pull request
- `repo_un_dismiss_pull_review` โ Cancel to dismiss a review for a pull request
- `repo_resolve_pull_review_comment` โ Resolve a pull request review comment
- `repo_unresolve_pull_review_comment` โ Unresolve a pull request review comment
- `repo_create_pull_review_comment_reply` โ Reply to a pull request review comment
### ๐ Releases (8 tools)
- `repo_list_releases` โ List a repo's releases
- `repo_create_release` โ Create a release
- `repo_get_latest_release` โ Get the most recent non-prerelease, non-draft release of a repository, sorted by created_at
- `repo_delete_release_by_tag` โ Delete a release by tag name
- `repo_get_release_by_tag` โ Get a release by tag name
- `repo_delete_release` โ Delete a release
- `repo_get_release` โ Get a release
- `repo_edit_release` โ Update a release
### ๐ Wiki & Topics (11 tools)
- `repo_list_topics` โ Get list of topics that a repository has
- `repo_update_topics` โ Replace list of topics for a repository
- `repo_delete_topic` โ Delete a topic from a repository
- `repo_add_topic` โ Add a topic to a repository
- `repo_create_wiki_page` โ Create a wiki page
- `repo_delete_wiki_page` โ Delete a wiki page
- `repo_get_wiki_page` โ Get a wiki page
- `repo_edit_wiki_page` โ Edit a wiki page
- `repo_get_wiki_pages` โ Get all wiki pages
- `repo_get_wiki_page_revisions` โ Get revisions of a wiki page
- `topic_search` โ Search topics via keyword
### ๐ Branch & Tag Protection (11 tools)
- `repo_list_branch_protection` โ List branch protections for a repository
- `repo_create_branch_protection` โ Create a branch protections for a repository
- `repo_update_branch_protection_priorities` โ Update the priorities of branch protections for a repository
- `repo_delete_branch_protection` โ Delete a specific branch protection for the repository
- `repo_get_branch_protection` โ Get a specific branch protection for the repository
- `repo_edit_branch_protection` โ Edit a branch protections for a repository
- `repo_list_tag_protection` โ List tag protections for a repository
- `repo_create_tag_protection` โ Create a tag protections for a repository
- `repo_delete_tag_protection` โ Delete a specific tag protection for the repository
- `repo_get_tag_protection` โ Get a specific tag protection for the repository
- `repo_edit_tag_protection` โ Edit a tag protections for a repository
### ๐ฅ Collaborators, Keys & Repo Teams (14 tools)
- `repo_list_collaborators` โ List a repository's collaborators
- `repo_delete_collaborator` โ Delete a collaborator from a repository
- `repo_check_collaborator` โ Check if a user is a collaborator of a repository
- `repo_add_collaborator` โ Add or Update a collaborator to a repository
- `repo_get_repo_permissions` โ Get repository permissions for a user
- `repo_list_keys` โ List a repository's keys
- `repo_create_key` โ Add a key to a repository
- `repo_delete_key` โ Delete a key from a repository
- `repo_get_key` โ Get a repository deploy key by ID
- `repo_create_deploy_token` โ Add a deploy token to a repository, it authenticates git over HTTPS
- `repo_list_teams` โ List teams assigned to a repository
- `repo_delete_team` โ Remove a team from a repository
- `repo_check_team` โ Check whether a team is assigned to a repository
- `repo_add_team` โ Assign a team to a repository
### ๐ข Organizations (16 tools)
- `org_get_all` โ Get list of organizations
- `org_create` โ Create an organization
- `org_delete` โ Delete an organization
- `org_get` โ Get an organization
- `org_edit` โ Edit an organization
- `org_list_activity_feeds` โ List an organization's activity feeds
- `org_list_members` โ List an organization's members
- `org_delete_member` โ Remove a member from an organization
- `org_is_member` โ Check if a user is a member of an organization
- `org_list_public_members` โ List an organization's public members
- `org_conceal_member` โ Conceal a user's membership
- `org_is_public_member` โ Check if a user is a public member of an organization
- `org_publicize_member` โ Publicize a user's membership
- `rename_org` โ Rename an organization
- `org_list_repos` โ List repositories in an organization
- `org_delete_repos` โ Delete all repositories in an organization
### ๐จโ๐ฉโ๐งโ๐ฆ Teams (15 tools)
- `org_list_teams` โ List teams in an organization
- `org_create_team` โ Create a team in an organization
- `team_search` โ Search for teams in an organization
- `org_delete_team` โ Delete an organization team
- `org_get_team` โ Get an organization team
- `org_edit_team` โ Edit an organization team
- `org_list_team_activity_feeds` โ List activity feeds for an organization team
- `org_list_team_members` โ List members of an organization team
- `org_remove_team_member` โ Remove a member from an organization team
- `org_list_team_member` โ Get an organization team member
- `org_add_team_member` โ Add a member to an organization team
- `org_list_team_repos` โ List repositories assigned to an organization team
- `org_remove_team_repository` โ Remove a repository from an organization team
- `org_list_team_repo` โ Get a repository assigned to an organization team
- `org_add_team_repository` โ Assign a repository to an organization team
### ๐ค Users (19 tools)
- `user_get_current` โ Get the authenticated user
- `user_current_list_followers` โ List followers of the authenticated user
- `user_current_list_following` โ List users followed by the authenticated user
- `user_current_delete_follow` โ Unfollow a user
- `user_current_check_following` โ Check whether a user is followed by the authenticated user
- `user_current_put_follow` โ Follow a user
- `user_search` โ Search for users
- `user_get` โ Get a user by username
- `user_list_activity_feeds` โ List activity feeds for a specified user
- `user_list_followers` โ List followers of a specified user
- `user_list_following` โ List users followed by a specified user
- `user_check_following` โ Check if one user is following another user
- `user_list_gpg_keys` โ List GPG keys for a specified user
- `user_get_heatmap_data` โ Get contribution heatmap data for a specified user
- `user_list_keys` โ List public SSH keys for a specified user
- `user_list_teams` โ List teams for the authenticated user
- `org_list_current_user_orgs` โ List organizations for the authenticated user
- `org_list_user_orgs` โ List organizations for a specified user
- `org_get_user_permissions` โ Get a user's permissions in an organization
### ๐ User Repositories & Subscriptions (9 tools)
- `user_current_list_repos` โ List repositories owned by the authenticated user
- `user_list_repos` โ List repositories owned by a specified user
- `user_current_list_starred` โ List repositories starred by the authenticated user
- `user_list_starred` โ List repositories starred by a specified user
- `user_current_list_subscriptions` โ List repository subscriptions for the authenticated user
- `user_list_subscriptions` โ List repository subscriptions for a specified user
- `user_current_check_subscription` โ Check if the current user is watching a repo
- `user_current_put_subscription` โ Watch a repo
- `user_current_delete_subscription` โ Unwatch a repo
### ๐ Projects (49 tools)
- `org_list_projects` โ List projects owned by an organization
- `org_create_project` โ Create a project owned by an organization
- `org_delete_project` โ Delete a project owned by an organization
- `org_get_project` โ Get a project owned by an organization
- `org_edit_project` โ Edit a project owned by an organization
- `org_list_project_columns` โ List columns in an organization project
- `org_create_project_column` โ Create a column in an organization project
- `org_move_project_columns` โ Reorder columns in an organization project
- `org_delete_project_column` โ Delete a column in an organization project
- `org_get_project_column` โ Get a column in an organization project
- `org_edit_project_column` โ Edit a column in an organization project
- `org_set_default_project_column` โ Set the default column for an organization project
- `org_list_project_column_issues` โ List issues in an organization project column
- `org_remove_issue_from_project_column` โ Remove an issue from an organization project column
- `org_add_issue_to_project_column` โ Add an issue to an organization project column
- `org_move_project_issue` โ Move an issue between columns in an organization project
- `repo_list_projects` โ List projects owned by a repository
- `repo_create_project` โ Create a project owned by a repository
- `repo_delete_project` โ Delete a project owned by a repository
- `repo_get_project` โ Get a project owned by a repository
- `repo_edit_project` โ Edit a project owned by a repository
- `repo_list_project_columns` โ List columns in a repository project
- `repo_create_project_column` โ Create a column in a repository project
- `repo_move_project_columns` โ Reorder columns in a repository project
- `repo_delete_project_column` โ Delete a column in a repository project
- `repo_get_project_column` โ Get a column in a repository project
- `repo_edit_project_column` โ Edit a column in a repository project
- `repo_set_default_project_column` โ Set the default column for a repository project
- `repo_list_project_column_issues` โ List issues in a repository project column
- `repo_remove_issue_from_project_column` โ Remove an issue from a repository project column
- `repo_add_issue_to_project_column` โ Add an issue to a repository project column
- `repo_move_project_issue` โ Move an issue between columns in a repository project
- `user_current_list_projects` โ List projects owned by the authenticated user
- `user_current_create_project` โ Create a project owned by the authenticated user
- `user_current_delete_project` โ Delete a project owned by the authenticated user
- `user_current_get_project` โ Get a project owned by the authenticated user
- `user_current_edit_project` โ Edit a project owned by the authenticated user
- `user_current_list_project_columns` โ List columns in the authenticated user's project
- `user_current_create_project_column` โ Create a column in the authenticated user's project
- `user_current_move_project_columns` โ Reorder columns in the authenticated user's project
- `user_current_delete_project_column` โ Delete a column in the authenticated user's project
- `user_current_get_project_column` โ Get a column in the authenticated user's project
- `user_current_edit_project_column` โ Edit a column in the authenticated user's project
- `user_current_set_default_project_column` โ Set the default column for the authenticated user's project
- `user_current_list_project_column_issues` โ List issues in the authenticated user's project column
- `user_current_remove_issue_from_project_column` โ Remove an issue from the authenticated user's project column
- `user_current_add_issue_to_project_column` โ Add an issue to the authenticated user's project column
- `user_current_move_project_issue` โ Move an issue between columns in the authenticated user's project
- `user_list_projects` โ List projects owned by a specified user
### ๐ Notifications (7 tools)
- `notify_get_list` โ List notification threads for the authenticated user
- `notify_read_list` โ Mark notification threads as read, pinned, or unread
- `notify_new_available` โ Check if unread notifications exist
- `notify_get_thread` โ Get notification thread by ID
- `notify_read_thread` โ Mark notification thread as read by ID
- `notify_get_repo_list` โ List notification threads for a repository
- `notify_read_repo_list` โ Mark repository notification threads as read, pinned, or unread
### ๐ฆ Packages (10 tools)
- `list_packages` โ List all packages for an owner
- `list_package_versions` โ List all versions of a package
- `get_latest_package_version` โ Get the latest version of a package
- `link_package` โ Link a package to a repository
- `unlink_package` โ Unlink a package from a repository
- `delete_package` โ Delete a package
- `delete_package_version` โ Delete a package version
- `get_package` โ Get a package
- `list_package_files` โ List all files of a package
- `upload_generic_package` โ Upload a text file as a Gitea generic package
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues