+46
-2
lines changedFilter options
+46
-2
lines changed Original file line number Diff line number Diff line change
@@ -18,6 +18,13 @@ type ListIncidentsParams struct {
18
18
func listIncidents(ctx context.Context, args ListIncidentsParams) (*incident.QueryIncidentPreviewsResponse, error) {
19
19
c := mcpgrafana.IncidentClientFromContext(ctx)
20
20
is := incident.NewIncidentsService(c)
21
+
22
+
// Set default limit to 10 if not specified
23
+
limit := args.Limit
24
+
if limit <= 0 {
25
+
limit = 10
26
+
}
27
+
21
28
query := ""
22
29
if !args.Drill {
23
30
query = "isdrill:false"
@@ -29,7 +36,7 @@ func listIncidents(ctx context.Context, args ListIncidentsParams) (*incident.Que
29
36
Query: incident.IncidentPreviewsQuery{
30
37
QueryString: query,
31
38
OrderDirection: "DESC",
32
-
Limit: args.Limit,
39
+
Limit: limit,
33
40
},
34
41
})
35
42
if err != nil {
@@ -103,12 +110,37 @@ func addActivityToIncident(ctx context.Context, args AddActivityToIncidentParams
103
110
104
111
var AddActivityToIncident = mcpgrafana.MustTool(
105
112
"add_activity_to_incident",
106
-
"Add an activity to an incident",
113
+
"Add a note to an incident's timeline. The note will appear in the incident's activity feed. Use this if there is a request to add context to an incident with a note.",
107
114
addActivityToIncident,
108
115
)
109
116
110
117
func AddIncidentTools(mcp *server.MCPServer) {
111
118
ListIncidents.Register(mcp)
112
119
CreateIncident.Register(mcp)
113
120
AddActivityToIncident.Register(mcp)
121
+
GetIncident.Register(mcp)
122
+
}
123
+
124
+
type GetIncidentParams struct {
125
+
ID string `json:"id" jsonschema:"description=The ID of the incident to retrieve"`
126
+
}
127
+
128
+
func getIncident(ctx context.Context, args GetIncidentParams) (*incident.Incident, error) {
129
+
c := mcpgrafana.IncidentClientFromContext(ctx)
130
+
is := incident.NewIncidentsService(c)
131
+
132
+
incidentResp, err := is.GetIncident(ctx, incident.GetIncidentRequest{
133
+
IncidentID: args.ID,
134
+
})
135
+
if err != nil {
136
+
return nil, fmt.Errorf("get incident by ID: %w", err)
137
+
}
138
+
139
+
return &incidentResp.Incident, nil
114
140
}
141
+
142
+
var GetIncident = mcpgrafana.MustTool(
143
+
"get_incident",
144
+
"Get a single incident by ID. Returns the full incident details including title, status, severity, and other metadata.",
145
+
getIncident,
146
+
)
Original file line number Diff line number Diff line change
@@ -50,4 +50,16 @@ func TestCloudIncidentTools(t *testing.T) {
50
50
assert.NotNil(t, result.IncidentPreviews, "IncidentPreviews should not be nil")
51
51
assert.LessOrEqual(t, len(result.IncidentPreviews), 1, "Should not return more incidents than the limit")
52
52
})
53
+
54
+
t.Run("get incident by ID", func(t *testing.T) {
55
+
ctx := createCloudTestContext(t)
56
+
result, err := getIncident(ctx, GetIncidentParams{
57
+
ID: "1",
58
+
})
59
+
require.NoError(t, err)
60
+
assert.NotNil(t, result, "Result should not be nil")
61
+
assert.Equal(t, "1", result.IncidentID, "Should return the requested incident ID")
62
+
assert.NotEmpty(t, result.Title, "Incident should have a title")
63
+
assert.NotEmpty(t, result.Status, "Incident should have a status")
64
+
})
53
65
}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4