-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathmcp_server.py
69 lines (51 loc) · 2.22 KB
/
mcp_server.py
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
from functools import lru_cache
from uuid import UUID
from mcp.server.fastmcp import FastMCP
from argus.client.sct.client import ArgusSCTClient
from sdcm.keystore import KeyStore
# Create an MCP server
mcp = FastMCP("Argus")
@lru_cache
def get_argus_client():
creds = KeyStore().get_argus_rest_credentials()
# TODO: add headers
return ArgusSCTClient(auth_token=creds["token"], base_url=creds["baseUrl"], run_id=UUID("e38b303f-df9b-4aac-b9d8-930cfd45306b"))
@mcp.tool()
def get_sct_run_status(test_id: str) -> str:
"""Get the specific sct run status from argus"""
client = get_argus_client()
return client.get_status(run_id=UUID(test_id))
@mcp.tool()
def get_sct_run_information(test_id: str) -> dict:
"""Get the specific sct run information from argus"""
client = get_argus_client()
results = client.get_run(run_id=UUID(test_id))
return dict(**results)
@mcp.tool()
def search_sct_run(query: str) -> list[dict]:
"""Search for SCT (Scylla Cluster Tests) runs using Argus search functionality.
This function allows searching through SCT test runs using various query patterns.
The search is performed against the Argus database which stores all test results.
Args:
query (str): Search query string. Supports various search patterns:
- Simple text search: "gemini", "alternator"
- Version search: "release:2024.1"
- Group search: "group:alternator"
- Test Id: "e38b303f-df9b-4aac-b9d8-930cfd45306b"
Returns:
list: A list containing search results with test runs matching the query.
Each result includes test ID, name, status, and other metadata.
Examples:
>>> # Search for all Gemini tests
>>> search_sct_run("gemini")
>>> # Search for specific version tests
>>> search_sct_run("release:2024.1")
>>> # Search by multiple criteria
>>> search_sct_run("gemini release:2024.1")
>>> # Search for specific test group
>>> search_sct_run("group:alternator")
"""
client = get_argus_client()
client.api_prefix = '/planning'
results = client.get('/search', params={'query': query}, location_params={})
return results.json()['response']['hits'][:20]