Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@ GITLAB_TOKEN=glpat-xxxxxxxxxxxxxxxx

# 替换为您的 GitLab 实例域名
GITLAB_API_URL=gitlab.example.com

# MCP 传输配置 (可选)
# 传输类型: stdio (默认) 或 httpStream
MCP_TRANSPORT_TYPE=stdio

# HTTP Stream 配置 (仅在 MCP_TRANSPORT_TYPE=httpStream 时使用)
# 服务器端口 (默认: 3000)
MCP_PORT=3000

# API 端点路径 (默认: /mcp)
MCP_ENDPOINT=/mcp
Comment on lines +8 to +17
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Chinese comments should be translated to English or provide bilingual comments to maintain consistency with the existing English comments in the file and improve accessibility for international developers.

Copilot uses AI. Check for mistakes.
11 changes: 3 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,17 @@ jobs:
with:
node-version: '18.19.0'

- name: Install bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Create .env file
run: echo -e "GITLAB_TOKEN=glpat-xxx\nGITLAB_API_URL=https://gitlab.xxx.com" > .env

- name: Install dependencies
run: bun install
run: npm install

# 注意:单元测试已重构,不再依赖环境变量
# 所有的 API 调用都应当被模拟

- name: Build project
run: bun run build
run: npm run build

- name: Run tests
run: bun test
run: npm test
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ RUN bun install
# Build the project
RUN bun run build

# Expose a port if your MCP server uses one (optional)
# EXPOSE 8080
# Expose the default MCP port for HTTP stream mode
EXPOSE 3000

# Start the MCP server
CMD [ "node", "dist/index.js" ]
140 changes: 139 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,33 @@ A GitLab integration server built on the fastmcp framework, providing various Gi

## Quick Start

### Stdio Mode (Default)
```bash
# Install dependencies
bun install

# Build the project
bun run build

# Start the server
# Start the server with stdio transport (default)
bun run start
```

### HTTP Stream Mode (Server Deployment)
```bash
# Install dependencies
bun install

# Build the project
bun run build

# Start the server with HTTP stream transport
MCP_TRANSPORT_TYPE=httpStream MCP_PORT=3000 bun run start

# Or using command line flag
bun dist/index.js --http-stream
```

## Environment Variables

```env
Expand All @@ -54,12 +70,44 @@ GITLAB_USER_MAPPING={"username1": 123, "username2": 456}
# This can reduce API calls and ensure the correct project is used
# Example: '{"project-name-a": 1001, "group/project-b": "group/project-b"}'
GITLAB_PROJECT_MAPPING={"project-name-a": 1001, "group/project-b": "group/project-b"}

# MCP Transport Configuration (Optional)
# Transport type: stdio (default) or httpStream
MCP_TRANSPORT_TYPE=stdio

# HTTP Stream Configuration (Only used when MCP_TRANSPORT_TYPE=httpStream)
# Server port (default: 3000)
MCP_PORT=3000

# API endpoint path (default: /mcp)
MCP_ENDPOINT=/mcp
```

## Usage Examples

See [USAGE.md](./USAGE.md) for detailed examples of each tool's parameters.

## Transport Modes

This server supports two transport modes:

### 1. Stdio Transport (Default)
- Best for local development and direct integration with MCP clients
- Uses stdin/stdout for communication
- No network configuration needed

### 2. HTTP Stream Transport
- Enables server deployment for remote access
- Uses HTTP POST requests with streaming responses
- Allows multiple clients to connect to the same server instance
- Ideal for production deployments

When using HTTP Stream mode, clients can connect to:
```
POST http://localhost:3000/mcp
Content-Type: application/json
```

## Project Structure

```
Expand Down Expand Up @@ -90,6 +138,7 @@ tsconfig.json

### Claude Desktop Client

#### Stdio Mode (Default)
Add to your config:

```json
Expand All @@ -103,6 +152,27 @@ Add to your config:
}
```

#### HTTP Stream Mode (Server Deployment)
For remote server deployment, first start the server:

```bash
# On your server
MCP_TRANSPORT_TYPE=httpStream MCP_PORT=3000 npx @zephyr-mcp/gitlab
```

Then configure Claude Desktop with HTTP transport:

```json
{
"mcpServers": {
"@zephyr-mcp/gitlab": {
"command": "npx",
"args": ["@modelcontextprotocol/client-cli", "http://your-server:3000/mcp"]
}
}
}
```

### Smithery

Use directly on Smithery platform:
Expand All @@ -117,6 +187,74 @@ Environment variables:

- `GITLAB_API_URL`: Base URL of your GitLab API
- `GITLAB_TOKEN`: Access token for GitLab API authentication
- `MCP_TRANSPORT_TYPE`: Transport type (stdio/httpStream)
- `MCP_PORT`: HTTP port for HTTP stream mode
- `MCP_ENDPOINT`: HTTP endpoint path for HTTP stream mode

## Deployment

### Docker Deployment

The repository includes a Dockerfile for easy deployment:

```bash
# Build the Docker image
docker build -t gitlab-mcp-server .

# Run with environment variables
docker run -d \
-p 3000:3000 \
-e GITLAB_API_URL=https://your-gitlab-instance.com \
-e GITLAB_TOKEN=your_access_token \
-e MCP_TRANSPORT_TYPE=httpStream \
-e MCP_PORT=3000 \
gitlab-mcp-server
```

### Manual Deployment

```bash
# Install dependencies and build
npm install
npm run build

# Start the server in HTTP stream mode
export GITLAB_API_URL=https://your-gitlab-instance.com
export GITLAB_TOKEN=your_access_token
export MCP_TRANSPORT_TYPE=httpStream
export MCP_PORT=3000

# Run the server
node dist/index.js
```

### Process Manager (PM2)

```bash
# Install PM2
npm install -g pm2

# Create ecosystem file
cat > ecosystem.config.js << EOF
module.exports = {
apps: [{
name: 'gitlab-mcp-server',
script: 'dist/index.js',
env: {
GITLAB_API_URL: 'https://your-gitlab-instance.com',
GITLAB_TOKEN: 'your_access_token',
MCP_TRANSPORT_TYPE: 'httpStream',
MCP_PORT: 3000
}
}]
}
EOF

# Start with PM2
pm2 start ecosystem.config.js
pm2 save
pm2 startup
```

## Related Links

Expand Down
14 changes: 13 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
/** @type {import('ts-jest').JestConfigWithTsJest} **/
export default {
preset: 'ts-jest/presets/default-esm',
extensionsToTreatAsEsm: ['.ts'],
testEnvironment: "node",
transform: {
"^.+\.tsx?$": ["ts-jest", {}],
"^.+\.tsx?$": ["ts-jest", {
useESM: true
}],
},
setupFiles: ["<rootDir>/jest.setup.js"],
testPathIgnorePatterns: [
"<rootDir>/dist/",
"<rootDir>/node_modules/"
],
testMatch: [
"<rootDir>/src/**/__tests__/**/*.test.ts",
"<rootDir>/src/**/*.test.ts"
]
};
6 changes: 5 additions & 1 deletion jest.setup.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
require('dotenv').config();
require('dotenv').config();

// Set up test environment variables
process.env.GITLAB_TOKEN = 'test-token';
process.env.GITLAB_API_URL = 'https://test-gitlab.com';
Loading