@maelitop/mention-mcp-server 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +1 -0
- package/dist/api-client.js +62 -18
- package/dist/config.js +7 -0
- package/dist/index.js +6 -57
- package/dist/prompts/build-boolean-query.js +16 -33
- package/dist/prompts/index.js +4 -2
- package/dist/server.js +17 -0
- package/dist/tools/create_advanced_alert.js +33 -61
- package/dist/tools/create_basic_alert.js +36 -52
- package/dist/tools/fetch_alert_stats.js +63 -88
- package/dist/tools/fetch_mentions.js +32 -53
- package/dist/tools/get_account_info.js +20 -43
- package/dist/tools/get_alert.js +14 -34
- package/dist/tools/get_app_data.js +20 -43
- package/dist/tools/index.js +24 -55
- package/dist/tools/list_alerts.js +20 -40
- package/dist/tools/pause_alert.js +20 -35
- package/dist/tools/unpause_alert.js +20 -35
- package/dist/tools/update_alert.js +43 -54
- package/dist/types.js +9 -17
- package/package.json +3 -4
- package/dist/prompts/base.js +0 -1
- package/dist/tools/base.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.5.0] - 2026-11-25
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Every tool has a `title` and `annotations`: the read tools are marked `readOnlyHint`, `pause_alert` and `unpause_alert` `idempotentHint`, and `update_alert` `destructiveHint`, so clients no longer have to treat every tool as destructive
|
|
14
|
+
- The server returns `instructions` at initialisation; the advice to call `get_account_info` first moved there from that tool's description, which now lists what the tool returns
|
|
15
|
+
- `MENTION_READ_ONLY=true` registers only the read-only tools, so the model cannot create, update, pause or unpause alerts; `false`, an empty value or leaving it unset keeps every tool, and any other value stops the server at startup with an error naming the variable
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- `@modelcontextprotocol/sdk` upgraded from 1.12 to 1.32; the server now accepts MCP protocol version `2025-11-25`
|
|
19
|
+
- A failed tool call, such as a missing or invalid argument, an API error or an unknown tool name, returns a result with `isError: true` and a readable message instead of a JSON-RPC error, so the model can see what went wrong
|
|
20
|
+
- An unknown prompt name or invalid `build-boolean-query` arguments return an "Invalid params" error naming the problem instead of an internal error
|
|
21
|
+
|
|
22
|
+
### Removed
|
|
23
|
+
- `resources` capability, which listed no resources
|
|
24
|
+
- `zod-to-json-schema` dependency
|
|
25
|
+
- Log lines for each tool call (started, completed, failed); failed API requests are still logged
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
- A 403 keeps the reason the API gives, such as a plan without access to a feature, after "Access denied" instead of dropping it
|
|
29
|
+
- A 400 or other API error whose body carries a message shows that message and the HTTP status instead of the raw response body: form errors become one `field: message` line each, and an invalid Boolean query in `create_advanced_alert` lists each error with its line and column, one per line, instead of generic tips and an example query. A 401 and a 429 keep their fixed messages
|
|
30
|
+
- `fetch_alert_stats` describes `from` and `to` as calendar days in `timezone`, both included, whose time of day and trailing `Z` are ignored; `interval` says that `P1W` and `P1M` widen the range to whole weeks (Monday to Sunday) or months, and `timezone` that it defaults to UTC
|
|
31
|
+
- `update_alert` states that an alert's query type cannot change: the keyword fields apply only to basic alerts and `query_string` only to advanced ones, and a field of the other type rejects the whole update. It also states that a keyword list left out is kept and that an empty `required_keywords` clears it
|
|
32
|
+
|
|
10
33
|
## [1.4.1] - 2026-11-25
|
|
11
34
|
|
|
12
35
|
### Fixed
|
package/README.md
CHANGED
|
@@ -50,6 +50,7 @@ Add the following to your Claude Desktop configuration file:
|
|
|
50
50
|
| `MENTION_API_BASE_URL` | Custom API base URL | `https://web.mention.com/api` |
|
|
51
51
|
| `MCP_LOG_LEVEL` | Logging level (`debug`, `info`, `warn`, `error`) | `info` |
|
|
52
52
|
| `MCP_REQUEST_TIMEOUT` | Request timeout in milliseconds, a whole number from `1` to `2147483647` | `30000` |
|
|
53
|
+
| `MENTION_READ_ONLY` | `true` registers only the read-only tools (`get_account_info`, `get_app_data`, `list_alerts`, `get_alert`, `fetch_mentions`, `fetch_alert_stats`), so alerts cannot be created, updated, paused or unpaused; `false`, an empty value or leaving it unset registers every tool. Any other value stops the server at startup | `false` |
|
|
53
54
|
|
|
54
55
|
|
|
55
56
|
### Development
|
package/dist/api-client.js
CHANGED
|
@@ -9,6 +9,62 @@ export function apiPath(strings, ...segments) {
|
|
|
9
9
|
}
|
|
10
10
|
return String.raw({ raw: strings }, ...segments.map(encodeURIComponent));
|
|
11
11
|
}
|
|
12
|
+
function isRecord(value) {
|
|
13
|
+
return typeof value === "object" && value !== null;
|
|
14
|
+
}
|
|
15
|
+
function asText(value) {
|
|
16
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
17
|
+
}
|
|
18
|
+
function formErrors(node, path = "") {
|
|
19
|
+
if (!isRecord(node)) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
const own = Array.isArray(node.errors)
|
|
23
|
+
? node.errors.map((message) => path ? `${path}: ${asText(message)}` : asText(message))
|
|
24
|
+
: [];
|
|
25
|
+
const children = isRecord(node.children)
|
|
26
|
+
? Object.entries(node.children).flatMap(([name, child]) => formErrors(child, path ? `${path}.${name}` : name))
|
|
27
|
+
: [];
|
|
28
|
+
return [...own, ...children];
|
|
29
|
+
}
|
|
30
|
+
function formatBooleanError(error) {
|
|
31
|
+
if (!isRecord(error) || typeof error.message !== "string") {
|
|
32
|
+
return asText(error);
|
|
33
|
+
}
|
|
34
|
+
const bounds = Array.isArray(error.bounds) ? error.bounds : [];
|
|
35
|
+
const positions = bounds.flatMap((bound) => isRecord(bound) &&
|
|
36
|
+
isRecord(bound.from) &&
|
|
37
|
+
typeof bound.from.row === "number" &&
|
|
38
|
+
typeof bound.from.column === "number"
|
|
39
|
+
? [`line ${bound.from.row + 1}, column ${bound.from.column + 1}`]
|
|
40
|
+
: []);
|
|
41
|
+
return positions.length > 0 ? `${error.message} (at ${positions.join("; ")})` : error.message;
|
|
42
|
+
}
|
|
43
|
+
function errorReason(body) {
|
|
44
|
+
if (!isRecord(body)) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const booleanErrors = Array.isArray(body.boolean_errors)
|
|
48
|
+
? body.boolean_errors.map(formatBooleanError)
|
|
49
|
+
: [];
|
|
50
|
+
const formLines = formErrors(body.form).filter((line) => booleanErrors.length === 0 || !line.startsWith("query.query_string: "));
|
|
51
|
+
const lines = [...booleanErrors, ...formLines];
|
|
52
|
+
if (lines.length > 0) {
|
|
53
|
+
return lines.join("\n");
|
|
54
|
+
}
|
|
55
|
+
if (typeof body.message === "string") {
|
|
56
|
+
return body.message;
|
|
57
|
+
}
|
|
58
|
+
if (typeof body.error === "string") {
|
|
59
|
+
return body.error;
|
|
60
|
+
}
|
|
61
|
+
if (isRecord(body.error) && typeof body.error.message === "string") {
|
|
62
|
+
return typeof body.error.details === "string"
|
|
63
|
+
? `${body.error.message} - ${body.error.details}`
|
|
64
|
+
: body.error.message;
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
12
68
|
export class MentionAPIClient {
|
|
13
69
|
config;
|
|
14
70
|
userAgent;
|
|
@@ -37,7 +93,6 @@ export class MentionAPIClient {
|
|
|
37
93
|
});
|
|
38
94
|
if (!response.ok) {
|
|
39
95
|
let rawErrorData;
|
|
40
|
-
let errorMsg;
|
|
41
96
|
try {
|
|
42
97
|
rawErrorData = await response.json();
|
|
43
98
|
logError("API response error", {
|
|
@@ -49,7 +104,6 @@ export class MentionAPIClient {
|
|
|
49
104
|
});
|
|
50
105
|
}
|
|
51
106
|
catch (parseError) {
|
|
52
|
-
errorMsg = `HTTP ${response.status}: ${response.statusText}`;
|
|
53
107
|
logError("Mention API request failed - could not parse error response", {
|
|
54
108
|
requestId,
|
|
55
109
|
endpoint,
|
|
@@ -57,31 +111,21 @@ export class MentionAPIClient {
|
|
|
57
111
|
statusText: response.statusText,
|
|
58
112
|
parseError: parseError instanceof Error ? parseError.message : String(parseError),
|
|
59
113
|
});
|
|
60
|
-
throw new McpError(ErrorCode.InternalError,
|
|
61
|
-
}
|
|
62
|
-
// Try to extract error message from the response
|
|
63
|
-
if (rawErrorData && typeof rawErrorData === "object" && "error" in rawErrorData) {
|
|
64
|
-
const errorData = rawErrorData;
|
|
65
|
-
if (errorData.error?.message) {
|
|
66
|
-
errorMsg = `Mention API Error: ${errorData.error.message}${errorData.error.details ? ` - ${errorData.error.details}` : ""}`;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
errorMsg = `HTTP ${response.status}: ${response.statusText} - ${JSON.stringify(rawErrorData)}`;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
errorMsg = `HTTP ${response.status}: ${response.statusText} - ${JSON.stringify(rawErrorData)}`;
|
|
114
|
+
throw new McpError(ErrorCode.InternalError, `HTTP ${response.status}: ${response.statusText}`);
|
|
74
115
|
}
|
|
75
116
|
if (response.status === 401) {
|
|
76
117
|
throw new McpError(ErrorCode.InvalidRequest, "Invalid API key");
|
|
77
118
|
}
|
|
119
|
+
const reason = errorReason(rawErrorData);
|
|
78
120
|
if (response.status === 403) {
|
|
79
|
-
throw new McpError(ErrorCode.InvalidRequest, "Access denied");
|
|
121
|
+
throw new McpError(ErrorCode.InvalidRequest, reason ? `Access denied: ${reason}` : "Access denied");
|
|
80
122
|
}
|
|
81
123
|
if (response.status === 429) {
|
|
82
124
|
throw new McpError(ErrorCode.InternalError, "Rate limit exceeded - please try again later");
|
|
83
125
|
}
|
|
84
|
-
throw new McpError(ErrorCode.InternalError,
|
|
126
|
+
throw new McpError(ErrorCode.InternalError, reason
|
|
127
|
+
? `Mention API Error (HTTP ${response.status}): ${reason}`
|
|
128
|
+
: `HTTP ${response.status}: ${response.statusText} - ${JSON.stringify(rawErrorData)}`);
|
|
85
129
|
}
|
|
86
130
|
const responseText = await response.text();
|
|
87
131
|
const responseData = responseText ? JSON.parse(responseText) : null;
|
package/dist/config.js
CHANGED
|
@@ -7,6 +7,12 @@ function parseRequestTimeout(value) {
|
|
|
7
7
|
}
|
|
8
8
|
return timeout;
|
|
9
9
|
}
|
|
10
|
+
function parseReadOnly(value) {
|
|
11
|
+
if (value !== "true" && value !== "false") {
|
|
12
|
+
throw new Error(`MENTION_READ_ONLY must be "true" or "false", got "${value}"`);
|
|
13
|
+
}
|
|
14
|
+
return value === "true";
|
|
15
|
+
}
|
|
10
16
|
export function loadConfig() {
|
|
11
17
|
const apiKey = process.env.MENTION_API_KEY;
|
|
12
18
|
if (!apiKey) {
|
|
@@ -17,5 +23,6 @@ export function loadConfig() {
|
|
|
17
23
|
apiBaseUrl: process.env.MENTION_API_BASE_URL || "https://web.mention.com/api",
|
|
18
24
|
logLevel: process.env.MCP_LOG_LEVEL || "info",
|
|
19
25
|
requestTimeout: parseRequestTimeout(process.env.MCP_REQUEST_TIMEOUT || "30000"),
|
|
26
|
+
readOnly: parseReadOnly(process.env.MENTION_READ_ONLY || "false"),
|
|
20
27
|
};
|
|
21
28
|
}
|
package/dist/index.js
CHANGED
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
6
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
|
-
import { CallToolRequestSchema, GetPromptRequestSchema, ListPromptsRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
8
6
|
import { MentionAPIClient } from "./api-client.js";
|
|
9
7
|
import { loadConfig } from "./config.js";
|
|
10
8
|
import { logError, logInfo } from "./logger.js";
|
|
11
|
-
import {
|
|
12
|
-
import { ToolHandlers, getToolDefinitions } from "./tools/index.js";
|
|
9
|
+
import { createServer } from "./server.js";
|
|
13
10
|
const __filename = fileURLToPath(import.meta.url);
|
|
14
11
|
const __dirname = dirname(__filename);
|
|
15
12
|
function getPackageVersion() {
|
|
@@ -23,62 +20,14 @@ function getPackageVersion() {
|
|
|
23
20
|
return "1.0.0";
|
|
24
21
|
}
|
|
25
22
|
}
|
|
26
|
-
async function createServer() {
|
|
27
|
-
let config;
|
|
28
|
-
try {
|
|
29
|
-
config = loadConfig();
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
logError("Failed to load configuration", error);
|
|
33
|
-
throw error;
|
|
34
|
-
}
|
|
35
|
-
const version = getPackageVersion();
|
|
36
|
-
const apiClient = new MentionAPIClient(config, version);
|
|
37
|
-
const toolHandlers = new ToolHandlers(apiClient);
|
|
38
|
-
const server = new Server({
|
|
39
|
-
name: "mention-mcp-server",
|
|
40
|
-
version,
|
|
41
|
-
}, {
|
|
42
|
-
capabilities: {
|
|
43
|
-
tools: {},
|
|
44
|
-
resources: {},
|
|
45
|
-
prompts: {},
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
49
|
-
return {
|
|
50
|
-
tools: getToolDefinitions(),
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
54
|
-
return {
|
|
55
|
-
resources: [],
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
server.setRequestHandler(ListPromptsRequestSchema, async () => {
|
|
59
|
-
return {
|
|
60
|
-
prompts: prompts.map((prompt) => prompt.getDefinition()),
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
64
|
-
const { name, arguments: args } = request.params;
|
|
65
|
-
const prompt = prompts.find((p) => p.getDefinition().name === name);
|
|
66
|
-
if (!prompt) {
|
|
67
|
-
throw new Error(`Unknown prompt: ${name}`);
|
|
68
|
-
}
|
|
69
|
-
const handler = prompt.createHandler();
|
|
70
|
-
return await handler.handle(args);
|
|
71
|
-
});
|
|
72
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
73
|
-
const { name, arguments: args } = request.params;
|
|
74
|
-
return await toolHandlers.handleTool(name, args);
|
|
75
|
-
});
|
|
76
|
-
return server;
|
|
77
|
-
}
|
|
78
23
|
async function main() {
|
|
79
24
|
try {
|
|
80
25
|
logInfo("Starting MCP server");
|
|
81
|
-
const
|
|
26
|
+
const version = getPackageVersion();
|
|
27
|
+
const config = loadConfig();
|
|
28
|
+
const server = createServer(new MentionAPIClient(config, version), version, {
|
|
29
|
+
readOnly: config.readOnly,
|
|
30
|
+
});
|
|
82
31
|
const transport = new StdioServerTransport();
|
|
83
32
|
await server.connect(transport);
|
|
84
33
|
}
|
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
import { BuildBooleanQueryPromptArgsSchema } from "../types.js";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
],
|
|
14
|
-
};
|
|
15
|
-
},
|
|
16
|
-
createHandler() {
|
|
17
|
-
return {
|
|
18
|
-
async handle(args) {
|
|
19
|
-
const parsedArgs = BuildBooleanQueryPromptArgsSchema.parse(args);
|
|
20
|
-
return {
|
|
21
|
-
messages: [
|
|
22
|
-
{
|
|
23
|
-
role: "user",
|
|
24
|
-
content: {
|
|
25
|
-
type: "text",
|
|
26
|
-
text: `You are generating a valid Boolean query string using the following rules:
|
|
2
|
+
export function registerBuildBooleanQueryPrompt(server) {
|
|
3
|
+
server.registerPrompt("build-boolean-query", {
|
|
4
|
+
description: "Generate a valid Boolean query string using Boolean operators, quoted terms, proximity, and field selectors",
|
|
5
|
+
argsSchema: BuildBooleanQueryPromptArgsSchema.shape,
|
|
6
|
+
}, ({ instructions }) => ({
|
|
7
|
+
messages: [
|
|
8
|
+
{
|
|
9
|
+
role: "user",
|
|
10
|
+
content: {
|
|
11
|
+
type: "text",
|
|
12
|
+
text: `You are generating a valid Boolean query string using the following rules:
|
|
27
13
|
1. Combine clauses using AND, OR, and NOT. Wrap mixed clauses in parentheses.
|
|
28
14
|
2. A clause can be:
|
|
29
15
|
- A term: single word (e.g. NASA)
|
|
@@ -50,13 +36,10 @@ export const buildBooleanQueryPrompt = {
|
|
|
50
36
|
- Stop words alone not allowed in OR
|
|
51
37
|
- Max term length: 128 chars
|
|
52
38
|
Generate a Boolean query for the following:
|
|
53
|
-
${
|
|
39
|
+
${instructions}
|
|
54
40
|
`,
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
};
|
|
41
|
+
},
|
|
59
42
|
},
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
}
|
|
43
|
+
],
|
|
44
|
+
}));
|
|
45
|
+
}
|
package/dist/prompts/index.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
1
|
+
import { registerBuildBooleanQueryPrompt } from "./build-boolean-query.js";
|
|
2
|
+
export function registerPrompts(server) {
|
|
3
|
+
registerBuildBooleanQueryPrompt(server);
|
|
4
|
+
}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { registerPrompts } from "./prompts/index.js";
|
|
3
|
+
import { registerTools } from "./tools/index.js";
|
|
4
|
+
const alertAuthoringInstructions = [
|
|
5
|
+
"Call get_account_info first. Its groups give the group_id that create_basic_alert and create_advanced_alert require, and canCreateAdvancedAlert says whether the account can use create_advanced_alert; when it is false, use create_basic_alert.",
|
|
6
|
+
"get_app_data lists the language and source codes that alerts accept, and the country codes that update_alert accepts.",
|
|
7
|
+
];
|
|
8
|
+
const listAlertsInstruction = "list_alerts returns the alert IDs that the other alert, mention and stats tools take.";
|
|
9
|
+
export function createServer(apiClient, version, { readOnly }) {
|
|
10
|
+
const instructions = readOnly
|
|
11
|
+
? listAlertsInstruction
|
|
12
|
+
: [...alertAuthoringInstructions, listAlertsInstruction].join("\n");
|
|
13
|
+
const server = new McpServer({ name: "mention-mcp-server", version }, { instructions });
|
|
14
|
+
registerTools(server, apiClient, readOnly);
|
|
15
|
+
registerPrompts(server);
|
|
16
|
+
return server;
|
|
17
|
+
}
|
|
@@ -1,65 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { logError, logInfo } from "../logger.js";
|
|
1
|
+
import { logInfo } from "../logger.js";
|
|
3
2
|
import { CreateAdvancedAlertArgsSchema, CreateAlertResponseSchema } from "../types.js";
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type: "advanced",
|
|
15
|
-
query_string,
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
const rawData = await apiClient.makeRequest(`/accounts/${accountId}/alerts`, {
|
|
19
|
-
method: "POST",
|
|
20
|
-
body: JSON.stringify(requestBody),
|
|
21
|
-
});
|
|
22
|
-
const data = CreateAlertResponseSchema.parse(rawData);
|
|
23
|
-
logInfo("Advanced alert created", {
|
|
24
|
-
accountId,
|
|
25
|
-
alertName: validated.name,
|
|
26
|
-
alertId: data.alert.id,
|
|
27
|
-
});
|
|
28
|
-
return {
|
|
29
|
-
content: [
|
|
30
|
-
{
|
|
31
|
-
type: "text",
|
|
32
|
-
text: data.alert.id,
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
// Check if this is a boolean query validation error
|
|
39
|
-
if (error instanceof Error && error.message.includes("boolean_errors")) {
|
|
40
|
-
logError("Boolean query validation failed", error);
|
|
41
|
-
throw new Error(`Boolean query validation failed. Common issues:
|
|
42
|
-
- Use url:domain.com instead of domain.com for websites
|
|
43
|
-
- Ensure proper boolean operators (AND, OR, NOT)
|
|
44
|
-
- Use quotes for phrases: "cold email"
|
|
45
|
-
- Max 1700 characters
|
|
46
|
-
- Example: (Lemlist OR url:lemlist.com OR "cold email") AND -spam
|
|
47
|
-
|
|
48
|
-
Original error: ${error.message}`);
|
|
49
|
-
}
|
|
50
|
-
logError("Failed to create advanced alert", error);
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
3
|
+
export function registerCreateAdvancedAlertTool(server, apiClient) {
|
|
4
|
+
server.registerTool("create_advanced_alert", {
|
|
5
|
+
title: "Create Advanced Alert",
|
|
6
|
+
description: "Create a new advanced monitoring alert with boolean query syntax. Advanced alerts use complex query strings with boolean operators like AND, OR, NOT.",
|
|
7
|
+
inputSchema: CreateAdvancedAlertArgsSchema.shape,
|
|
8
|
+
annotations: {
|
|
9
|
+
readOnlyHint: false,
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
idempotentHint: false,
|
|
12
|
+
openWorldHint: true,
|
|
53
13
|
},
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
14
|
+
}, async ({ query_string, ...requestData }) => {
|
|
15
|
+
const accountId = await apiClient.getAccountId();
|
|
16
|
+
const requestBody = {
|
|
17
|
+
...requestData,
|
|
18
|
+
query: {
|
|
19
|
+
type: "advanced",
|
|
20
|
+
query_string,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
const rawData = await apiClient.makeRequest(`/accounts/${accountId}/alerts`, {
|
|
24
|
+
method: "POST",
|
|
25
|
+
body: JSON.stringify(requestBody),
|
|
26
|
+
});
|
|
27
|
+
const data = CreateAlertResponseSchema.parse(rawData);
|
|
28
|
+
logInfo("Advanced alert created", {
|
|
29
|
+
accountId,
|
|
30
|
+
alertName: requestData.name,
|
|
31
|
+
alertId: data.alert.id,
|
|
32
|
+
});
|
|
58
33
|
return {
|
|
59
|
-
|
|
60
|
-
description: "Create a new advanced monitoring alert with boolean query syntax. Advanced alerts use complex query strings with boolean operators like AND, OR, NOT.",
|
|
61
|
-
inputSchema: zodToJsonSchema(CreateAdvancedAlertArgsSchema),
|
|
34
|
+
content: [{ type: "text", text: data.alert.id }],
|
|
62
35
|
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -1,56 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { logError, logInfo } from "../logger.js";
|
|
1
|
+
import { logInfo } from "../logger.js";
|
|
3
2
|
import { CreateAlertResponseSchema, CreateBasicAlertArgsSchema } from "../types.js";
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type: "basic",
|
|
15
|
-
included_keywords,
|
|
16
|
-
required_keywords,
|
|
17
|
-
excluded_keywords,
|
|
18
|
-
monitored_website,
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
const rawData = await apiClient.makeRequest(`/accounts/${accountId}/alerts`, {
|
|
22
|
-
method: "POST",
|
|
23
|
-
body: JSON.stringify(requestBody),
|
|
24
|
-
});
|
|
25
|
-
const data = CreateAlertResponseSchema.parse(rawData);
|
|
26
|
-
logInfo("Basic alert created", {
|
|
27
|
-
accountId,
|
|
28
|
-
alertName: validated.name,
|
|
29
|
-
alertId: data.alert.id,
|
|
30
|
-
});
|
|
31
|
-
return {
|
|
32
|
-
content: [
|
|
33
|
-
{
|
|
34
|
-
type: "text",
|
|
35
|
-
text: data.alert.id,
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
logError("Failed to create basic alert", error);
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
3
|
+
export function registerCreateBasicAlertTool(server, apiClient) {
|
|
4
|
+
server.registerTool("create_basic_alert", {
|
|
5
|
+
title: "Create Basic Alert",
|
|
6
|
+
description: "Create a new basic monitoring alert. Basic alerts use simple keyword matching with included_keywords, required_keywords, and excluded_keywords arrays.",
|
|
7
|
+
inputSchema: CreateBasicAlertArgsSchema.shape,
|
|
8
|
+
annotations: {
|
|
9
|
+
readOnlyHint: false,
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
idempotentHint: false,
|
|
12
|
+
openWorldHint: true,
|
|
44
13
|
},
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
14
|
+
}, async ({ included_keywords, required_keywords, excluded_keywords, monitored_website, ...requestData }) => {
|
|
15
|
+
const accountId = await apiClient.getAccountId();
|
|
16
|
+
const requestBody = {
|
|
17
|
+
...requestData,
|
|
18
|
+
query: {
|
|
19
|
+
type: "basic",
|
|
20
|
+
included_keywords,
|
|
21
|
+
required_keywords,
|
|
22
|
+
excluded_keywords,
|
|
23
|
+
monitored_website,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const rawData = await apiClient.makeRequest(`/accounts/${accountId}/alerts`, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
body: JSON.stringify(requestBody),
|
|
29
|
+
});
|
|
30
|
+
const data = CreateAlertResponseSchema.parse(rawData);
|
|
31
|
+
logInfo("Basic alert created", {
|
|
32
|
+
accountId,
|
|
33
|
+
alertName: requestData.name,
|
|
34
|
+
alertId: data.alert.id,
|
|
35
|
+
});
|
|
49
36
|
return {
|
|
50
|
-
|
|
51
|
-
description: "Create a new basic monitoring alert. Basic alerts use simple keyword matching with included_keywords, required_keywords, and excluded_keywords arrays.",
|
|
52
|
-
inputSchema: zodToJsonSchema(CreateBasicAlertArgsSchema),
|
|
37
|
+
content: [{ type: "text", text: data.alert.id }],
|
|
53
38
|
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
};
|
|
39
|
+
});
|
|
40
|
+
}
|