github-brain 0.0.9
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 +200 -0
- package/bin/github-brain.js +77 -0
- package/install.js +16 -0
- package/package.json +36 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Tomáš Veselý
|
|
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,200 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="logo.svg" alt="GitHub Brain Logo" width="150" height="150">
|
|
3
|
+
<h1>GitHub Brain MCP Server</h1>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
**GitHub Brain** is an experimental MCP server for summarizing GitHub discussions, issues, and pull requests. It helps answer questions like:
|
|
7
|
+
|
|
8
|
+
- _What are the contributions of user X in the last month?_
|
|
9
|
+
- _Summarize this month's discussions._
|
|
10
|
+
|
|
11
|
+
https://github.com/user-attachments/assets/80910025-9d58-4367-af00-bf4c51e6ce86
|
|
12
|
+
|
|
13
|
+
GitHub Brain complements (but does not replace) the [official GitHub MCP server](https://github.com/github/github-mcp-server). It uses a local database to store data pulled from GitHub, enabling:
|
|
14
|
+
|
|
15
|
+
- Fast responses
|
|
16
|
+
- More results than the standard 100-item API limit
|
|
17
|
+
- Markdown output for token efficiency
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
As a bonus, GitHub Brain also includes a simple web-based UI for ultra-fast search of discussions, issues, and pull requests.
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
As a bonus, GitHub Brain also includes a Raycast extension for ultra-fast search of discussions, issues, and pull requests.
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+
|
|
29
|
+
GitHub Brain is [programmed in Markdown](https://github.blog/ai-and-ml/generative-ai/spec-driven-development-using-markdown-as-a-programming-language-when-building-with-ai/).
|
|
30
|
+
|
|
31
|
+
## Prerequisites
|
|
32
|
+
|
|
33
|
+
- [Go](https://go.dev/doc/install) installed
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
scripts/run <command> [<args>]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Workflow:**
|
|
42
|
+
|
|
43
|
+
1. Populate the local database with the `pull` command.
|
|
44
|
+
2. Start the MCP server with the `mcp` command.
|
|
45
|
+
|
|
46
|
+
Re-run `pull` anytime to update the database with new GitHub data. You can do this while `mcp` is running, but MCP requests may temporarily return errors during the update.
|
|
47
|
+
|
|
48
|
+
Each command has its own arguments. Some can be set via environment variables. The app will also load environment variables from a `.env` file in the GitHub Brain's home directory - `~/.github-brain` by default.
|
|
49
|
+
You can change the home directory with the `-m` argument available for all commands. When executing `scripts/run`, the home directory is set to the checkout directory.
|
|
50
|
+
|
|
51
|
+
<details>
|
|
52
|
+
<summary>Example .env file</summary>
|
|
53
|
+
|
|
54
|
+
GITHUB_TOKEN=your_github_token
|
|
55
|
+
ORGANIZATION=my-org
|
|
56
|
+
|
|
57
|
+
</details>
|
|
58
|
+
|
|
59
|
+
### `pull`
|
|
60
|
+
|
|
61
|
+
Populate the local database with GitHub data.
|
|
62
|
+
|
|
63
|
+
Example:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
scripts/run pull -o my-org
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The first call for an organization may take a while. Subsequent calls are faster, updating only with new data.
|
|
70
|
+
|
|
71
|
+
| Argument | Variable | Description |
|
|
72
|
+
| :------- | :---------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
73
|
+
| `-t` | `GITHUB_TOKEN` | Your GitHub [personal token](https://github.com/settings/personal-access-tokens) to access the API. **Required.** |
|
|
74
|
+
| `-o` | `ORGANIZATION` | The GitHub organization to pull data from. **Required.** |
|
|
75
|
+
| `-m` | | GitHub Brain home directory. Default: `~/.github-brain` or the repo checkout directory if executed via `scripts/run`. |
|
|
76
|
+
| `-i` | | Only pull selected entities. Choose from: `repositories`, `discussions`, `issues`, `pull-requests`. Comma-separated list. |
|
|
77
|
+
| `-f` | | Remove all data before pulling. If combined with `-i`, only the specified items will be removed. |
|
|
78
|
+
| `-e` | `EXCLUDED_REPOSITORIES` | Comma-separated list of repositories to exclude from the pull of discussions, issues, and pull requests. Useful for large repositories that are not relevant to the analysis. |
|
|
79
|
+
|
|
80
|
+
<details>
|
|
81
|
+
<summary>Personal access token scopes</summary>
|
|
82
|
+
|
|
83
|
+
Use the [fine-grained personal access tokens](https://github.com/settings/personal-access-tokens).
|
|
84
|
+
|
|
85
|
+
For private organizations, the token must have the following configuration:
|
|
86
|
+
|
|
87
|
+
- Repository permissions: Read access to discussions, issues, metadata, and pull requests. Click [here](https://github.com/settings/personal-access-tokens/new?name=github-brain&description=http%3A%2F%2Fgithub.com%2Fwham%2Fgithub-brain&issues=read&pull_requests=read&discussions=read) to generate.
|
|
88
|
+
|
|
89
|
+
For public organizations, an empty token is sufficient, as the data is publicly accessible.
|
|
90
|
+
|
|
91
|
+
</details>
|
|
92
|
+
|
|
93
|
+
### `mcp`
|
|
94
|
+
|
|
95
|
+
Start the MCP server using the local database.
|
|
96
|
+
|
|
97
|
+
Example:
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
scripts/run mcp -o my-org
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
| Argument | Variable | Description |
|
|
104
|
+
| :------- | :------------- | :-------------------------------------------------------------------------------------------------------------------- |
|
|
105
|
+
| `-o` | `ORGANIZATION` | The GitHub organization to work with. **Required.** |
|
|
106
|
+
| `-m` | | GitHub Brain home directory. Default: `~/.github-brain` or the repo checkout directory if executed via `scripts/run`. |
|
|
107
|
+
|
|
108
|
+
### `ui`
|
|
109
|
+
|
|
110
|
+
Start the UI server, which provides a web-based interface for interacting with the GitHub data. Alternative to MCP for quick lookups.
|
|
111
|
+
|
|
112
|
+
Example:
|
|
113
|
+
|
|
114
|
+
```sh
|
|
115
|
+
scripts/run ui -o my-org
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
| Argument | Variable | Description |
|
|
119
|
+
| :------- | :------------- | :-------------------------------------------------------------------------------------------------------------------- |
|
|
120
|
+
| `-o` | `ORGANIZATION` | The GitHub organization to work with. **Required.** |
|
|
121
|
+
| `-m` | | GitHub Brain home directory. Default: `~/.github-brain` or the repo checkout directory if executed via `scripts/run`. |
|
|
122
|
+
| `-p` | `UI_PORT` | Port for the UI server. Default: `8080`. |
|
|
123
|
+
|
|
124
|
+
### Additional Arguments
|
|
125
|
+
|
|
126
|
+
**Version:**
|
|
127
|
+
|
|
128
|
+
```sh
|
|
129
|
+
github-brain --version
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Displays the current version (commit hash and build date).
|
|
133
|
+
|
|
134
|
+
## Installation
|
|
135
|
+
|
|
136
|
+
### NPM (Recommended)
|
|
137
|
+
|
|
138
|
+
Install globally:
|
|
139
|
+
|
|
140
|
+
```sh
|
|
141
|
+
npm install -g github-brain
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Then run commands directly:
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
github-brain pull -o my-org
|
|
148
|
+
github-brain mcp -o my-org
|
|
149
|
+
github-brain ui -o my-org
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### From Source
|
|
153
|
+
|
|
154
|
+
`scripts/run` is a convenience script that runs the MCP server. It builds the Go code and runs the `mcp` command with the checkout directory as the working directory. As a result, the SQLite database will be created in the `db` folder of the checkout directory.
|
|
155
|
+
|
|
156
|
+
### Claude
|
|
157
|
+
|
|
158
|
+
Add to the Claude MCP configuration file:
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"mcpServers": {
|
|
163
|
+
"github-brain": {
|
|
164
|
+
"type": "stdio",
|
|
165
|
+
"command": "<path-to-the-checkout-directory>/scripts/run",
|
|
166
|
+
"args": ["mcp"]
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Where `<path-to-the-checkout-directory>` is the path to the GitHub Brain repository on your local machine. Merge if `mcpServers` already exists.
|
|
172
|
+
|
|
173
|
+
### VS Code
|
|
174
|
+
|
|
175
|
+
Add to the VS Code MCP configuration file:
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"servers": {
|
|
180
|
+
"github-brain": {
|
|
181
|
+
"type": "stdio",
|
|
182
|
+
"command": "<path-to-the-checkout-directory>/scripts/run",
|
|
183
|
+
"args": ["mcp"],
|
|
184
|
+
"version": "0.0.1"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Where `<path-to-the-checkout-directory>` is the path to the GitHub Brain repository on your local machine. Merge if `servers` already exists.
|
|
191
|
+
|
|
192
|
+
## Raycast Extension
|
|
193
|
+
|
|
194
|
+
Run the Raycast extension with:
|
|
195
|
+
|
|
196
|
+
```sh
|
|
197
|
+
scripts/raycast
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
The extension uses the MCP server to search GitHub data.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
|
|
7
|
+
// Platform-specific package mapping
|
|
8
|
+
// Note: Windows package uses simplified name "github-brain-windows" instead of
|
|
9
|
+
// "github-brain-win32-x64" to avoid NPM's spam detection which flags packages
|
|
10
|
+
// with platform-specific suffixes like win32-x64.
|
|
11
|
+
const PLATFORMS = {
|
|
12
|
+
"darwin-arm64": "github-brain-darwin-arm64",
|
|
13
|
+
"darwin-x64": "github-brain-darwin-x64",
|
|
14
|
+
"linux-arm64": "github-brain-linux-arm64",
|
|
15
|
+
"linux-x64": "github-brain-linux-x64",
|
|
16
|
+
"win32-x64": "github-brain-windows",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function getPlatformPackage() {
|
|
20
|
+
const platform = process.platform;
|
|
21
|
+
const arch = process.arch;
|
|
22
|
+
|
|
23
|
+
// Map Node.js arch to our naming convention
|
|
24
|
+
const archMap = {
|
|
25
|
+
arm64: "arm64",
|
|
26
|
+
x64: "x64",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const mappedArch = archMap[arch];
|
|
30
|
+
if (!mappedArch) {
|
|
31
|
+
throw new Error(`Unsupported architecture: ${arch}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const key = `${platform}-${mappedArch}`;
|
|
35
|
+
const pkg = PLATFORMS[key];
|
|
36
|
+
|
|
37
|
+
if (!pkg) {
|
|
38
|
+
throw new Error(`Unsupported platform: ${platform} ${arch}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return pkg;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function getBinaryPath() {
|
|
45
|
+
try {
|
|
46
|
+
const pkg = getPlatformPackage();
|
|
47
|
+
const binaryName =
|
|
48
|
+
process.platform === "win32" ? "github-brain.exe" : "github-brain";
|
|
49
|
+
|
|
50
|
+
// Try to resolve the binary from the platform-specific package
|
|
51
|
+
const pkgPath = require.resolve(`${pkg}/package.json`);
|
|
52
|
+
const pkgDir = path.dirname(pkgPath);
|
|
53
|
+
const binaryPath = path.join(pkgDir, binaryName);
|
|
54
|
+
|
|
55
|
+
if (fs.existsSync(binaryPath)) {
|
|
56
|
+
return binaryPath;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
throw new Error(`Binary not found at ${binaryPath}`);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error("Error:", error.message);
|
|
62
|
+
console.error(
|
|
63
|
+
"\nThe platform-specific binary package may not be installed."
|
|
64
|
+
);
|
|
65
|
+
console.error("Try running: npm install");
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Get the binary path and execute it
|
|
71
|
+
const binaryPath = getBinaryPath();
|
|
72
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), {
|
|
73
|
+
stdio: "inherit",
|
|
74
|
+
windowsHide: false,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
process.exit(result.status || 0);
|
package/install.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// This install script runs after npm install and verifies the binary is accessible
|
|
4
|
+
const { execSync } = require("child_process");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
// Try to run the binary with --version to verify it works
|
|
9
|
+
const binPath = path.join(__dirname, "bin", "github-brain.js");
|
|
10
|
+
execSync(`node "${binPath}" --version`, { stdio: "inherit" });
|
|
11
|
+
console.log("✓ github-brain installed successfully!");
|
|
12
|
+
} catch (error) {
|
|
13
|
+
// If the binary isn't available yet (e.g., during CI or --no-optional),
|
|
14
|
+
// that's okay - it will be resolved when the user tries to run it
|
|
15
|
+
console.log("✓ github-brain package installed");
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "github-brain",
|
|
3
|
+
"version": "0.0.9",
|
|
4
|
+
"description": "MCP server for searching GitHub discussions, issues, and pull requests",
|
|
5
|
+
"bin": {
|
|
6
|
+
"github-brain": "bin/github-brain.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node install.js"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/wham/github-brain.git"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"github",
|
|
17
|
+
"mcp",
|
|
18
|
+
"search",
|
|
19
|
+
"discussions",
|
|
20
|
+
"issues",
|
|
21
|
+
"pull-requests"
|
|
22
|
+
],
|
|
23
|
+
"author": "wham",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"optionalDependencies": {
|
|
26
|
+
"github-brain-darwin-arm64": "0.0.9",
|
|
27
|
+
"github-brain-darwin-x64": "0.0.9",
|
|
28
|
+
"github-brain-linux-arm64": "0.0.9",
|
|
29
|
+
"github-brain-linux-x64": "0.0.9",
|
|
30
|
+
"github-brain-windows": "0.0.9"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"bin",
|
|
34
|
+
"install.js"
|
|
35
|
+
]
|
|
36
|
+
}
|