Skip to main content
Glama

Jira-GitLab MCP Server

by gabbar910
simple_gitlab_test.pyโ€ข5.96 kB
#!/usr/bin/env python3 """ Simple GitLab connectivity test """ import asyncio import json async def test_gitlab_basic(): """Test basic GitLab functionality without MCP server""" try: from connectors.gitlab_client import GitLabClient from utils.config import load_config print("๐Ÿ”ง Loading configuration...") config = load_config() print("๐Ÿ”— Testing GitLab connection...") gitlab_client = GitLabClient(config["gitlab"]) # Test connection connection_ok = await gitlab_client.test_connection() print(f"Connection: {'โœ… SUCCESS' if connection_ok else 'โŒ FAILED'}") if not connection_ok: return False # Test getting projects print("\n๐Ÿ“‹ Testing project access...") projects = await gitlab_client.get_projects() print(f"Projects found: {len(projects)}") if len(projects) == 0: print("โš ๏ธ No projects found. This could mean:") print(" - Your token doesn't have access to any projects") print(" - You need to be added to projects in GitLab") print(" - The GitLab instance has no projects") # Try getting all projects (not just owned) print("\n๐Ÿ” Trying to get all accessible projects...") all_projects = await gitlab_client.get_projects(owned=False) print(f"All accessible projects: {len(all_projects)}") if len(all_projects) > 0: print("โœ… Found some accessible projects!") projects = all_projects # Show project details for i, project in enumerate(projects[:3]): print(f"\n๐Ÿ“ Project {i+1}:") print(f" Name: {project['name']}") print(f" ID: {project['id']}") print(f" URL: {project['web_url']}") print(f" Default branch: {project['default_branch']}") print(f" Visibility: {project['visibility']}") # Test branch creation simulation if projects: test_project = projects[0] print(f"\n๐ŸŒฟ Testing branch operations on '{test_project['name']}'...") # Get existing branches branches = await gitlab_client.get_branches(test_project['id']) print(f" Existing branches: {len(branches)}") # Show some branches for branch in branches[:3]: status = "๐Ÿ”’" if branch['protected'] else "๐Ÿ”“" default = "โญ" if branch['default'] else " " print(f" {default} {status} {branch['name']}") # Simulate what would happen with branch creation test_branch = "feature/TEST-123-fix" existing = any(b['name'] == test_branch for b in branches) if existing: print(f" โš ๏ธ Branch '{test_branch}' already exists") else: print(f" โœ… Branch '{test_branch}' can be created") print(f" ๐Ÿ“ Would create: {test_project['web_url']}/-/tree/{test_branch}") return True except Exception as e: print(f"โŒ Error: {e}") import traceback traceback.print_exc() return False async def test_mcp_tools_simulation(): """Simulate MCP tool functionality""" try: print("\n๐Ÿ› ๏ธ Simulating MCP Tools...") # Simulate the create_branch_for_issue tool print("\n๐Ÿ”ง Tool: create_branch_for_issue") print(" Input: issue_key='PROJ-123', project_id=1") print(" Expected branch name: feature/PROJ-123-fix") print(" Expected output: Branch URL + Jira comment") # Simulate the get_jira_issues tool print("\n๐Ÿ”ง Tool: get_jira_issues") print(" Input: jql='project = DEMO AND status = \"To Do\"'") print(" Expected output: List of matching issues") # Simulate the comment_on_issue tool print("\n๐Ÿ”ง Tool: comment_on_issue") print(" Input: issue_key='PROJ-123', comment='Branch created: [URL]'") print(" Expected output: Success confirmation") return True except Exception as e: print(f"โŒ Error in MCP simulation: {e}") return False async def main(): print("๐Ÿงช Simple GitLab MCP Server Test") print("=" * 40) # Test 1: Basic GitLab functionality gitlab_ok = await test_gitlab_basic() # Test 2: MCP tools simulation mcp_ok = await test_mcp_tools_simulation() print("\n" + "=" * 40) print("๐Ÿ“Š Test Summary:") print(f"GitLab Connection: {'โœ… PASS' if gitlab_ok else 'โŒ FAIL'}") print(f"MCP Tools Ready: {'โœ… PASS' if mcp_ok else 'โŒ FAIL'}") if gitlab_ok and mcp_ok: print("\n๐ŸŽ‰ Your GitLab MCP server is ready!") print("\n๐Ÿ’ก What this means:") print(" โœ… GitLab connection is working") print(" โœ… Authentication is successful") print(" โœ… API access is functional") print(" โœ… MCP server can be started") print("\n๐Ÿš€ Next steps:") print(" 1. Add your Jira API token to config.json") print(" 2. Run: python mcp_server.py") print(" 3. Connect your AI agent to the MCP server") if gitlab_ok: print("\n๐Ÿ“ Available for AI agents:") print(" - Create GitLab branches for Jira issues") print(" - Link branches back to Jira with comments") print(" - Query GitLab projects and branches") print(" - Automated DevOps workflows") else: print("\n๐Ÿ”ง Issues found - please check the errors above") if __name__ == "__main__": asyncio.run(main())

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gabbar910/MCPJiraGitlab'

If you have feedback or need assistance with the MCP directory API, please join our Discord server