feat: add HTTP server mode with updated docs and localization (#45)

- Update download instructions for clarity and consistency in all README files
- Add example configuration for HTTP mode to all README files
- Expand transport type support to include "http" in command-line flags and documentation
- Implement HTTP server mode in the application entrypoint
- Update log output behavior to include "http" mode alongside "sse" for stdout logging
- Refine Chinese README translations for greater accuracy and localization

Signed-off-by: appleboy <appleboy.tw@gmail.com>

Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/45
Co-authored-by: appleboy <appleboy.tw@gmail.com>
Co-committed-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
appleboy
2025-05-27 12:17:37 +00:00
committed by Bo-Yi Wu (吳柏毅)
parent 417ef26da0
commit f25cc0de8c
6 changed files with 95 additions and 55 deletions

View File

@@ -59,7 +59,7 @@ Optionally, you can add it to a file called `.vscode/mcp.json` in your workspace
### 📥 Download the official binary release ### 📥 Download the official binary release
You can download the official release from [here](https://gitea.com/gitea/gitea-mcp/releases). You can download the official release from [official Gitea MCP binary releases](https://gitea.com/gitea/gitea-mcp/releases).
### 🔧 Build from Source ### 🔧 Build from Source
@@ -129,6 +129,18 @@ To configure the MCP server for Gitea, add the following to your MCP configurati
} }
``` ```
- **http mode**
```json
{
"mcpServers": {
"gitea": {
"url": "http://localhost:8080/mcp"
}
}
}
```
**Default log path**: `$HOME/.gitea-mcp/gitea-mcp.log` **Default log path**: `$HOME/.gitea-mcp/gitea-mcp.log`
> [!NOTE] > [!NOTE]
@@ -145,42 +157,42 @@ list all my repositories
The Gitea MCP Server supports the following tools: The Gitea MCP Server supports the following tools:
| Tool | Scope | Description | | Tool | Scope | Description |
| :--------------------------: | :----------: | :---------------------------------------------------: | | :--------------------------: | :----------: | :------------------------------------------------------: |
| get_my_user_info | User | Get the information of the authenticated user | | get_my_user_info | User | Get the information of the authenticated user |
| get_user_orgs | User | Get organizations associated with the authenticated user | | get_user_orgs | User | Get organizations associated with the authenticated user |
| create_repo | Repository | Create a new repository | | create_repo | Repository | Create a new repository |
| fork_repo | Repository | Fork a repository | | fork_repo | Repository | Fork a repository |
| list_my_repos | Repository | List all repositories owned by the authenticated user | | list_my_repos | Repository | List all repositories owned by the authenticated user |
| create_branch | Branch | Create a new branch | | create_branch | Branch | Create a new branch |
| delete_branch | Branch | Delete a branch | | delete_branch | Branch | Delete a branch |
| list_branches | Branch | List all branches in a repository | | list_branches | Branch | List all branches in a repository |
| create_release | Release | Create a new release in a repository | | create_release | Release | Create a new release in a repository |
| delete_release | Release | Delete a release from a repository | | delete_release | Release | Delete a release from a repository |
| get_release | Release | Get a release | | get_release | Release | Get a release |
| get_latest_release | Release | Get the latest release in a repository | | get_latest_release | Release | Get the latest release in a repository |
| list_releases | Release | List all releases in a repository | | list_releases | Release | List all releases in a repository |
| create_tag | Tag | Create a new tag | | create_tag | Tag | Create a new tag |
| delete_tag | Tag | Delete a tag | | delete_tag | Tag | Delete a tag |
| get_tag | Tag | Get a tag | | get_tag | Tag | Get a tag |
| list_tags | Tag | List all tags in a repository | | list_tags | Tag | List all tags in a repository |
| list_repo_commits | Commit | List all commits in a repository | | list_repo_commits | Commit | List all commits in a repository |
| get_file_content | File | Get the content and metadata of a file | | get_file_content | File | Get the content and metadata of a file |
| create_file | File | Create a new file | | create_file | File | Create a new file |
| update_file | File | Update an existing file | | update_file | File | Update an existing file |
| delete_file | File | Delete a file | | delete_file | File | Delete a file |
| get_issue_by_index | Issue | Get an issue by its index | | get_issue_by_index | Issue | Get an issue by its index |
| list_repo_issues | Issue | List all issues in a repository | | list_repo_issues | Issue | List all issues in a repository |
| create_issue | Issue | Create a new issue | | create_issue | Issue | Create a new issue |
| create_issue_comment | Issue | Create a comment on an issue | | create_issue_comment | Issue | Create a comment on an issue |
| edit_issue | Issue | Edit a issue | | edit_issue | Issue | Edit a issue |
| get_pull_request_by_index | Pull Request | Get a pull request by its index | | get_pull_request_by_index | Pull Request | Get a pull request by its index |
| list_repo_pull_requests | Pull Request | List all pull requests in a repository | | list_repo_pull_requests | Pull Request | List all pull requests in a repository |
| create_pull_request | Pull Request | Create a new pull request | | create_pull_request | Pull Request | Create a new pull request |
| search_users | User | Search for users | | search_users | User | Search for users |
| search_org_teams | Organization | Search for teams in an organization | | search_org_teams | Organization | Search for teams in an organization |
| search_repos | Repository | Search for repositories | | search_repos | Repository | Search for repositories |
| get_gitea_mcp_server_version | Server | Get the version of the Gitea MCP Server | | get_gitea_mcp_server_version | Server | Get the version of the Gitea MCP Server |
## 🐛 Debugging ## 🐛 Debugging

