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
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
@@ -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`
> [!NOTE]
@@ -146,7 +158,7 @@ list all my repositories
The Gitea MCP Server supports the following tools:
| Tool | Scope | Description |
| :--------------------------: | :----------: | :---------------------------------------------------: |
| :--------------------------: | :----------: | :------------------------------------------------------: |
| get_my_user_info | User | Get the information of the authenticated user |
| get_user_orgs | User | Get organizations associated with the authenticated user |
| create_repo | Repository | Create a new repository |

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`
> [!注意]

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 兼容聊天框中輸入以下內容:
@@ -184,7 +196,7 @@ Gitea MCP 伺服器支持以下工具:
## 🐛 調試
要啟用調試模式,請在使用 sse 模式運行 Gitea MCP 伺服器時添加 `-d`
要啟用調試模式,請在使用 sse 模式運行 Gitea MCP 伺服器時添加 `-d` 標:
```sh
./gitea-mcp -t sse [--port 8080] --token <your personal access token> -d

View File

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

View File

@@ -15,9 +15,7 @@ import (
"github.com/mark3labs/mcp-go/server"
)
var (
mcpServer *server.MCPServer
)
var mcpServer *server.MCPServer
func RegisterTool(s *server.MCPServer) {
// User Tool
@@ -55,8 +53,14 @@ func Run() error {
if err := sseServer.Start(fmt.Sprintf(":%d", flag.Port)); err != nil {
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:
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
}

View File

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