newrelic-mcp 1.0.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/LICENSE +21 -0
- package/README.md +430 -0
- package/dist/client/newrelic-client.d.ts +40 -0
- package/dist/client/newrelic-client.d.ts.map +1 -0
- package/dist/client/newrelic-client.js +173 -0
- package/dist/client/newrelic-client.js.map +1 -0
- package/dist/server.d.ts +24 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +204 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/alert.d.ts +14 -0
- package/dist/tools/alert.d.ts.map +1 -0
- package/dist/tools/alert.js +183 -0
- package/dist/tools/alert.js.map +1 -0
- package/dist/tools/apm.d.ts +9 -0
- package/dist/tools/apm.d.ts.map +1 -0
- package/dist/tools/apm.js +33 -0
- package/dist/tools/apm.js.map +1 -0
- package/dist/tools/entity.d.ts +11 -0
- package/dist/tools/entity.d.ts.map +1 -0
- package/dist/tools/entity.js +140 -0
- package/dist/tools/entity.js.map +1 -0
- package/dist/tools/nerdgraph.d.ts +9 -0
- package/dist/tools/nerdgraph.d.ts.map +1 -0
- package/dist/tools/nerdgraph.js +33 -0
- package/dist/tools/nerdgraph.js.map +1 -0
- package/dist/tools/nrql.d.ts +25 -0
- package/dist/tools/nrql.d.ts.map +1 -0
- package/dist/tools/nrql.js +58 -0
- package/dist/tools/nrql.js.map +1 -0
- package/dist/tools/synthetics.d.ts +12 -0
- package/dist/tools/synthetics.d.ts.map +1 -0
- package/dist/tools/synthetics.js +149 -0
- package/dist/tools/synthetics.js.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAIA,OAAO,EAKL,KAAK,IAAI,EACV,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAQ1D,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,gBAAgB,CAAC,CAAS;gBAEtB,MAAM,CAAC,EAAE,cAAc;IA0BnC,OAAO,CAAC,aAAa;IAwCrB,OAAO,CAAC,aAAa;IA6Bf,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAYtB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IA6DxD,OAAO,CAAC,iBAAiB;IAczB,WAAW;;;;;IAQX,kBAAkB,IAAI,MAAM,EAAE;IAI9B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAIvC,mBAAmB,IAAI,MAAM,GAAG,SAAS;CAG1C"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.NewRelicMCPServer = void 0;
|
|
5
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
6
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
7
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
8
|
+
const newrelic_client_1 = require("./client/newrelic-client");
|
|
9
|
+
const alert_1 = require("./tools/alert");
|
|
10
|
+
const apm_1 = require("./tools/apm");
|
|
11
|
+
const entity_1 = require("./tools/entity");
|
|
12
|
+
const nerdgraph_1 = require("./tools/nerdgraph");
|
|
13
|
+
const nrql_1 = require("./tools/nrql");
|
|
14
|
+
const synthetics_1 = require("./tools/synthetics");
|
|
15
|
+
class NewRelicMCPServer {
|
|
16
|
+
server;
|
|
17
|
+
client;
|
|
18
|
+
tools;
|
|
19
|
+
defaultAccountId;
|
|
20
|
+
constructor(client) {
|
|
21
|
+
if (!process.env.NEW_RELIC_API_KEY) {
|
|
22
|
+
throw new Error('NEW_RELIC_API_KEY is required');
|
|
23
|
+
}
|
|
24
|
+
this.defaultAccountId = process.env.NEW_RELIC_ACCOUNT_ID;
|
|
25
|
+
this.client =
|
|
26
|
+
client || new newrelic_client_1.NewRelicClient(process.env.NEW_RELIC_API_KEY, this.defaultAccountId);
|
|
27
|
+
this.server = new index_js_1.Server({
|
|
28
|
+
name: 'newrelic-mcp',
|
|
29
|
+
version: '1.0.0',
|
|
30
|
+
}, {
|
|
31
|
+
capabilities: {
|
|
32
|
+
tools: {},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
this.tools = new Map();
|
|
36
|
+
this.registerTools();
|
|
37
|
+
this.setupHandlers();
|
|
38
|
+
}
|
|
39
|
+
registerTools() {
|
|
40
|
+
const nrqlTool = new nrql_1.NrqlTool(this.client);
|
|
41
|
+
const apmTool = new apm_1.ApmTool(this.client);
|
|
42
|
+
const entityTool = new entity_1.EntityTool(this.client);
|
|
43
|
+
const alertTool = new alert_1.AlertTool(this.client);
|
|
44
|
+
const syntheticsTool = new synthetics_1.SyntheticsTool(this.client);
|
|
45
|
+
const nerdGraphTool = new nerdgraph_1.NerdGraphTool(this.client);
|
|
46
|
+
// Register all tools
|
|
47
|
+
const tools = [
|
|
48
|
+
nrqlTool.getToolDefinition(),
|
|
49
|
+
apmTool.getListApplicationsTool(),
|
|
50
|
+
entityTool.getSearchTool(),
|
|
51
|
+
entityTool.getDetailsTool(),
|
|
52
|
+
alertTool.getPoliciesTool(),
|
|
53
|
+
alertTool.getIncidentsTool(),
|
|
54
|
+
alertTool.getAcknowledgeTool(),
|
|
55
|
+
syntheticsTool.getListMonitorsTool(),
|
|
56
|
+
syntheticsTool.getCreateMonitorTool(),
|
|
57
|
+
nerdGraphTool.getQueryTool(),
|
|
58
|
+
{
|
|
59
|
+
name: 'get_account_details',
|
|
60
|
+
description: 'Get New Relic account details',
|
|
61
|
+
inputSchema: {
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {
|
|
64
|
+
target_account_id: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
description: 'Optional account ID to get details for',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
tools.forEach((tool) => {
|
|
73
|
+
this.tools.set(tool.name, tool);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
setupHandlers() {
|
|
77
|
+
this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
|
|
78
|
+
tools: Array.from(this.tools.values()),
|
|
79
|
+
}));
|
|
80
|
+
this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
81
|
+
const tool = this.tools.get(request.params.name);
|
|
82
|
+
if (!tool) {
|
|
83
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.MethodNotFound, `Tool ${request.params.name} not found`);
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
const result = await this.executeTool(request.params.name, request.params.arguments || {});
|
|
87
|
+
return {
|
|
88
|
+
content: [
|
|
89
|
+
{
|
|
90
|
+
type: 'text',
|
|
91
|
+
text: JSON.stringify(result, null, 2),
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, error.message || 'Tool execution failed');
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
async start() {
|
|
102
|
+
const isValid = await this.client.validateCredentials();
|
|
103
|
+
if (!isValid) {
|
|
104
|
+
throw new Error('Invalid New Relic API credentials');
|
|
105
|
+
}
|
|
106
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
107
|
+
await this.server.connect(transport);
|
|
108
|
+
console.error('New Relic MCP Server started');
|
|
109
|
+
}
|
|
110
|
+
async executeTool(name, args) {
|
|
111
|
+
const accountId = args.target_account_id || args.account_id || this.defaultAccountId;
|
|
112
|
+
if (!accountId && this.requiresAccountId(name)) {
|
|
113
|
+
throw new Error('Account ID must be provided');
|
|
114
|
+
}
|
|
115
|
+
switch (name) {
|
|
116
|
+
case 'run_nrql_query':
|
|
117
|
+
return await new nrql_1.NrqlTool(this.client).execute({
|
|
118
|
+
...args,
|
|
119
|
+
target_account_id: accountId,
|
|
120
|
+
});
|
|
121
|
+
case 'list_apm_applications':
|
|
122
|
+
return await new apm_1.ApmTool(this.client).execute({
|
|
123
|
+
...args,
|
|
124
|
+
target_account_id: accountId,
|
|
125
|
+
});
|
|
126
|
+
case 'get_account_details':
|
|
127
|
+
return await this.client.getAccountDetails(accountId);
|
|
128
|
+
case 'list_alert_policies':
|
|
129
|
+
return await new alert_1.AlertTool(this.client).listAlertPolicies({
|
|
130
|
+
...args,
|
|
131
|
+
target_account_id: accountId,
|
|
132
|
+
});
|
|
133
|
+
case 'list_open_incidents':
|
|
134
|
+
return await new alert_1.AlertTool(this.client).listOpenIncidents({
|
|
135
|
+
...args,
|
|
136
|
+
target_account_id: accountId,
|
|
137
|
+
});
|
|
138
|
+
case 'acknowledge_incident':
|
|
139
|
+
return await new alert_1.AlertTool(this.client).acknowledgeIncident(args);
|
|
140
|
+
case 'search_entities':
|
|
141
|
+
return await new entity_1.EntityTool(this.client).searchEntities({
|
|
142
|
+
...args,
|
|
143
|
+
target_account_id: accountId,
|
|
144
|
+
});
|
|
145
|
+
case 'get_entity_details':
|
|
146
|
+
return await new entity_1.EntityTool(this.client).getEntityDetails(args);
|
|
147
|
+
case 'list_synthetics_monitors':
|
|
148
|
+
return await new synthetics_1.SyntheticsTool(this.client).listSyntheticsMonitors({
|
|
149
|
+
...args,
|
|
150
|
+
target_account_id: accountId,
|
|
151
|
+
});
|
|
152
|
+
case 'create_browser_monitor':
|
|
153
|
+
return await new synthetics_1.SyntheticsTool(this.client).createBrowserMonitor({
|
|
154
|
+
...args,
|
|
155
|
+
target_account_id: accountId,
|
|
156
|
+
});
|
|
157
|
+
case 'execute_nerdgraph_query':
|
|
158
|
+
return await new nerdgraph_1.NerdGraphTool(this.client).execute(args);
|
|
159
|
+
default: {
|
|
160
|
+
const tool = this.tools.get(name);
|
|
161
|
+
if (!tool) {
|
|
162
|
+
throw new Error(`Tool ${name} not found`);
|
|
163
|
+
}
|
|
164
|
+
throw new Error(`Tool handler for ${name} not implemented`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
requiresAccountId(toolName) {
|
|
169
|
+
const accountRequiredTools = [
|
|
170
|
+
'run_nrql_query',
|
|
171
|
+
'list_apm_applications',
|
|
172
|
+
'search_entities',
|
|
173
|
+
'get_account_details',
|
|
174
|
+
'list_alert_policies',
|
|
175
|
+
'list_open_incidents',
|
|
176
|
+
'list_synthetics_monitors',
|
|
177
|
+
'create_browser_monitor',
|
|
178
|
+
];
|
|
179
|
+
return accountRequiredTools.includes(toolName);
|
|
180
|
+
}
|
|
181
|
+
getMetadata() {
|
|
182
|
+
return {
|
|
183
|
+
name: 'newrelic-mcp',
|
|
184
|
+
version: '1.0.0',
|
|
185
|
+
description: 'MCP server for New Relic observability platform integration',
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
getRegisteredTools() {
|
|
189
|
+
return Array.from(this.tools.keys());
|
|
190
|
+
}
|
|
191
|
+
getTool(name) {
|
|
192
|
+
return this.tools.get(name);
|
|
193
|
+
}
|
|
194
|
+
getDefaultAccountId() {
|
|
195
|
+
return this.defaultAccountId;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
exports.NewRelicMCPServer = NewRelicMCPServer;
|
|
199
|
+
// Main entry point
|
|
200
|
+
if (require.main === module) {
|
|
201
|
+
const server = new NewRelicMCPServer();
|
|
202
|
+
server.start().catch(console.error);
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"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AW;QACT,OAAO;YACL,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,6DAA6D;SAC3E,CAAC;IACJ,CAAC;IAED,kBAAkB;QAChB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,mBAAmB;QACjB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;CACF;AA/MD,8CA+MC;AAED,mBAAmB;AACnB,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAI,iBAAiB,EAAE,CAAC;IACvC,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import type { NewRelicClient } from '../client/newrelic-client';
|
|
3
|
+
export declare class AlertTool {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: NewRelicClient);
|
|
6
|
+
getPoliciesTool(): Tool;
|
|
7
|
+
getIncidentsTool(): Tool;
|
|
8
|
+
getAcknowledgeTool(): Tool;
|
|
9
|
+
listAlertPolicies(input: any): Promise<any>;
|
|
10
|
+
listOpenIncidents(input: any): Promise<any>;
|
|
11
|
+
acknowledgeIncident(input: any): Promise<any>;
|
|
12
|
+
acknowledgeIncidents(input: any): Promise<any>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=alert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../src/tools/alert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,EAAE,cAAc;IAIlC,eAAe,IAAI,IAAI;IAgBvB,gBAAgB,IAAI,IAAI;IAqBxB,kBAAkB,IAAI,IAAI;IAiBpB,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IA+B3C,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IA+C3C,mBAAmB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAgC7C,oBAAoB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CA2BrD"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AlertTool = void 0;
|
|
4
|
+
class AlertTool {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
getPoliciesTool() {
|
|
10
|
+
return {
|
|
11
|
+
name: 'list_alert_policies',
|
|
12
|
+
description: 'List all alert policies in your New Relic account',
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
target_account_id: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description: 'Optional New Relic account ID',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
getIncidentsTool() {
|
|
25
|
+
return {
|
|
26
|
+
name: 'list_open_incidents',
|
|
27
|
+
description: 'List all open incidents in your New Relic account',
|
|
28
|
+
inputSchema: {
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: {
|
|
31
|
+
target_account_id: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'Optional New Relic account ID',
|
|
34
|
+
},
|
|
35
|
+
priority: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
enum: ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'],
|
|
38
|
+
description: 'Filter by incident priority',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
getAcknowledgeTool() {
|
|
45
|
+
return {
|
|
46
|
+
name: 'acknowledge_incident',
|
|
47
|
+
description: 'Acknowledge an open incident',
|
|
48
|
+
inputSchema: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
incident_id: {
|
|
52
|
+
type: 'string',
|
|
53
|
+
description: 'The ID of the incident to acknowledge',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
required: ['incident_id'],
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async listAlertPolicies(input) {
|
|
61
|
+
const accountId = input.target_account_id;
|
|
62
|
+
if (!accountId) {
|
|
63
|
+
throw new Error('Account ID must be provided');
|
|
64
|
+
}
|
|
65
|
+
const query = `{
|
|
66
|
+
actor {
|
|
67
|
+
account(id: ${accountId}) {
|
|
68
|
+
alerts {
|
|
69
|
+
policiesSearch {
|
|
70
|
+
policies {
|
|
71
|
+
id
|
|
72
|
+
name
|
|
73
|
+
incidentPreference
|
|
74
|
+
conditions {
|
|
75
|
+
id
|
|
76
|
+
name
|
|
77
|
+
enabled
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}`;
|
|
85
|
+
const response = await this.client.executeNerdGraphQuery(query);
|
|
86
|
+
return response.data?.actor?.account?.alerts?.policiesSearch?.policies || [];
|
|
87
|
+
}
|
|
88
|
+
async listOpenIncidents(input) {
|
|
89
|
+
const accountId = input.target_account_id;
|
|
90
|
+
if (!accountId) {
|
|
91
|
+
throw new Error('Account ID must be provided');
|
|
92
|
+
}
|
|
93
|
+
let filter = `accountId = '${accountId}' AND state = 'OPEN'`;
|
|
94
|
+
if (input.priority) {
|
|
95
|
+
filter += ` AND priority = '${input.priority}'`;
|
|
96
|
+
}
|
|
97
|
+
const query = `{
|
|
98
|
+
actor {
|
|
99
|
+
entitySearch(query: "${filter}") {
|
|
100
|
+
results {
|
|
101
|
+
entities {
|
|
102
|
+
... on AiIssuesEntity {
|
|
103
|
+
issues {
|
|
104
|
+
issues {
|
|
105
|
+
issueId
|
|
106
|
+
title
|
|
107
|
+
priority
|
|
108
|
+
state
|
|
109
|
+
createdAt
|
|
110
|
+
sources
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}`;
|
|
119
|
+
const response = await this.client.executeNerdGraphQuery(query);
|
|
120
|
+
const entities = response.data?.actor?.entitySearch?.results?.entities || [];
|
|
121
|
+
const incidents = [];
|
|
122
|
+
entities.forEach((entity) => {
|
|
123
|
+
if (entity.issues?.issues) {
|
|
124
|
+
incidents.push(...entity.issues.issues);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
return incidents;
|
|
128
|
+
}
|
|
129
|
+
async acknowledgeIncident(input) {
|
|
130
|
+
const mutation = `
|
|
131
|
+
mutation {
|
|
132
|
+
aiIssuesAcknowledge(
|
|
133
|
+
issueIds: ["${input.incident_id}"]
|
|
134
|
+
${input.comment ? `, comment: "${input.comment}"` : ''}
|
|
135
|
+
) {
|
|
136
|
+
issues {
|
|
137
|
+
issueId
|
|
138
|
+
state
|
|
139
|
+
acknowledgedAt
|
|
140
|
+
acknowledgedBy
|
|
141
|
+
${input.comment ? 'comment' : ''}
|
|
142
|
+
}
|
|
143
|
+
errors {
|
|
144
|
+
type
|
|
145
|
+
description
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
`;
|
|
150
|
+
const response = await this.client.executeNerdGraphQuery(mutation);
|
|
151
|
+
const result = response.data?.aiIssuesAcknowledge;
|
|
152
|
+
if (result?.errors && result.errors.length > 0) {
|
|
153
|
+
throw new Error(result.errors[0].description);
|
|
154
|
+
}
|
|
155
|
+
return result?.issues?.[0] || null;
|
|
156
|
+
}
|
|
157
|
+
async acknowledgeIncidents(input) {
|
|
158
|
+
const mutation = `
|
|
159
|
+
mutation {
|
|
160
|
+
aiIssuesAcknowledge(
|
|
161
|
+
issueIds: ${JSON.stringify(input.incident_ids)}
|
|
162
|
+
) {
|
|
163
|
+
issues {
|
|
164
|
+
issueId
|
|
165
|
+
state
|
|
166
|
+
}
|
|
167
|
+
errors {
|
|
168
|
+
type
|
|
169
|
+
description
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
`;
|
|
174
|
+
const response = await this.client.executeNerdGraphQuery(mutation);
|
|
175
|
+
const result = response.data?.aiIssuesAcknowledge;
|
|
176
|
+
if (result?.errors && result.errors.length > 0) {
|
|
177
|
+
throw new Error(result.errors[0].description);
|
|
178
|
+
}
|
|
179
|
+
return result?.issues || [];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
exports.AlertTool = AlertTool;
|
|
183
|
+
//# sourceMappingURL=alert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.js","sourceRoot":"","sources":["../../src/tools/alert.ts"],"names":[],"mappings":";;;AAGA,MAAa,SAAS;IACZ,MAAM,CAAiB;IAE/B,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,eAAe;QACb,OAAO;YACL,IAAI,EAAE,qBAAqB;YAC3B,WAAW,EAAE,mDAAmD;YAChE,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,iBAAiB,EAAE;wBACjB,IAA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,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACnE,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;QAElD,IAAI,MAAM,EAAE,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,KAAU;QACnC,MAAM,QAAQ,GAAG;;;sBAGC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC;;;;;;;;;;;;KAYnD,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACnE,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;QAElD,IAAI,MAAM,EAAE,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC;IAC9B,CAAC;CACF;AAtMD,8BAsMC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import type { ApmApplication, NewRelicClient } from '../client/newrelic-client';
|
|
3
|
+
export declare class ApmTool {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: NewRelicClient);
|
|
6
|
+
getListApplicationsTool(): Tool;
|
|
7
|
+
execute(input: any): Promise<ApmApplication[]>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=apm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apm.d.ts","sourceRoot":"","sources":["../../src/tools/apm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhF,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,EAAE,cAAc;IAIlC,uBAAuB,IAAI,IAAI;IAgBzB,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;CAQrD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApmTool = void 0;
|
|
4
|
+
class ApmTool {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
getListApplicationsTool() {
|
|
10
|
+
return {
|
|
11
|
+
name: 'list_apm_applications',
|
|
12
|
+
description: 'List all APM applications in your New Relic account',
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
target_account_id: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description: 'Optional New Relic account ID',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async execute(input) {
|
|
25
|
+
if (!input.target_account_id) {
|
|
26
|
+
throw new Error('Account ID must be provided');
|
|
27
|
+
}
|
|
28
|
+
const applications = await this.client.listApmApplications(input.target_account_id);
|
|
29
|
+
return applications;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ApmTool = ApmTool;
|
|
33
|
+
//# sourceMappingURL=apm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apm.js","sourceRoot":"","sources":["../../src/tools/apm.ts"],"names":[],"mappings":";;;AAGA,MAAa,OAAO;IACV,MAAM,CAAiB;IAE/B,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,uBAAuB;QACrB,OAAO;YACL,IAAI,EAAE,uBAAuB;YAC7B,WAAW,EAAE,qDAAqD;YAClE,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,iBAAiB,EAAE;wBACjB,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,+BAA+B;qBAC7C;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAU;QACtB,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACpF,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AA/BD,0BA+BC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import type { NewRelicClient } from '../client/newrelic-client';
|
|
3
|
+
export declare class EntityTool {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: NewRelicClient);
|
|
6
|
+
getSearchTool(): Tool;
|
|
7
|
+
getDetailsTool(): Tool;
|
|
8
|
+
searchEntities(input: any): Promise<any>;
|
|
9
|
+
getEntityDetails(input: any): Promise<any>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/tools/entity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,EAAE,cAAc;IAIlC,aAAa,IAAI,IAAI;IA0BrB,cAAc,IAAI,IAAI;IAiBhB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAqCxC,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CA2DjD"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EntityTool = void 0;
|
|
4
|
+
class EntityTool {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
getSearchTool() {
|
|
10
|
+
return {
|
|
11
|
+
name: 'search_entities',
|
|
12
|
+
description: 'Search for entities in New Relic by name, type, or tags',
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
query: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description: 'Search query for entities',
|
|
19
|
+
},
|
|
20
|
+
entity_types: {
|
|
21
|
+
type: 'array',
|
|
22
|
+
items: { type: 'string' },
|
|
23
|
+
description: 'Filter by entity types (e.g., APPLICATION, HOST)',
|
|
24
|
+
},
|
|
25
|
+
target_account_id: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description: 'Optional New Relic account ID',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
required: ['query'],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
getDetailsTool() {
|
|
35
|
+
return {
|
|
36
|
+
name: 'get_entity_details',
|
|
37
|
+
description: 'Get detailed information about a specific entity',
|
|
38
|
+
inputSchema: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
entity_guid: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: 'The GUID of the entity',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
required: ['entity_guid'],
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async searchEntities(input) {
|
|
51
|
+
const accountId = input.target_account_id;
|
|
52
|
+
let query = input.query;
|
|
53
|
+
if (accountId) {
|
|
54
|
+
query += ` AND accountId = '${accountId}'`;
|
|
55
|
+
}
|
|
56
|
+
if (input.entity_types && input.entity_types.length > 0) {
|
|
57
|
+
const types = input.entity_types.map((t) => `'${t}'`).join(',');
|
|
58
|
+
query += ` AND type IN (${types})`;
|
|
59
|
+
}
|
|
60
|
+
const graphqlQuery = `{
|
|
61
|
+
actor {
|
|
62
|
+
entitySearch(query: "${query}") {
|
|
63
|
+
results {
|
|
64
|
+
entities {
|
|
65
|
+
guid
|
|
66
|
+
name
|
|
67
|
+
type
|
|
68
|
+
domain
|
|
69
|
+
tags {
|
|
70
|
+
key
|
|
71
|
+
values
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
nextCursor
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}`;
|
|
79
|
+
const response = await this.client.executeNerdGraphQuery(graphqlQuery);
|
|
80
|
+
return response.data?.actor?.entitySearch?.results || { entities: [] };
|
|
81
|
+
}
|
|
82
|
+
async getEntityDetails(input) {
|
|
83
|
+
const graphqlQuery = `{
|
|
84
|
+
actor {
|
|
85
|
+
entity(guid: "${input.entity_guid}") {
|
|
86
|
+
guid
|
|
87
|
+
name
|
|
88
|
+
type
|
|
89
|
+
domain
|
|
90
|
+
entityType
|
|
91
|
+
reporting
|
|
92
|
+
tags {
|
|
93
|
+
key
|
|
94
|
+
values
|
|
95
|
+
}
|
|
96
|
+
... on AlertableEntity {
|
|
97
|
+
alertSeverity
|
|
98
|
+
recentAlertViolations {
|
|
99
|
+
alertSeverity
|
|
100
|
+
violationId
|
|
101
|
+
openedAt
|
|
102
|
+
closedAt
|
|
103
|
+
violationUrl
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
... on ApmApplicationEntity {
|
|
107
|
+
language
|
|
108
|
+
settings {
|
|
109
|
+
apdexTarget
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
relationships {
|
|
113
|
+
type
|
|
114
|
+
target {
|
|
115
|
+
entities {
|
|
116
|
+
guid
|
|
117
|
+
name
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
goldenMetrics {
|
|
122
|
+
metrics {
|
|
123
|
+
name
|
|
124
|
+
value
|
|
125
|
+
unit
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}`;
|
|
131
|
+
const response = await this.client.executeNerdGraphQuery(graphqlQuery);
|
|
132
|
+
const entity = response.data?.actor?.entity;
|
|
133
|
+
if (!entity) {
|
|
134
|
+
throw new Error('Entity not found');
|
|
135
|
+
}
|
|
136
|
+
return entity;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.EntityTool = EntityTool;
|
|
140
|
+
//# sourceMappingURL=entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/tools/entity.ts"],"names":[],"mappings":";;;AAGA,MAAa,UAAU;IACb,MAAM,CAAiB;IAE/B,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,aAAa;QACX,OAAO;YACL,IAAI,EAAE,iBAAiB;YACvB,WAAW,EAAE,yDAAyD;YACtE,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU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B9B,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;QACvE,OAAO,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,KAAU;QAC/B,MAAM,YAAY,GAAG;;wBAED,KAAK,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA6CnC,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;QACvE,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC;QAE5C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAlJD,gCAkJC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import type { NewRelicClient } from '../client/newrelic-client';
|
|
3
|
+
export declare class NerdGraphTool {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: NewRelicClient);
|
|
6
|
+
getQueryTool(): Tool;
|
|
7
|
+
execute(input: any): Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=nerdgraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nerdgraph.d.ts","sourceRoot":"","sources":["../../src/tools/nerdgraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,EAAE,cAAc;IAIlC,YAAY,IAAI,IAAI;IAiBd,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CAOxC"}
|