View File

@@ -57,9 +57,9 @@ Model Context Protocol (MCP) 是一种协议,允许通过聊天界面整合各
} }
``` ```
### 📥 下载官方二进制版本 ### 📥 下载官方 Gitea MCP 二进制版本
您可以从[这里](https://gitea.com/gitea/gitea-mcp/releases)下载官方版本。 您可以从[官方 Gitea MCP 二进制版本](https://gitea.com/gitea/gitea-mcp/releases)下载官方版本。
### 🔧 从源代码构建 ### 🔧 从源代码构建
@@ -129,6 +129,18 @@ cp gitea-mcp /usr/local/bin/
} }
``` ```
- **http 模式**
```json
{
"mcpServers": {
"gitea": {
"url": "http://localhost:8080/mcp"
}
}
}
```
**默认日志路径**: `$HOME/.gitea-mcp/gitea-mcp.log` **默认日志路径**: `$HOME/.gitea-mcp/gitea-mcp.log`
> [!注意] > [!注意]
@@ -180,7 +192,7 @@ Gitea MCP 服务器支持以下工具:
| search_users | 用户 | 搜索用户 | | search_users | 用户 | 搜索用户 |
| search_org_teams | 组织 | 搜索组织中的团队 | | search_org_teams | 组织 | 搜索组织中的团队 |
| search_repos | 仓库 | 搜索仓库 | | search_repos | 仓库 | 搜索仓库 |
| get_gitea_mcp_server_version | 服务器 | 获取 Gitea MCP 服务器的版本 | | get_gitea_mcp_server_version | 服务器 | 获取 Gitea MCP 服务器的版本 |
## 🐛 调试 ## 🐛 调试

View File

