Skip to content

Commit 27908d4

Browse files
authored
Merge pull request #52 from doitintl/hotfix/talc/anomalies-filters-value
feat(mcp): remove anomaly filter
2 parents 2c9b386 + 3861dc8 commit 27908d4

File tree

3 files changed

+28
-42
lines changed

3 files changed

+28
-42
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@doitintl/doit-mcp-server",
3-
"version": "0.1.29",
3+
"version": "0.1.31",
44
"description": "DoiT official MCP Server",
55
"keywords": [
66
"doit",

src/tools/__tests__/anomalies.test.ts

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Top SKUs:
116116
});
117117

118118
it("should call makeDoitRequest with correct parameters and return success response", async () => {
119-
const mockArgs = { filter: "platform:gcp", pageToken: "next-page" };
119+
const mockArgs = { pageToken: "next-page" };
120120
const mockApiResponse = {
121121
rowCount: 1,
122122
anomalies: [
@@ -144,14 +144,14 @@ Top SKUs:
144144
const response = await handleAnomaliesRequest(mockArgs, mockToken);
145145

146146
expect(makeDoitRequest).toHaveBeenCalledWith(
147-
"https://api.doit.com/anomalies/v1?filter=platform%3Agcp&pageToken=next-page&maxResults=24",
147+
"https://api.doit.com/anomalies/v1?pageToken=next-page&maxResults=32",
148148
mockToken,
149149
{
150150
method: "GET",
151151
}
152152
);
153153
expect(createSuccessResponse).toHaveBeenCalledWith(
154-
expect.stringContaining("Found 1 anomalies (filtered by: platform:gcp)")
154+
expect.stringContaining("Found 1 anomalies")
155155
);
156156
expect(response).toEqual({
157157
content: [
@@ -161,7 +161,7 @@ Top SKUs:
161161
});
162162

163163
it("should handle no anomalies found", async () => {
164-
const mockArgs = { filter: "platform:aws" };
164+
const mockArgs = {};
165165
const mockApiResponse = {
166166
rowCount: 0,
167167
anomalies: [],
@@ -172,7 +172,7 @@ Top SKUs:
172172
const response = await handleAnomaliesRequest(mockArgs, mockToken);
173173

174174
expect(makeDoitRequest).toHaveBeenCalledWith(
175-
"https://api.doit.com/anomalies/v1?filter=platform%3Aaws&maxResults=24",
175+
"https://api.doit.com/anomalies/v1?maxResults=32",
176176
mockToken,
177177
{
178178
method: "GET",
@@ -191,7 +191,7 @@ Top SKUs:
191191
const response = await handleAnomaliesRequest(mockArgs, mockToken);
192192

193193
expect(makeDoitRequest).toHaveBeenCalledWith(
194-
"https://api.doit.com/anomalies/v1?maxResults=24",
194+
"https://api.doit.com/anomalies/v1?maxResults=32",
195195
mockToken,
196196
{ method: "GET" }
197197
);
@@ -203,22 +203,6 @@ Top SKUs:
203203
});
204204
});
205205

206-
it("should handle ZodError for invalid arguments", async () => {
207-
const mockArgs = { filter: 123 }; // Invalid filter type
208-
const response = await handleAnomaliesRequest(mockArgs, mockToken);
209-
210-
expect(formatZodError).toHaveBeenCalled();
211-
expect(createErrorResponse).toHaveBeenCalled();
212-
expect(response).toEqual({
213-
content: [
214-
{
215-
type: "text",
216-
text: expect.stringContaining("Formatted Zod Error:"),
217-
},
218-
],
219-
});
220-
});
221-
222206
it("should handle general errors", async () => {
223207
const mockArgs = {};
224208
(makeDoitRequest as vi.Mock).mockRejectedValue(
@@ -237,6 +221,23 @@ Top SKUs:
237221
],
238222
});
239223
});
224+
225+
it("should handle ZodError for invalid arguments", async () => {
226+
const mockArgs = { pageToken: 123 }; // Invalid argument type for Zod
227+
const response = await handleAnomaliesRequest(mockArgs, mockToken);
228+
229+
expect(createErrorResponse).toHaveBeenCalledWith(
230+
expect.stringContaining("Formatted Zod Error:")
231+
);
232+
expect(response).toEqual({
233+
content: [
234+
{
235+
type: "text",
236+
text: expect.stringContaining("Formatted Zod Error:"),
237+
},
238+
],
239+
});
240+
});
240241
});
241242

242243
describe("handleAnomalyRequest", () => {

src/tools/anomalies.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ import {
1010

1111
// Schema definitions
1212
export const AnomaliesArgumentsSchema = z.object({
13-
filter: z
14-
.string()
15-
.optional()
16-
.describe(
17-
"Filter string in format 'key:value|key:value'. Multiple values for same key are treated as OR, different keys as AND."
18-
),
1913
pageToken: z
2014
.string()
2115
.optional()
@@ -65,11 +59,6 @@ export const anomaliesTool = {
6559
inputSchema: {
6660
type: "object",
6761
properties: {
68-
filter: {
69-
type: "string",
70-
description:
71-
"Filter string in format 'key:value|key:value'. Multiple values for same key are treated as OR, different keys as AND.",
72-
},
7362
pageToken: {
7463
type: "string",
7564
description:
@@ -129,17 +118,15 @@ export function formatAnomaly(anomaly: Anomaly): string {
129118
// Handle anomalies request
130119
export async function handleAnomaliesRequest(args: any, token: string) {
131120
try {
132-
const { filter, pageToken } = AnomaliesArgumentsSchema.parse(args);
121+
const { pageToken } = AnomaliesArgumentsSchema.parse(args);
133122

134123
// Create API URL with query parameters
135124
const params = new URLSearchParams();
136-
if (filter && filter.length > 1) {
137-
params.append("filter", filter);
138-
}
125+
139126
if (pageToken && pageToken.length > 1) {
140127
params.append("pageToken", pageToken);
141128
}
142-
params.append("maxResults", "24");
129+
params.append("maxResults", "32");
143130

144131
let anomaliesUrl = `${DOIT_API_BASE}/anomalies/v1`;
145132

@@ -191,9 +178,7 @@ export async function handleAnomaliesRequest(args: any, token: string) {
191178
}));
192179

193180
let anomaliesText = `Found ${rowCount} anomalies`;
194-
if (filter) {
195-
anomaliesText += ` (filtered by: ${filter})`;
196-
}
181+
197182
anomaliesText += `:\n\n${formattedAnomalies
198183
.map((a) => JSON.stringify(a, null, 2))
199184
.join("\n")}\n\n${

0 commit comments

Comments
 (0)