Skip to content

Commit 8a80c0d

Browse files
author
Nisha Saini
committed
change port
1 parent 4ebf8b4 commit 8a80c0d

File tree

9 files changed

+109
-11
lines changed

9 files changed

+109
-11
lines changed

Containerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@ RUN pip install --no-cache-dir -r requirements.txt
1010
# Copy source code (uses .containerignore)
1111
COPY . .
1212

13+
# Expose port for HTTP transport (only used when MCP_TRANSPORT=http)
14+
EXPOSE 8085
15+
1316
# Entrypoint
1417
CMD ["python", "gitlab_mcp_server.py"]

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ build:
1313
podman build -t $(IMG) .
1414

1515
# Notes:
16-
# - $(ENV_FILE) is expected to define _URL & JIRA_API_TOKEN.
16+
# - $(ENV_FILE) is expected to define the gitlab token & repos other vars are optional..
1717
# - The --tty option is used here since we might run this in a
1818
# terminal, but for the mcp.json version we don't use --tty.
1919
# - You can use Ctrl-D to quit nicely.
2020
run:
2121
@podman run -i --tty --rm --env-file $(ENV_FILE) $(IMG)
2222

23+
run-http:
24+
@echo "🌐 Starting GitLab MCP server in HTTP mode"
25+
@podman run -i --rm --env-file $(ENV_FILE) -p 8085:8085 -e MCP_TRANSPORT=http $(IMG)
26+
2327
clean:
2428
podman rmi -i $(IMG)
2529

@@ -35,6 +39,6 @@ cursor-config:
3539
# Copy the example .env file only if it doesn't exist already
3640
$(ENV_FILE):
3741
@cp example.env $@
38-
@echo "🛠️ Env file created. Edit $@ to add your Jira token"
42+
@echo "🛠️ Env file created. Edit $@ to add your GitLab token"
3943

4044
setup: build cursor-config $(ENV_FILE)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ The MCP follows:
115115
```
116116

117117
### list_pipelines
118-
```json
119-
{
118+
```json
119+
{
120120
"project_id": "123", // Required: GitLab project ID
121121
"status": "all", // running, pending, success, failed, all
122122
"limit": 20 // max results

example-http.mcp.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"mcpServers": {
3+
"gitlabMCP_HTTP": {
4+
"command": "podman",
5+
"args": [
6+
"run",
7+
"-i",
8+
"--rm",
9+
"--env-file",
10+
"~/.rh-gitlab-mcp.env",
11+
"-p",
12+
"8085:8085",
13+
"-e",
14+
"MCP_TRANSPORT=http",
15+
"localhost/gitlab-mcp:latest"
16+
],
17+
"description": "A containerized GitLab MCP server using HTTP transport",
18+
"transport": {
19+
"type": "streamable-http",
20+
"url": "http://localhost:8085"
21+
}
22+
}
23+
}
24+
}

example.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ GITLAB_URL=https://gitlab.com
1717
# Optional: Transport mode (stdio or http)
1818
MCP_TRANSPORT=stdio
1919

20+
# HTTP Transport Configuration (only used when MCP_TRANSPORT=http)
21+
MCP_HOST=127.0.0.1
22+
MCP_PORT=8085
23+
24+
# Recommended ports for multiple MCP servers:
25+
# GitLab MCP: 8086, Jira MCP: 8087, Other MCP: 8088, 8089, etc.
26+
2027
# Optional: API rate limiting
2128
MCP_MAX_API_CALLS=100
2229

example.mcp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"mcpServers": {
3-
"jiraMcp": {
3+
"gitlabMCP": {
44
"command": "podman",
55
"args": [
66
"run",

gitlab_mcp_server.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __init__(self):
5757

5858
# SSL Configuration options
5959
ssl_verify = os.getenv("MCP_SSL_VERIFY", "true").lower() == "true"
60-
ssl_ca_bundle = os.getenv("MCP_SSL_CA_BUNDLE") # Path to CA bundle file
60+
ssl_ca_bundle = os.getenv("SSL_CERT_FILE") # Path to CA bundle file
6161

6262
# Build GitLab client configuration
6363
gitlab_config = {
@@ -808,6 +808,9 @@ async def list_latest_commits(request: CommitsRequest) -> dict:
808808

809809
def main():
810810
"""Main entry point for the FastMCP server."""
811+
# Get transport mode from environment
812+
transport_mode = os.getenv("MCP_TRANSPORT", "stdio").lower()
813+
811814
print("🚀 Starting GitLab MCP Server (FastMCP - Read-Only)...")
812815
print("📋 Available Tools:")
813816
print(" 🔍 search_repositories - Search/filter repositories")
@@ -821,10 +824,24 @@ def main():
821824
print(f"🔒 Actions: {config.allowed_actions}")
822825
print(f"🔗 GitLab: {config.gitlab_url}")
823826
print("📖 Query Support: Both project_id and project_name supported for flexible access")
824-
print("\n✅ FastMCP Read-Only Server ready for connections!")
825-
826-
# Run the FastMCP server
827-
mcp.run()
827+
print(f"🚀 Transport Mode: {transport_mode.upper()}")
828+
829+
if transport_mode == "http":
830+
# HTTP Transport configuration
831+
host = os.getenv("MCP_HOST", "127.0.0.1")
832+
port = int(os.getenv("MCP_PORT", "8085"))
833+
834+
print(f"🌐 Starting HTTP server on {host}:{port}")
835+
print("\n✅ FastMCP HTTP Server ready for connections!")
836+
837+
# Run with HTTP transport
838+
mcp.run(transport="http", host=host, port=port)
839+
else:
840+
# Default STDIO transport
841+
print("\n✅ FastMCP STDIO Server ready for connections!")
842+
843+
# Run with STDIO transport (default)
844+
mcp.run()
828845

829846
if __name__ == "__main__":
830847
main()

multi-mcp-example.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"mcpServers": {
3+
"gitlabMcp": {
4+
"command": "podman",
5+
"args": [
6+
"run", "-i", "--rm", "--env-file", "~/.rh-gitlab-mcp.env",
7+
"-p", "8086:8086", "-e", "MCP_TRANSPORT=http",
8+
"localhost/gitlab-mcp:latest"
9+
],
10+
"description": "GitLab MCP server on port 8086",
11+
"transport": {
12+
"type": "streamable-http",
13+
"url": "http://localhost:8086"
14+
}
15+
},
16+
"jiraMcp": {
17+
"command": "podman",
18+
"args": [
19+
"run", "-i", "--rm", "--env-file", "~/.rh-jira-mcp.env",
20+
"-p", "8087:8087", "-e", "MCP_TRANSPORT=http", "-e", "MCP_PORT=8087",
21+
"localhost/jira-mcp:latest"
22+
],
23+
"description": "Jira MCP server on port 8087",
24+
"transport": {
25+
"type": "streamable-http",
26+
"url": "http://localhost:8087"
27+
}
28+
},
29+
"otherMcp": {
30+
"command": "podman",
31+
"args": [
32+
"run", "-i", "--rm", "--env-file", "~/.other-mcp.env",
33+
"-p", "8088:8088", "-e", "MCP_TRANSPORT=http", "-e", "MCP_PORT=8088",
34+
"localhost/other-mcp:latest"
35+
],
36+
"description": "Other MCP server on port 8088",
37+
"transport": {
38+
"type": "streamable-http",
39+
"url": "http://localhost:8088"
40+
}
41+
}
42+
}
43+
}

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fastmcp==2.11.2
2-
gitlab==1.0.2
2+
python-gitlab==4.0.0
33
pydantic==2.11.7

0 commit comments

Comments
 (0)