bugsink-mcp-server 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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +116 -0
  3. package/package.json +38 -0
  4. package/src/index.js +278 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 neno73
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # Bugsink MCP Server
2
+
3
+ MCP (Model Context Protocol) server for querying [Bugsink](https://bugsink.com) error tracking. Allows Claude Code to directly access your error reports.
4
+
5
+ ## Features
6
+
7
+ - List all projects
8
+ - List issues (errors) for a project
9
+ - Get issue details
10
+ - List events (error occurrences)
11
+ - Get full event data
12
+ - Get formatted stacktraces
13
+
14
+ ## Setup for Claude Code
15
+
16
+ ### 1. Install globally (recommended)
17
+
18
+ ```bash
19
+ cd ~/Code/bugsink-mcp-server
20
+ npm install
21
+ npm link
22
+ ```
23
+
24
+ ### 2. Add to Claude Code settings
25
+
26
+ Edit `~/.claude/settings.json` and add:
27
+
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "bugsink": {
32
+ "type": "stdio",
33
+ "command": "node",
34
+ "args": ["/home/neno/Code/bugsink-mcp-server/src/index.js"],
35
+ "env": {
36
+ "BUGSINK_URL": "https://bug.sols.mk:8000",
37
+ "BUGSINK_TOKEN": "your-api-token-here"
38
+ }
39
+ }
40
+ }
41
+ }
42
+ ```
43
+
44
+ Or use npx (no install needed):
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "bugsink": {
50
+ "type": "stdio",
51
+ "command": "npx",
52
+ "args": ["-y", "/home/neno/Code/bugsink-mcp-server"],
53
+ "env": {
54
+ "BUGSINK_URL": "https://bug.sols.mk:8000",
55
+ "BUGSINK_TOKEN": "your-api-token-here"
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ ### 3. Restart Claude Code
63
+
64
+ After adding the configuration, restart Claude Code to load the MCP server.
65
+
66
+ ## Available Tools
67
+
68
+ | Tool | Description |
69
+ |------|-------------|
70
+ | `list_projects` | List all Bugsink projects |
71
+ | `list_issues` | List issues for a project (sorted by last_seen) |
72
+ | `get_issue` | Get details of a specific issue |
73
+ | `list_events` | List events (occurrences) for an issue |
74
+ | `get_event` | Get full event data including context |
75
+ | `get_stacktrace` | Get formatted stacktrace markdown |
76
+
77
+ ## Usage Examples
78
+
79
+ Once configured, you can ask Claude:
80
+
81
+ - "Show me recent errors from Bugsink"
82
+ - "Get the stacktrace for the latest error"
83
+ - "What errors happened in project 3?"
84
+
85
+ ## Environment Variables
86
+
87
+ | Variable | Required | Default | Description |
88
+ |----------|----------|---------|-------------|
89
+ | `BUGSINK_TOKEN` | Yes | - | Your Bugsink API token |
90
+ | `BUGSINK_URL` | No | `https://bug.sols.mk:8000` | Bugsink instance URL |
91
+
92
+ ## Docker Usage (optional)
93
+
94
+ Build and run with Docker:
95
+
96
+ ```bash
97
+ docker build -t bugsink-mcp .
98
+ docker run -e BUGSINK_TOKEN=your-token bugsink-mcp
99
+ ```
100
+
101
+ ## Development
102
+
103
+ ```bash
104
+ # Install dependencies
105
+ npm install
106
+
107
+ # Run in watch mode
108
+ npm run dev
109
+
110
+ # Test manually
111
+ BUGSINK_TOKEN=your-token node src/index.js
112
+ ```
113
+
114
+ ## License
115
+
116
+ MIT
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "bugsink-mcp-server",
3
+ "version": "1.0.0",
4
+ "description": "MCP server for querying Bugsink error tracking",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "bin": {
8
+ "bugsink-mcp": "./src/index.js"
9
+ },
10
+ "files": [
11
+ "src",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "scripts": {
16
+ "start": "node src/index.js",
17
+ "dev": "node --watch src/index.js"
18
+ },
19
+ "keywords": ["mcp", "bugsink", "sentry", "error-tracking", "claude", "anthropic"],
20
+ "author": "neno73",
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/solsmk/bugsink.git"
25
+ },
26
+ "homepage": "https://github.com/solsmk/bugsink#readme",
27
+ "bugs": {
28
+ "url": "https://github.com/solsmk/bugsink/issues"
29
+ },
30
+ "dependencies": {
31
+ "@modelcontextprotocol/sdk": "^1.24.3",
32
+ "express": "^5.2.1",
33
+ "zod": "^4.1.13"
34
+ },
35
+ "engines": {
36
+ "node": ">=18"
37
+ }
38
+ }
package/src/index.js ADDED
@@ -0,0 +1,278 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
4
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import {
6
+ CallToolRequestSchema,
7
+ ListToolsRequestSchema,
8
+ } from "@modelcontextprotocol/sdk/types.js";
9
+
10
+ // Configuration from environment
11
+ const BUGSINK_URL = process.env.BUGSINK_URL || "https://bug.sols.mk:8000";
12
+ const BUGSINK_TOKEN = process.env.BUGSINK_TOKEN;
13
+
14
+ if (!BUGSINK_TOKEN) {
15
+ console.error("Error: BUGSINK_TOKEN environment variable is required");
16
+ process.exit(1);
17
+ }
18
+
19
+ // Bugsink API client
20
+ class BugsinkClient {
21
+ constructor(baseUrl, token) {
22
+ this.baseUrl = baseUrl.replace(/\/$/, "");
23
+ this.token = token;
24
+ }
25
+
26
+ async request(endpoint, params = {}) {
27
+ const url = new URL(`${this.baseUrl}/api/canonical/0${endpoint}`);
28
+ Object.entries(params).forEach(([key, value]) => {
29
+ if (value !== undefined) url.searchParams.append(key, value);
30
+ });
31
+
32
+ const response = await fetch(url.toString(), {
33
+ headers: {
34
+ Authorization: `Bearer ${this.token}`,
35
+ "Content-Type": "application/json",
36
+ },
37
+ });
38
+
39
+ if (!response.ok) {
40
+ throw new Error(`Bugsink API error: ${response.status} ${response.statusText}`);
41
+ }
42
+
43
+ // Check if response is JSON or text (stacktrace endpoint returns markdown)
44
+ const contentType = response.headers.get("content-type");
45
+ if (contentType && contentType.includes("application/json")) {
46
+ return response.json();
47
+ }
48
+ return response.text();
49
+ }
50
+
51
+ async listProjects() {
52
+ return this.request("/projects/");
53
+ }
54
+
55
+ async listIssues(projectId, options = {}) {
56
+ return this.request("/issues/", {
57
+ project: projectId,
58
+ order: options.order || "desc",
59
+ sort: options.sort || "last_seen",
60
+ });
61
+ }
62
+
63
+ async getIssue(issueId) {
64
+ return this.request(`/issues/${issueId}/`);
65
+ }
66
+
67
+ async listEvents(issueId, options = {}) {
68
+ return this.request("/events/", {
69
+ issue: issueId,
70
+ order: options.order || "desc",
71
+ });
72
+ }
73
+
74
+ async getEvent(eventId) {
75
+ return this.request(`/events/${eventId}/`);
76
+ }
77
+
78
+ async getStacktrace(eventId) {
79
+ return this.request(`/events/${eventId}/stacktrace/`);
80
+ }
81
+ }
82
+
83
+ // Initialize client
84
+ const client = new BugsinkClient(BUGSINK_URL, BUGSINK_TOKEN);
85
+
86
+ // Create MCP server
87
+ const server = new Server(
88
+ {
89
+ name: "bugsink-mcp-server",
90
+ version: "1.0.0",
91
+ },
92
+ {
93
+ capabilities: {
94
+ tools: {},
95
+ },
96
+ }
97
+ );
98
+
99
+ // Define tools
100
+ const TOOLS = [
101
+ {
102
+ name: "list_projects",
103
+ description: "List all projects in Bugsink",
104
+ inputSchema: {
105
+ type: "object",
106
+ properties: {},
107
+ required: [],
108
+ },
109
+ },
110
+ {
111
+ name: "list_issues",
112
+ description: "List issues for a project. Returns recent errors/exceptions.",
113
+ inputSchema: {
114
+ type: "object",
115
+ properties: {
116
+ project_id: {
117
+ type: "string",
118
+ description: "The project ID to list issues for",
119
+ },
120
+ sort: {
121
+ type: "string",
122
+ enum: ["last_seen", "digest_order"],
123
+ description: "Sort order (default: last_seen)",
124
+ },
125
+ order: {
126
+ type: "string",
127
+ enum: ["asc", "desc"],
128
+ description: "Order direction (default: desc)",
129
+ },
130
+ },
131
+ required: ["project_id"],
132
+ },
133
+ },
134
+ {
135
+ name: "get_issue",
136
+ description: "Get details of a specific issue including error message and metadata",
137
+ inputSchema: {
138
+ type: "object",
139
+ properties: {
140
+ issue_id: {
141
+ type: "string",
142
+ description: "The issue ID to retrieve",
143
+ },
144
+ },
145
+ required: ["issue_id"],
146
+ },
147
+ },
148
+ {
149
+ name: "list_events",
150
+ description: "List events (occurrences) for an issue. Each event is one occurrence of the error.",
151
+ inputSchema: {
152
+ type: "object",
153
+ properties: {
154
+ issue_id: {
155
+ type: "string",
156
+ description: "The issue ID to list events for",
157
+ },
158
+ order: {
159
+ type: "string",
160
+ enum: ["asc", "desc"],
161
+ description: "Order direction (default: desc)",
162
+ },
163
+ },
164
+ required: ["issue_id"],
165
+ },
166
+ },
167
+ {
168
+ name: "get_event",
169
+ description: "Get full details of a specific event including the complete error data payload",
170
+ inputSchema: {
171
+ type: "object",
172
+ properties: {
173
+ event_id: {
174
+ type: "string",
175
+ description: "The event ID to retrieve",
176
+ },
177
+ },
178
+ required: ["event_id"],
179
+ },
180
+ },
181
+ {
182
+ name: "get_stacktrace",
183
+ description: "Get the stacktrace for an event as formatted markdown. Best for understanding where an error occurred.",
184
+ inputSchema: {
185
+ type: "object",
186
+ properties: {
187
+ event_id: {
188
+ type: "string",
189
+ description: "The event ID to get stacktrace for",
190
+ },
191
+ },
192
+ required: ["event_id"],
193
+ },
194
+ },
195
+ ];
196
+
197
+ // Handle list tools request
198
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
199
+ return { tools: TOOLS };
200
+ });
201
+
202
+ // Handle tool calls
203
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
204
+ const { name, arguments: args } = request.params;
205
+
206
+ try {
207
+ let result;
208
+
209
+ switch (name) {
210
+ case "list_projects":
211
+ result = await client.listProjects();
212
+ break;
213
+
214
+ case "list_issues":
215
+ result = await client.listIssues(args.project_id, {
216
+ sort: args.sort,
217
+ order: args.order,
218
+ });
219
+ break;
220
+
221
+ case "get_issue":
222
+ result = await client.getIssue(args.issue_id);
223
+ break;
224
+
225
+ case "list_events":
226
+ result = await client.listEvents(args.issue_id, {
227
+ order: args.order,
228
+ });
229
+ break;
230
+
231
+ case "get_event":
232
+ result = await client.getEvent(args.event_id);
233
+ break;
234
+
235
+ case "get_stacktrace":
236
+ result = await client.getStacktrace(args.event_id);
237
+ // Stacktrace is already markdown text
238
+ return {
239
+ content: [{ type: "text", text: result }],
240
+ };
241
+
242
+ default:
243
+ throw new Error(`Unknown tool: ${name}`);
244
+ }
245
+
246
+ // Format JSON result
247
+ return {
248
+ content: [
249
+ {
250
+ type: "text",
251
+ text: JSON.stringify(result, null, 2),
252
+ },
253
+ ],
254
+ };
255
+ } catch (error) {
256
+ return {
257
+ content: [
258
+ {
259
+ type: "text",
260
+ text: `Error: ${error.message}`,
261
+ },
262
+ ],
263
+ isError: true,
264
+ };
265
+ }
266
+ });
267
+
268
+ // Start server
269
+ async function main() {
270
+ const transport = new StdioServerTransport();
271
+ await server.connect(transport);
272
+ console.error("Bugsink MCP server running on stdio");
273
+ }
274
+
275
+ main().catch((error) => {
276
+ console.error("Fatal error:", error);
277
+ process.exit(1);
278
+ });