forked from sooperset/mcp-atlassian
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_simple_dev.py
More file actions
112 lines (89 loc) · 4.09 KB
/
test_simple_dev.py
File metadata and controls
112 lines (89 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python3
"""
Simple test to check what the Jira dev-status endpoint returns.
This will help debug why the MCP tool is returning empty results.
"""
import os
import json
import requests
from requests.auth import HTTPBasicAuth
def test_simple():
"""Simple test of the dev-status endpoint."""
# Get environment variables
jira_url = os.getenv("JIRA_URL")
pat = os.getenv("JIRA_PERSONAL_TOKEN")
username = os.getenv("JIRA_USERNAME")
api_token = os.getenv("JIRA_API_TOKEN")
if not jira_url:
print("JIRA_URL not set")
return
# Setup session
session = requests.Session()
# Configure auth
if pat:
print(f"Using PAT authentication")
session.headers['Authorization'] = f'Bearer {pat}'
elif username and api_token:
print(f"Using basic auth with username: {username}")
session.auth = HTTPBasicAuth(username, api_token)
else:
print("No authentication configured")
return
issue_key = "LQC-25567"
# Test the dev-status endpoint
endpoint = f"/rest/dev-status/latest/issue/detail"
params = {
"issueId": issue_key,
"applicationType": "",
"dataType": "pullrequest,branch,commit,repository"
}
full_url = f"{jira_url}{endpoint}"
print(f"\nTesting: {full_url}")
print(f"Params: {params}")
try:
response = session.get(full_url, params=params, verify=True, timeout=10)
print(f"Status: {response.status_code}")
if response.status_code == 200:
data = response.json()
print(f"Response type: {type(data)}")
# Save full response
with open(f"raw_response_{issue_key}.json", 'w') as f:
json.dump(data, f, indent=2)
print(f"Full response saved to: raw_response_{issue_key}.json")
# Analyze response
if isinstance(data, dict):
print(f"\nResponse keys: {list(data.keys())}")
if 'detail' in data:
detail = data['detail']
print(f"Detail entries: {len(detail)}")
for i, item in enumerate(detail):
print(f"\nDetail [{i}]:")
print(f" Keys: {list(item.keys())}")
if 'instances' in item:
instances = item['instances']
print(f" Instances: {len(instances)}")
for j, instance in enumerate(instances):
print(f" Instance [{j}]:")
print(f" Type: {instance.get('type', 'Unknown')}")
print(f" ID: {instance.get('id', 'Unknown')}")
print(f" Name: {instance.get('name', 'Unknown')}")
# Check for development data
prs = instance.get('pullRequests', [])
branches = instance.get('branches', [])
commits = instance.get('commits', [])
print(f" Pull Requests: {len(prs)}")
print(f" Branches: {len(branches)}")
print(f" Commits: {len(commits)}")
# Show some PR details if present
for pr in prs[:2]:
print(f" PR: {pr.get('name', 'Unknown')} - {pr.get('status', 'Unknown')}")
if 'errors' in data:
print(f"\nErrors: {data['errors']}")
else:
print(f"Error response: {response.text[:500]}")
except Exception as e:
print(f"Request failed: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
test_simple()