|
|
9 maanden geleden | |
|---|---|---|
| docs-api @ 9740f402bd | 9 maanden geleden | |
| scripts | 9 maanden geleden | |
| src | 9 maanden geleden | |
| .dockerignore | 9 maanden geleden | |
| .env.example | 9 maanden geleden | |
| .gitignore | 9 maanden geleden | |
| .gitmodules | 9 maanden geleden | |
| .mcp-gogs.json | 9 maanden geleden | |
| CHANGELOG_LABELS.md | 9 maanden geleden | |
| CLAUDE.md | 9 maanden geleden | |
| Dockerfile | 9 maanden geleden | |
| LABEL_IMPLEMENTATION_SUMMARY.md | 9 maanden geleden | |
| LICENSE | 9 maanden geleden | |
| README.md | 9 maanden geleden | |
| SERVICE.md | 9 maanden geleden | |
| USAGE_EXAMPLES.md | 9 maanden geleden | |
| docker-compose.yml | 9 maanden geleden | |
| gogs-mcp-server.service | 9 maanden geleden | |
| install-service.sh | 9 maanden geleden | |
| package-lock.json | 9 maanden geleden | |
| package.json | 9 maanden geleden | |
| tsconfig.json | 9 maanden geleden | |
| uninstall-service.sh | 9 maanden geleden |
A Model Context Protocol (MCP) server that provides access to Gogs git hosting APIs. This server enables AI assistants like Claude to interact with Gogs repositories, users, and other resources.
This MCP server provides tools to:
User Management
Repository Management
Content Access
Issue Management
Label Management
Organization Management
Team Management
Release Management
OR
Clone this repository:
git clone ssh://git@207.154.220.231:10022/claude/gogs-mcp.git
cd gogs-mcp
Install dependencies:
npm install
Build the project:
npm run build
Clone this repository:
git clone ssh://git@207.154.220.231:10022/claude/gogs-mcp.git
cd gogs-mcp
Create a .env file from the example:
cp .env.example .env
Edit .env and configure your Gogs server URL and access token:
GOGS_SERVER_URL=https://your-gogs-server.com
GOGS_ACCESS_TOKEN=your-access-token-here
Build and run with Docker Compose:
docker-compose up -d
Or build the Docker image manually:
docker build -t gogs-mcp-server .
docker run --env-file .env gogs-mcp-server
Create a .env file or set environment variables:
GOGS_SERVER_URL=https://your-gogs-server.com
GOGS_ACCESS_TOKEN=your-access-token-here
# Transport mode (optional, default: stdio)
TRANSPORT_MODE=stdio # or 'http' for HTTP/SSE transport
# HTTP server configuration (only used when TRANSPORT_MODE=http)
HTTP_PORT=3000
HTTP_HOST=0.0.0.0
The access token is optional but recommended. Without it:
The server supports two transport modes:
stdio (default): For use with MCP clients like Claude Desktop
http: For HTTP-based access with Server-Sent Events (SSE)
Add the server to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"gogs": {
"command": "node",
"args": ["/absolute/path/to/gogs-mcp-server/dist/index.js"],
"env": {
"GOGS_SERVER_URL": "https://your-gogs-server.com",
"GOGS_ACCESS_TOKEN": "your-access-token-here",
"TRANSPORT_MODE": "stdio"
}
}
}
}
To run the server in HTTP mode for web applications:
Set the transport mode to HTTP in your .env file:
TRANSPORT_MODE=http
HTTP_PORT=3000
HTTP_HOST=0.0.0.0
Start the server:
npm start
The server will be available at:
http://localhost:3000/ssehttp://localhost:3000/messagehttp://localhost:3000/healthConnect your MCP client to the SSE endpoint to establish a persistent connection.
# Set environment variables in .env
TRANSPORT_MODE=http
HTTP_PORT=3000
# Run with docker-compose
docker-compose up -d
# Or run with Docker directly
docker run -p 3000:3000 \
-e GOGS_SERVER_URL=https://your-gogs-server.com \
-e GOGS_ACCESS_TOKEN=your-access-token-here \
-e TRANSPORT_MODE=http \
-e HTTP_PORT=3000 \
gogs-mcp-server:latest
The server uses stdio transport and can be integrated with any MCP-compatible client:
# Set environment variables
export GOGS_SERVER_URL=https://your-gogs-server.com
export GOGS_ACCESS_TOKEN=your-access-token-here
export TRANSPORT_MODE=stdio
# Run the server
npm start
You can use the Docker image with MCP clients by mounting it as a command:
{
"mcpServers": {
"gogs": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e", "GOGS_SERVER_URL=https://your-gogs-server.com",
"-e", "GOGS_ACCESS_TOKEN=your-access-token-here",
"gogs-mcp-server:latest"
]
}
}
}
Or using docker-compose:
{
"mcpServers": {
"gogs": {
"command": "docker-compose",
"args": [
"-f", "/absolute/path/to/gogs-mcp-server/docker-compose.yml",
"run",
"--rm",
"gogs-mcp-server"
]
}
}
}
get_current_userGet information about the authenticated user.
get_userGet information about a specific user.
username (string, required): Username to look upsearch_usersSearch for users by username.
query (string, required): Search querylimit (number, optional): Maximum results (default: 10)list_user_repositoriesList repositories for a user.
username (string, optional): Username (omit for authenticated user)search_repositoriesSearch for repositories.
query (string, required): Search queryuid (number, optional): User ID to filter bylimit (number, optional): Maximum results (default: 10)page (number, optional): Page number (default: 1)get_repositoryGet information about a specific repository.
owner (string, required): Repository owner usernamerepo (string, required): Repository namecreate_repositoryCreate a new repository.
name (string, required): Repository namedescription (string, optional): Repository descriptionprivate (boolean, optional): Create as private (default: false)auto_init (boolean, optional): Initialize with README (default: false)gitignores (string, optional): Gitignore templates (e.g., "Go,VisualStudioCode")license (string, optional): License template (e.g., "MIT License")readme (string, optional): README template (default: "Default")delete_repositoryDelete a repository (requires admin access).
owner (string, required): Repository owner usernamerepo (string, required): Repository nameget_contentsGet file or directory contents from a repository.
owner (string, required): Repository owner usernamerepo (string, required): Repository namepath (string, required): File or directory pathref (string, optional): Branch, tag, or commit SHA (default: default branch)get_raw_contentGet raw file content from a repository.
owner (string, required): Repository owner usernamerepo (string, required): Repository nameref (string, required): Branch, tag, or commit SHApath (string, required): File pathlist_branchesList all branches in a repository.
owner (string, required): Repository owner usernamerepo (string, required): Repository nameget_commitsGet commit history from a repository.
owner (string, required): Repository owner usernamerepo (string, required): Repository namesha (string, optional): Branch name or commit SHApage (number, optional): Page number (default: 1)get_treeGet a git tree by SHA - provides low-level access to repository structure at a specific commit or tree SHA. Returns tree entries including files (blobs), directories (trees), and submodules (commits) with their modes and permissions.
owner (string, required): Repository owner usernamerepo (string, required): Repository namesha (string, required): Git tree SHA or commit SHAlist_issuesList issues in a repository.
owner (string, required): Repository owner usernamerepo (string, required): Repository namestate (string, optional): Filter by state - 'open', 'closed', or 'all' (default: 'open')labels (string, optional): Comma-separated list of label namespage (number, optional): Page number (default: 1)per_page (number, optional): Results per page (default: 30)get_issueGet a specific issue by number.
owner (string, required): Repository owner usernamerepo (string, required): Repository namenumber (number, required): Issue numbercreate_issueCreate a new issue in a repository.
owner (string, required): Repository owner usernamerepo (string, required): Repository nametitle (string, required): Issue titlebody (string, optional): Issue descriptionassignee (string, optional): Username to assign the issue tomilestone (number, optional): Milestone IDlabels (array of numbers, optional): Array of label IDsupdate_issueUpdate an existing issue (including closing or reopening).
owner (string, required): Repository owner usernamerepo (string, required): Repository namenumber (number, required): Issue numbertitle (string, optional): Issue titlebody (string, optional): Issue descriptionassignee (string, optional): Username to assign the issue tomilestone (number, optional): Milestone IDstate (string, optional): Issue state - 'open' or 'closed'labels (array of numbers, optional): Array of label IDslist_issue_commentsList all comments on an issue.
owner (string, required): Repository owner usernamerepo (string, required): Repository namenumber (number, required): Issue numbercreate_issue_commentAdd a comment to an issue.
owner (string, required): Repository owner usernamerepo (string, required): Repository namenumber (number, required): Issue numberbody (string, required): Comment textupdate_issue_commentEdit an existing comment on an issue.
owner (string, required): Repository owner usernamerepo (string, required): Repository namecommentId (number, required): Comment IDbody (string, required): Updated comment textlist_labelsList all labels in a repository.
owner (string, required): Repository owner usernamerepo (string, required): Repository nameget_labelGet a specific label by ID.
owner (string, required): Repository owner usernamerepo (string, required): Repository namelabelId (number, required): Label IDcreate_labelCreate a new label in a repository.
owner (string, required): Repository owner usernamerepo (string, required): Repository namename (string, required): Label namecolor (string, required): 7-character hex color code with leading # (e.g., #ff0000)update_labelUpdate an existing label.
owner (string, required): Repository owner usernamerepo (string, required): Repository namelabelId (number, required): Label IDname (string, optional): Label namecolor (string, optional): 7-character hex color code with leading # (e.g., #ff0000)delete_labelDelete a label from a repository.
owner (string, required): Repository owner usernamerepo (string, required): Repository namelabelId (number, required): Label IDlist_issue_labelsList all labels on a specific issue.
owner (string, required): Repository owner usernamerepo (string, required): Repository namenumber (number, required): Issue numberadd_issue_labelsAdd labels to an issue.
owner (string, required): Repository owner usernamerepo (string, required): Repository namenumber (number, required): Issue numberlabels (array of numbers, required): Array of label IDs to addremove_issue_labelRemove a specific label from an issue.
owner (string, required): Repository owner usernamerepo (string, required): Repository namenumber (number, required): Issue numberlabelId (number, required): Label ID to removereplace_issue_labelsReplace all labels on an issue with a new set.
owner (string, required): Repository owner usernamerepo (string, required): Repository namenumber (number, required): Issue numberlabels (array of numbers, required): Array of label IDs to set (replaces all existing labels)remove_all_issue_labelsRemove all labels from an issue.
owner (string, required): Repository owner usernamerepo (string, required): Repository namenumber (number, required): Issue numberlist_user_organizationsList organizations for the authenticated user.
create_organizationCreate a new organization.
username (string, required): Organization username (alphanumeric, dashes, underscores)full_name (string, optional): Organization full namedescription (string, optional): Organization descriptionwebsite (string, optional): Organization websitelocation (string, optional): Organization locationlist_public_organizationsList public organizations for a specific user.
username (string, required): Username to get public organizations forget_organizationGet information about a specific organization.
orgname (string, required): Organization nameupdate_organizationUpdate an organization (requires owner permissions).
orgname (string, required): Organization namefull_name (string, optional): Organization full namedescription (string, optional): Organization descriptionwebsite (string, optional): Organization websitelocation (string, optional): Organization locationadd_organization_memberAdd or update organization membership (requires owner permissions).
orgname (string, required): Organization nameusername (string, required): Username to add as memberrole (string, required): Member role - 'admin' or 'member'list_organization_teamsList teams in an organization.
orgname (string, required): Organization namecreate_teamCreate a new team in an organization (requires admin permissions).
orgname (string, required): Organization namename (string, required): Team name (max 30 characters, alphanumeric with dashes and dots)description (string, optional): Team description (max 255 characters)permission (string, optional): Team permission level - 'read', 'write', or 'admin' (default: 'read')get_teamGet information about a specific team.
teamId (number, required): Team IDadd_team_memberAdd a user to a team (requires admin permissions).
teamId (number, required): Team IDusername (string, required): Username to add to the teamremove_team_memberRemove a user from a team (requires admin permissions).
teamId (number, required): Team IDusername (string, required): Username to remove from the teamlist_releasesList all releases for a repository. Returns release information including tag name, name, description, author, timestamps, and downloadable assets (attachments).
owner (string, required): Repository owner usernamerepo (string, required): Repository nameNote: Currently only read-only access to releases is supported. Create, update, and delete operations are not available in the Gogs API v1.
The following Gogs API v1 endpoints are officially documented but not yet implemented in this MCP server. These represent potential features for future development:
| Category | Endpoint | Method | Description | Documentation |
|---|---|---|---|---|
| User Administration | /admin/users |
POST | Create a new user | Link |
| User Administration | /admin/users/:username |
PATCH | Edit an existing user | Link |
| User Administration | /admin/users/:username |
DELETE | Delete a user | Link |
| User Administration | /admin/users/:username/keys |
POST | Create public key for user | Link |
| Repository Administration | /admin/users/:username/repos |
POST | Create repository for user/org | Link |
| Team Administration | /admin/teams/:teamid/members |
GET | List all members of a team | Link |
| Team Administration | /admin/teams/:teamid/repos/:reponame |
PUT | Add or update team repository | Link |
| Team Administration | /admin/teams/:teamid/repos/:reponame |
DELETE | Remove team repository | Link |
| Public Keys | /users/:username/keys |
GET | List public keys for a user | Link |
| Public Keys | /user/keys |
GET | List your public keys | Link |
| Public Keys | /user/keys/:id |
GET | Get a single public key | Link |
| Public Keys | /user/keys |
POST | Create a public key | Link |
| Public Keys | /user/keys/:id |
DELETE | Delete a public key | Link |
| Deploy Keys | /repos/:username/:reponame/keys |
GET | List deploy keys | Link |
| Deploy Keys | /repos/:username/:reponame/keys/:id |
GET | Get a deploy key | Link |
| Deploy Keys | /repos/:username/:reponame/keys |
POST | Add a new deploy key | Link |
| Deploy Keys | /repos/:username/:reponame/keys/:id |
DELETE | Remove a deploy key | Link |
| Webhooks | /repos/:username/:reponame/hooks |
GET | List hooks | Link |
| Webhooks | /repos/:username/:reponame/hooks |
POST | Create a hook | Link |
| Webhooks | /repos/:username/:reponame/hooks/:id |
PATCH | Edit a hook | Link |
| Webhooks | /repos/:username/:reponame/hooks/:id |
DELETE | Delete a hook | Link |
| Collaborators | /repos/:username/:reponame/collaborators |
GET | Get collaborators | Link |
| Collaborators | /repos/:username/:reponame/collaborators/:collaborator |
PUT | Add user as a collaborator | Link |
| Collaborators | /repos/:username/:reponame/collaborators/:collaborator |
DELETE | Delete collaborator | Link |
If you'd like to help implement any of these endpoints:
src/gogs-client.ts with proper TypeScript typessrc/server.tsnpm run dev
npm run build
npm run watch
The Gogs API documentation is included in the docs-api submodule. For more information about the Gogs REST API, see:
docs-api/README.mdMake sure you've set the GOGS_SERVER_URL environment variable or included it in your MCP client configuration.
This can indicate:
MIT
Contributions are welcome! Please feel free to submit a Pull Request.