Skip to content

Claude Code CLI Integration ​

Configure GitLab MCP for Claude Code (CLI).

Auto-Setup ​

bash
npx @structured-world/gitlab-mcp install --claude-code

Detection ​

MethodDetails
TypeCLI command
Commandclaude
Auto-detectedYes (when claude is in PATH)

Config File Location ​

OSPath
macOS~/.claude.json
Windows%USERPROFILE%\.claude.json
Linux~/.claude.json

Configuration ​

Add to your ~/.claude.json:

json
{
  "mcpServers": {
    "gitlab": {
      "command": "npx",
      "args": ["-y", "@structured-world/gitlab-mcp"],
      "env": {
        "GITLAB_TOKEN": "glpat-xxxxxxxxxxxxxxxxxxxx",
        "GITLAB_API_URL": "https://gitlab.com"
      }
    }
  }
}

CLI Installation ​

Claude Code also supports adding MCP servers via CLI:

bash
claude mcp add gitlab -- npx -y @structured-world/gitlab-mcp

Set environment variables separately in your shell profile or .env file.

Remote Server ​

Connect to a running GitLab MCP HTTP server:

json
{
  "mcpServers": {
    "gitlab": {
      "type": "http",
      "url": "http://localhost:3333/mcp"
    }
  }
}

Alternatively, use Claude Code's native registration and browser sign-in:

bash
claude mcp add --transport http gitlab https://mcp.example.com/mcp

Run /mcp in Claude Code to authenticate an OAuth server. Registration defaults to the current project's local scope; add --scope user for all your projects. See the official MCP configuration guide.

Verification ​

bash
# Start Claude Code and check available tools
claude

# Within Claude Code, ask:
# "List available GitLab tools"

Troubleshooting ​

  • Server not loading: Restart Claude Code session after config changes
  • "Command not found": Ensure npx is available (Node.js >= 24)
  • Permission issues: Check file permissions on ~/.claude.json

See Also ​

Released under the Apache 2.0 License.