@@ -57,9 +57,9 @@ Model Context Protocol (MCP) 是一種協議,允許通過聊天界面整合各
} }
``` ```
### 📥 下載官方二進版本 ### 📥 下載官方 Gitea MCP 二進版本
您可以從[這裡](https://gitea.com/gitea/gitea-mcp/releases)下載官方版本。 您可以從[官方 Gitea MCP 二進位版本](https://gitea.com/gitea/gitea-mcp/releases)下載官方版本。
### 🔧 從源代碼構建 ### 🔧 從源代碼構建
@@ -129,11 +129,23 @@ cp gitea-mcp /usr/local/bin/
} }
``` ```
**默認日誌路徑**: `$HOME/.gitea-mcp/gitea-mcp.log` - **http 模式**
```json
{
"mcpServers": {
"gitea": {
"url": "http://localhost:8080/mcp"
}
}
}
```
**預設日誌路徑**: `$HOME/.gitea-mcp/gitea-mcp.log`
> [!注意] > [!注意]
> 您可以通過命令參數或環境變提供您的 Gitea 主機和訪問令牌。 > 您可以通過命令參數或環境變提供您的 Gitea 主機和訪問令牌。
> 命令參數具有最高優先 > 命令參數具有最高優先
一切設置完成後,請嘗試在您的 MCP 兼容聊天框中輸入以下內容: 一切設置完成後,請嘗試在您的 MCP 兼容聊天框中輸入以下內容:
@@ -180,11 +192,11 @@ Gitea MCP 伺服器支持以下工具:
| search_users | 用戶 | 搜索用戶 | | search_users | 用戶 | 搜索用戶 |
| search_org_teams | 組織 | 搜索組織中的團隊 | | search_org_teams | 組織 | 搜索組織中的團隊 |
| search_repos | 倉庫 | 搜索倉庫 | | search_repos | 倉庫 | 搜索倉庫 |
| get_gitea_mcp_server_version | 伺服器 | 獲取 Gitea MCP 伺服器的版本 | | get_gitea_mcp_server_version | 伺服器 | 獲取 Gitea MCP 伺服器的版本 |
## 🐛 調試 ## 🐛 調試
要啟用調試模式,請在使用 sse 模式運行 Gitea MCP 伺服器時添加 `-d` 要啟用調試模式,請在使用 sse 模式運行 Gitea MCP 伺服器時添加 `-d` 標:
```sh ```sh
./gitea-mcp -t sse [--port 8080] --token <your personal access token> -d ./gitea-mcp -t sse [--port 8080] --token <your personal access token> -d

View File

@@ -21,13 +21,13 @@ func init() {
&flagPkg.Mode, &flagPkg.Mode,
"t", "t",
"stdio", "stdio",
"Transport type (stdio or sse)", "Transport type (stdio, sse or http)",
) )
flag.StringVar( flag.StringVar(
&flagPkg.Mode, &flagPkg.Mode,
"transport", "transport",
"stdio", "stdio",
"Transport type (stdio or sse)", "Transport type (stdio, sse or http)",
) )
flag.StringVar( flag.StringVar(
&host, &host,
@@ -39,7 +39,7 @@ func init() {
&port, &port,
"port", "port",
8080, 8080,
"sse port", "see or http port",
) )
flag.StringVar( flag.StringVar(
&token, &token,

View File

@@ -15,9 +15,7 @@ import (
"github.com/mark3labs/mcp-go/server" "github.com/mark3labs/mcp-go/server"
) )
var ( var mcpServer *server.MCPServer
mcpServer *server.MCPServer
)
func RegisterTool(s *server.MCPServer) { func RegisterTool(s *server.MCPServer) {
// User Tool // User Tool
@@ -55,8 +53,14 @@ func Run() error {
if err := sseServer.Start(fmt.Sprintf(":%d", flag.Port)); err != nil { if err := sseServer.Start(fmt.Sprintf(":%d", flag.Port)); err != nil {
return err return err
} }
case "http":
httpServer := server.NewStreamableHTTPServer(mcpServer)
log.Infof("Gitea MCP HTTP server listening on :%d", flag.Port)
if err := httpServer.Start(fmt.Sprintf(":%d", flag.Port)); err != nil {
return err
}
default: default:
return fmt.Errorf("invalid transport type: %s. Must be 'stdio' or 'sse'", flag.Mode) return fmt.Errorf("invalid transport type: %s. Must be 'stdio', 'sse' or 'http'", flag.Mode)
} }
return nil return nil
} }

View File

@@ -39,7 +39,7 @@ func Default() *zap.Logger {
MaxAge: 30, MaxAge: 30,
})) }))
if flag.Mode == "sse" { if flag.Mode == "http" || flag.Mode == "sse" {
wss = append(wss, zapcore.AddSync(os.Stdout)) wss = append(wss, zapcore.AddSync(os.Stdout))
} }