@mackerel/mcp-server 0.0.1

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 ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # Mackerel MCP Server
2
+
3
+ A Model Context Protocol server for interacting with [Mackerel](https://mackerel.io).
4
+
5
+ # Configuration
6
+
7
+ The MCP server can be run either via Docker or npx.
8
+
9
+ ## Running via Docker
10
+
11
+ ```json
12
+ {
13
+ "mcpServers": {
14
+ "mackerel": {
15
+ "command": "docker",
16
+ "args": [
17
+ "run",
18
+ "--rm",
19
+ "-i",
20
+ "-e",
21
+ "MACKEREL_API_KEY",
22
+ "-----TBD_IMAGE_NAME"
23
+ ],
24
+ "env": {
25
+ "MACKEREL_API_KEY": "${MACKEREL_API_KEY}"
26
+ }
27
+ }
28
+ }
29
+ }
30
+ ```
31
+
32
+ ## Running via npx
33
+
34
+ ```json
35
+ {
36
+ "mcpServers": {
37
+ "mackerel": {
38
+ "command": "npx",
39
+ "args": [
40
+ "-y",
41
+ "-----TBD_PACKAGE_NAME"
42
+ ],
43
+ "env": {
44
+ "MACKEREL_API_KEY": "${MACKEREL_API_KEY}"
45
+ }
46
+ }
47
+ }
48
+ }
49
+ ```
50
+
51
+ # Available tools
52
+
53
+ * `list_alerts` - Retrieve alerts.
54
+ * `get_alert` - Retrieve a specific alert.
55
+ * `get_alert_logs` - Retrieve logs for a specific alert.
56
+ * `list_dashboards` - Retrieve dashboards.
57
+ * `get_dashboard` - Retrieve a specific dashboard.
58
+ * `update_dashboard` - Update a specific dashboard.
59
+ * `list_hosts` - Retrieve hosts.
60
+ * `get_host_metrics` - Retrieve metrics data for a specific host.
61
+ * `list_services` - Retrieve services.
62
+ * `get_service_metrics` - Retrieve metrics data for a specific service.
63
+ * `list_monitors` - Retrieve monitor configurations.
64
+ * `get_monitor` - Retrieve a specific monitor configuration.
@@ -0,0 +1 @@
1
+ export {};
package/build/index.js ADDED
@@ -0,0 +1,169 @@
1
+ import{McpServer as e}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as t}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as n}from"zod";async function r(e){try{let t=await e();return{content:[{type:`text`,text:JSON.stringify(t)}]}}catch(e){let t=e instanceof Error?e.message:String(e);return{content:[{type:`text`,text:`Error occurred: ${t}`}],isError:!0}}}var i=class{constructor(e){this.mackerelClient=e}static ListAlertsToolInput=n.object({withClosed:n.boolean().optional().describe(`Whether or not to get resolved alerts. If true, resolved alerts as well as open alerts are retrieved`),nextId:n.string().optional().describe(`If specified, alerts older than the alert with the specified id are retrieved`),limit:n.number().min(1).max(100).optional().describe(`The maximum number of alerts to retrieve. When omitted, up to 100 cases are retrieved. The most that can be specified is 100`)});listAlerts=async({withClosed:e,nextId:t,limit:n})=>await r(async()=>await this.mackerelClient.getAlerts(e,t,n));static GetAlertToolInput=n.object({alertId:n.string().describe(`The ID of the alert to retrieve`)});getAlert=async({alertId:e})=>await r(async()=>await this.mackerelClient.getAlert(e));static GetAlertLogsToolInput=n.object({alertId:n.string().describe(`The ID of the alert to retrieve logs for`),nextId:n.string().optional().describe(`If specified, alert logs older than the specified are retrieved`),limit:n.number().min(1).max(100).optional().describe(`The maximum number of alert logs to retrieve. When omitted, up to 100 logs are retrieved. The most that can be specified is 100`)});getAlertLogs=async({alertId:e,nextId:t,limit:n})=>await r(async()=>await this.mackerelClient.getAlertLogs(e,t,n))},a=class e{constructor(e){this.mackerelClient=e}static ListDashboardsToolInput=n.object({});listDashboards=async({})=>await r(async()=>await this.mackerelClient.getDashboards());static GetDashboardToolInput=n.object({dashboardId:n.string().describe(`The ID of the dashboard to retrieve`)});getDashboard=async({dashboardId:e})=>await r(async()=>await this.mackerelClient.getDashboard(e));static LayoutSchema=n.object({x:n.number().describe(`X coordinate of widget`),y:n.number().describe(`Y coordinate of widget`),width:n.number().describe(`Width of widget`),height:n.number().describe(`Height of widget`)});static RangeSchema=n.union([n.object({type:n.literal(`relative`).describe(`Relative time range`),period:n.number().describe(`Length of the period (in seconds)`),offset:n.number().describe(`Difference from the current time (in seconds)`)}),n.object({type:n.literal(`absolute`).describe(`Absolute time range`),start:n.number().describe(`Start time (in epoch seconds)`),end:n.number().describe(`End time (in epoch seconds)`)}),n.object({min:n.number().optional().describe(`Minimum value on vertical axis`),max:n.number().optional().describe(`Maximum value on vertical axis`)})]);static ValueRangeSchema=n.object({min:n.number().optional().describe(`Minimum value on vertical axis`),max:n.number().optional().describe(`Maximum value on vertical axis`)});static GraphSchema=n.discriminatedUnion(`type`,[n.object({type:n.literal(`host`).describe(`Host graph`),hostId:n.string().describe(`Host ID`),name:n.string().describe(`Graph name (e.g., loadavg, cpu)`)}),n.object({type:n.literal(`role`).describe(`Role graph`),roleFullname:n.string().describe("The service name and role name linked with `:`"),name:n.string().describe(`Graph name`),isStacked:n.boolean().optional().describe(`Whether the graph is stacked or line graph`)}),n.object({type:n.literal(`service`).describe(`Service graph`),serviceName:n.string().describe(`Service name`),name:n.string().describe(`Graph name`)}),n.object({type:n.literal(`expression`).describe(`Expression graph`),expression:n.string().describe(`Expression representing a graph`)}),n.object({type:n.literal(`query`).describe(`Query graph`),query:n.string().describe(`PromQL-style queries`),legend:n.string().optional().describe('Query legend. by specifiying the label key in `{{ }}`, it can be expanded to the value of the label. e.g. if you have a label `{ http.method: "GET" }` and you specify `method: {{http.method}}` in the `legend`, it will expand to `method: GET`.')}),n.object({type:n.literal(`unknown`).describe(`Unknown graph`)})]);static ReferenceLineSchema=n.object({label:n.string().describe(`Label of the reference line`),value:n.number().describe(`Value of the reference line`)});static MetricSchema=n.discriminatedUnion(`type`,[n.object({type:n.literal(`host`).describe(`Host metric`),hostId:n.string().describe(`Host ID`),name:n.string().describe("The name of the metric (`loadavg5` etc)")}),n.object({type:n.literal(`service`).describe(`Service metric`),serviceName:n.string().describe(`The name of the service`),name:n.string().describe(`The name of the metric`)}),n.object({type:n.literal(`expression`).describe(`Expression metric`),expression:n.string().describe(`An expression that represents a metric`)}),n.object({type:n.literal(`query`).describe(`Query metric`),query:n.string().describe(`PromQL-style queries`),legend:n.string().describe('Query legend. by specifying the label key in `{{ }}`, it can be expanded to the value of the label. e.g. if you have a label `{ http.method: "GET" }` and you specify `method: {{http.method}}` in the `legend`, it will expand to `method: GET`')}),n.object({type:n.literal(`unknown`).describe(`Unknown metric type (fallback when source is deleted)`)})]);static FormatRuleSchema=n.object({name:n.string().optional().describe(`Name of the format rule`),threshold:n.number().describe(`Base value of the conditional expression`),operator:n.enum([`>`,`<`]).describe(`Specify the conditions under which the emphasized style will be applied.`)});static WidgetSchema=n.discriminatedUnion(`type`,[n.object({type:n.literal(`graph`).describe(`Graph widget`),title:n.string().describe(`The title of the widget`),graph:e.GraphSchema.describe(`Object representing a graph`),range:e.RangeSchema.optional().describe(`Object representing the graph display range`),valueRange:e.ValueRangeSchema.optional().describe(`Object representing the value range of vertical axis`),referenceLines:n.array(e.ReferenceLineSchema).optional().describe(`Array of objects representing the reference line. If you want to remove the reference line setting, specify an empty array. If reference line is not set when get dashboards, an empty array is returned. Cannot specify more than one element in an array.`),layout:e.LayoutSchema.describe(`Object representing the layout`)}),n.object({type:n.literal(`value`).describe(`Value widget`),title:n.string().describe(`The title of the widget`),metric:e.MetricSchema.describe(`Object representing a metric`),fractionSize:n.number().optional().describe(`Decimal places displayed on the widget (0–16)`),suffix:n.string().optional().describe(`The units to be displayed after the value`),formatRules:n.array(e.FormatRuleSchema).optional().describe(`Array of objects representing the format rule. If you want to remove the format rule setting, specify an empty array. If format rule is not set when get dashboards, an empty array is returned. Cannot specify more than one element in an array.`),layout:e.LayoutSchema.describe(`Object representing the layout`)}),n.object({type:n.literal(`markdown`).describe(`Markdown widget`),title:n.string().describe(`The title of the widget`),markdown:n.string().describe(`A character string in Markdown format`),layout:e.LayoutSchema.describe(`Object representing the layout`)}),n.object({type:n.literal(`alertStatus`).describe(`Alert status widget`),title:n.string().describe(`The title of the widget`),roleFullname:n.string().describe("The service name and role name linked by `:`.However, if the relevant role or service has been deleted when the dashboard is retrieved, `roleFullname` will be set as `null`. "),layout:e.LayoutSchema.describe(`Object representing the layout`)})]);static UpdateDashboardToolInput=n.object({dashboardId:n.string().describe(`The ID of the dashboard to update`),title:n.string().describe(`Dashboard name`),memo:n.string().describe(`Dashboard notes`),urlPath:n.string().describe(`Dashboard URL path`),widgets:n.array(e.WidgetSchema).describe(`List of widget objects`)});updateDashboard=async({dashboardId:e,title:t,memo:n,urlPath:i,widgets:a})=>await r(async()=>await this.mackerelClient.updateDashboard(e,{title:t,memo:n,urlPath:i,widgets:a}))},o=class{constructor(e){this.mackerelClient=e}static ListMonitorsToolInput=n.object({});listMonitors=async({})=>await r(async()=>await this.mackerelClient.getMonitors());static GetMonitorToolInput=n.object({monitorId:n.string().describe(`Monitor ID`)});getMonitor=async({monitorId:e})=>await r(async()=>await this.mackerelClient.getMonitor(e))},s=class{constructor(e){this.mackerelClient=e}static ListHostsToolInput=n.object({service:n.string().optional().describe(`Service name`),role:n.array(n.string()).optional().describe(`Role names in the service, multiple assignments possible (result will be a unit of the hosts that belong to each role) if service has not been assigned it will be ignored.`),name:n.string().optional().describe(`Host name`),status:n.array(n.string()).optional().describe("Filters the host status. multiple specifications are possible. defaults are `working` and `standby`."),customIdentifier:n.string().optional().describe(`An identifier for the host that is user-specific and unique to the organization (registered at Register Host Information or Update Host Information API)`)});listHosts=async({service:e,role:t,name:n,status:i,customIdentifier:a})=>await r(async()=>await this.mackerelClient.getHosts(e,t,n,i,a))},c=class{constructor(e){this.mackerelClient=e}static ListServicesToolInput=n.object({});listServices=async e=>await r(async()=>await this.mackerelClient.getServices())},l=class{baseUrl;apiKey;constructor(e,t){this.baseUrl=e,this.apiKey=t}async request(e,t,{searchParams:n,body:r}={}){let i=`${this.baseUrl}${t}${n?`?`+n.toString():``}`,a={"X-Api-Key":this.apiKey,"Content-Type":`application/json`},o={method:e,headers:a};r&&(o.body=JSON.stringify(r));let s=await fetch(i,o);if(!s.ok){let e=await s.text();throw Error(`Mackerel API error: ${s.status} ${e}`)}return await s.json()}async getAlerts(e,t,n){let r=new URLSearchParams;return e!==void 0&&r.append(`withClosed`,e.toString()),t&&r.append(`nextId`,t),n!==void 0&&r.append(`limit`,n.toString()),this.request(`GET`,`/api/v0/alerts`,{searchParams:r})}async getAlert(e){return this.request(`GET`,`/api/v0/alerts/${e}`)}async getAlertLogs(e,t,n){let r=new URLSearchParams;return t&&r.append(`nextId`,t),n!==void 0&&r.append(`limit`,n.toString()),this.request(`GET`,`/api/v0/alerts/${e}/logs`,{searchParams:r})}async getDashboards(){return this.request(`GET`,`/api/v0/dashboards`)}async getDashboard(e){return this.request(`GET`,`/api/v0/dashboards/${e}`)}static WidgetArray=n.array(a.WidgetSchema);async updateDashboard(e,t){return this.request(`PUT`,`/api/v0/dashboards/${e}`,{body:t})}async getHosts(e,t,n,r,i){let a=new URLSearchParams;if(e&&a.append(`service`,e),t)for(let e of t)a.append(`role`,e);if(n&&a.append(`name`,n),r)for(let e of r)a.append(`status`,e);return i&&a.append(`customIdentifier`,i),this.request(`GET`,`/api/v0/hosts`,{searchParams:a})}async getHostMetrics(e,t,n,r){let i=new URLSearchParams;return i.append(`name`,t),i.append(`from`,n.toString()),i.append(`to`,r.toString()),this.request(`GET`,`/api/v0/hosts/${e}/metrics`,{searchParams:i})}async getServices(){return this.request(`GET`,`/api/v0/services`)}async getServiceMetrics(e,t,n,r){let i=new URLSearchParams;return i.append(`name`,t),i.append(`from`,n.toString()),i.append(`to`,r.toString()),this.request(`GET`,`/api/v0/services/${e}/metrics`,{searchParams:i})}async getMonitors(){return this.request(`GET`,`/api/v0/monitors`)}async getMonitor(e){return this.request(`GET`,`/api/v0/monitors/${e}`)}},u=class{constructor(e){this.mackerelClient=e}static GetServiceMetricsToolInput=n.object({serviceName:n.string().describe(`Service name`),name:n.string().describe(`Metric name`),from:n.number().describe(`The start of the time period you want metrics for (unix time)`),to:n.number().describe(`The end of the time period you want metrics for (unix time)`)});getServiceMetrics=async({serviceName:e,name:t,from:n,to:i})=>await r(async()=>await this.mackerelClient.getServiceMetrics(e,t,n,i))},d=class{constructor(e){this.mackerelClient=e}static GetHostMetricsToolInput=n.object({hostId:n.string().describe(`Host ID`),name:n.string().describe(`Metric name(loadavg5, etc.)`),from:n.number().describe(`The start of the time period you want metrics for (unix time)`),to:n.number().describe(`The end of the time period you want metrics for (unix time)`)});getHostMetrics=async({hostId:e,name:t,from:n,to:i})=>await r(async()=>await this.mackerelClient.getHostMetrics(e,t,n,i))};async function f(){let n=new l(`https://api.mackerelio.com`,p()),r=new i(n),f=new a(n),m=new o(n),h=new s(n),g=new d(n),_=new c(n),v=new u(n),y=new e({name:`mackerel-mcp`,version:`0.0.1`});y.registerTool(`list_alerts`,{title:`List Alerts`,description:`Retrieve alerts from Mackerel.
2
+
3
+ 🔍 USE THIS TOOL WHEN USERS:
4
+ - Check currently active alerts
5
+ - Get a list of alerts including closed alerts
6
+
7
+ <examples>
8
+ ### Get opening alerts
9
+ \`\`\`
10
+ list_alerts()
11
+ \`\`\`
12
+
13
+ ### Get all alerts
14
+ \`\`\`
15
+ list_alerts(withClosed=true)
16
+ \`\`\`
17
+ </examples>
18
+ `,inputSchema:i.ListAlertsToolInput.shape},r.listAlerts),y.registerTool(`get_alert`,{title:`Get Alert`,description:`Retrieve a specific alert by ID from Mackerel.
19
+
20
+ 🔍 USE THIS TOOL WHEN USERS:
21
+ - Investigate a particular alert
22
+
23
+ <examples>
24
+ ### Get alert by ID
25
+ \`\`\`
26
+ get_alert(alertId=3Yr)
27
+ \`\`\`
28
+ </example>
29
+ `,inputSchema:i.GetAlertToolInput.shape},r.getAlert),y.registerTool(`get_alert_logs`,{title:`Get Alert Logs`,description:`Retrieve logs for a specific alert by ID from Mackerel.
30
+
31
+ 🔍 USE THIS TOOL WHEN USERS:
32
+ - View status change history for a specific alert
33
+ - Investigate alert transitions and their reasons
34
+
35
+ <examples>
36
+ ### Get alert logs for the alert
37
+ \`\`\`
38
+ get_alert_logs(alertId=3Yr)
39
+ \`\`\`
40
+ </example>
41
+ `,inputSchema:i.GetAlertLogsToolInput.shape},r.getAlertLogs),y.registerTool(`list_dashboards`,{title:`List Dashboards`,description:`Retrieve all dashboards from Mackerel.
42
+
43
+ 🔍 USE THIS TOOL WHEN USERS:
44
+ - Get a list of dashboards
45
+ - Get ID and title of each dashboard
46
+
47
+ <examples>
48
+ ### Get all dashboards
49
+ \`\`\`
50
+ list_dashboards()
51
+ \`\`\`
52
+ </example>
53
+ `,inputSchema:a.ListDashboardsToolInput.shape},f.listDashboards),y.registerTool(`get_dashboard`,{title:`Get Dashboard`,description:`Retrieve a specific dashboard by ID from Mackerel.
54
+
55
+ 🔍 USE THIS TOOL WHEN USERS:
56
+ - Get details of a specific dashboard
57
+ - View dashboard configuration and widgets
58
+
59
+ <examples>
60
+ ### Get dashboard by ID
61
+ \`\`\`
62
+ get_dashboard(dashboardId="3Yr")
63
+ \`\`\`
64
+ </examples>
65
+ `,inputSchema:a.GetDashboardToolInput.shape},f.getDashboard),y.registerTool(`update_dashboard`,{title:`Update Dashboard`,description:`Update a specific dashboard by ID in Mackerel.
66
+
67
+ 🔍 USE THIS TOOL WHEN USERS:
68
+ - Modify dashboard title, memo, or URL path
69
+ - Update dashboard widgets configuration
70
+
71
+ <examples>
72
+ ### Update dashboard
73
+ \`\`\`
74
+ update_dashboard(
75
+ dashboardId="3Yr",
76
+ title="Updated Dashboard",
77
+ memo="Updated memo",
78
+ urlPath="updated path",
79
+ widgets=[{
80
+ type="markdown",
81
+ markdown="## Updated Markdown Widget",
82
+ title="Updated Title",
83
+ layout: { x: 0, y: 0, width: 6, height: 4 },
84
+ }]
85
+ )
86
+ \`\`\`
87
+ </examples>
88
+ `,inputSchema:a.UpdateDashboardToolInput.shape},f.updateDashboard),y.registerTool(`list_hosts`,{title:`List Hosts`,description:`Retrieve hosts from Mackerel.
89
+
90
+ 🔍 USE THIS TOOL WHEN USERS:
91
+ - Get a list of hosts
92
+ - Filter hosts by various criteria (service, role, name, etc.)
93
+ - Check host status and information
94
+
95
+ <examples>
96
+ ### Get all hosts
97
+ \`\`\`
98
+ list_hosts()
99
+ \`\`\`
100
+
101
+ ### Get hosts for a specific role
102
+ \`\`\`
103
+ list_hosts(service="web",role=["app"])
104
+ \`\`\`
105
+
106
+ ### Get hosts by status
107
+ \`\`\`
108
+ list_hosts(status=["working","standby"])
109
+ \`\`\`
110
+ </examples>
111
+ `,inputSchema:s.ListHostsToolInput.shape},h.listHosts),y.registerTool(`get_host_metrics`,{title:`Get Host Metrics`,description:`Retrieve metrics data for a specific host from Mackerel.
112
+
113
+ 🔍 USE THIS TOOL WHEN USERS:
114
+ - Get metrics data for a specific host
115
+ - Analyze host performance over time
116
+
117
+ <examples>
118
+ ### Get all metrics for a host
119
+ \`\`\`
120
+ get_host_metrics(hostId="host123", name="loadavg5", from=1609459200, to=1609462800)
121
+ \`\`\`
122
+ </examples>
123
+ `,inputSchema:d.GetHostMetricsToolInput.shape},g.getHostMetrics),y.registerTool(`list_services`,{title:`List Services`,description:`Retrieve all services from Mackerel.
124
+
125
+ 🔍 USE THIS TOOL WHEN USERS:
126
+ - Get a list of services
127
+ - View service names, memos, and roles
128
+
129
+ <examples>
130
+ ### Get all services
131
+ \`\`\`
132
+ list_services()
133
+ \`\`\`
134
+ </examples>
135
+ `,inputSchema:c.ListServicesToolInput.shape},_.listServices),y.registerTool(`get_service_metrics`,{title:`Get Service Metrics`,description:`Retrieve metrics data for a specific service from Mackerel.
136
+
137
+ 🔍 USE THIS TOOL WHEN USERS:
138
+ - Get metrics data for a specific service
139
+
140
+ <examples>
141
+ ### Get service metrics
142
+ \`\`\`
143
+ get_service_metrics(serviceName="web", name="response_time", from=1609459200, to=1609462800)
144
+ \`\`\`
145
+ </examples>
146
+ `,inputSchema:u.GetServiceMetricsToolInput.shape},v.getServiceMetrics),y.registerTool(`list_monitors`,{title:`List Monitors`,description:`Retrieve all monitor configurations from Mackerel.
147
+
148
+ 🔍 USE THIS TOOL WHEN USERS:
149
+ - Get a list of all monitors
150
+ - View monitor configurations
151
+
152
+ <examples>
153
+ ### Get all monitors
154
+ \`\`\`
155
+ list_monitors()
156
+ \`\`\`
157
+ </examples>
158
+ `,inputSchema:o.ListMonitorsToolInput.shape},m.listMonitors),y.registerTool(`get_monitor`,{title:`Get Monitor`,description:`Retrieve a specific monitor configuration by ID from Mackerel.
159
+
160
+ 🔍 USE THIS TOOL WHEN USERS:
161
+ - Get details of a specific monitor
162
+
163
+ <examples>
164
+ ### Get monitor by ID
165
+ \`\`\`
166
+ get_monitor(monitorId="2cSZzK3XfmB")
167
+ \`\`\`
168
+ </examples>
169
+ `,inputSchema:o.GetMonitorToolInput.shape},m.getMonitor);let b=new t;await y.connect(b),console.error(`Mackerel MCP Server running on stdio`)}function p(){let e=process.env.MACKEREL_API_KEY;if(!e)throw Error(`MACKEREL_API_KEY environment variable is not set.`);return e}f().catch(e=>{console.error(`Fatal error in main():`,e),process.exit(1)});export{};
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@mackerel/mcp-server",
3
+ "version": "0.0.1",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "A Model Context Protocol server for interacting with Mackerel",
8
+ "main": "build/index.js",
9
+ "type": "module",
10
+ "scripts": {
11
+ "build": "tsdown",
12
+ "dev": "tsx src/index.ts",
13
+ "inspector": "npx @modelcontextprotocol/inspector -e MACKEREL_API_KEY=$MACKEREL_API_KEY tsx src/index.ts",
14
+ "format": "prettier --write \"src/**/*.{ts,tsx}\"",
15
+ "format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
16
+ "test": "vitest run"
17
+ },
18
+ "license": "Apache-2.0",
19
+ "files": [
20
+ "build",
21
+ "README.md",
22
+ "LICENSE"
23
+ ],
24
+ "types": "build/index.d.ts",
25
+ "bugs": {
26
+ "url": "https://github.com/mackerelio-labs/mcp-server/issues"
27
+ },
28
+ "author": "Mackerel <platform+mackerel@hatena.ne.jp> (http://mackerel.io/)",
29
+ "homepage": "https://github.com/mackerelio-labs/mcp-server#readme",
30
+ "keywords": [
31
+ "mackerel",
32
+ "model-context-protocol",
33
+ "mcp"
34
+ ],
35
+ "dependencies": {
36
+ "@modelcontextprotocol/sdk": "^1.17.2",
37
+ "zod": "^3.25.76"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^24.2.1",
41
+ "msw": "^2.10.5",
42
+ "prettier": "^3.6.2",
43
+ "tsdown": "^0.14.1",
44
+ "tsx": "^4.20.3",
45
+ "typescript": "^5.9.2",
46
+ "vitest": "^3.2.4"
47
+ }
48
+ }