-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmcp_server.py
More file actions
72 lines (61 loc) · 2.2 KB
/
mcp_server.py
File metadata and controls
72 lines (61 loc) · 2.2 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
import subprocess
import requests
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("BuildCheck-AI")
@mcp.tool()
def write_file(file_name: str, content: str) -> str:
"""Write content to a file."""
try:
with open(file_name, 'w', encoding='utf-8') as f:
f.write(content)
return f"Successfully wrote to {file_name}"
except Exception as e:
return f"Error writing to {file_name}: {str(e)}"
@mcp.tool()
def run_test(file_name: str) -> str:
"""Run pytest on a file."""
try:
result = subprocess.run(
["pytest", file_name],
capture_output=True,
text=True
)
if result.returncode == 0:
return f"Tests passed for {file_name}"
else:
return f"Tests failed for {file_name}\nSTDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}"
except Exception as e:
return f"Error running tests: {str(e)}"
@mcp.tool()
def report_to_boss(ticket_id: int, status: str) -> str:
"""Update a bug ticket status through the Django API."""
try:
payload = {"ticket_id": ticket_id, "status": status}
response = requests.post(
"http://localhost:8000/api/update-status/",
json=payload
)
if response.status_code == 200:
return "Successfully reported to boss"
else:
return f"Error reporting to boss: Status {response.status_code}, Response: {response.text}"
except Exception as e:
return f"Error reporting to boss: {str(e)}"
@mcp.tool()
def submit_business_lens(score: int, verdict: str) -> str:
"""IBM Bob uses this to send a Business & Monetization Evaluation to the Dashboard."""
try:
payload = {
"score": score,
"verdict": verdict
}
response = requests.post("http://localhost:8000/api/business-lens/", json=payload)
if response.status_code == 200:
return "Business evaluation successfully sent to the Dashboard!"
else:
return f"Error: Status {response.status_code}"
except Exception as e:
return f"Failed to send business evaluation: {str(e)}"
if __name__ == "__main__":
mcp.run()
# Made with Bob