Skip to content

Commit 3d27c20

Browse files
authored
Merge pull request #2 from bucketeer-io/feat/init-impl
feat: init implementation
2 parents c2624d1 + 1019f44 commit 3d27c20

File tree

22 files changed

+3824
-120
lines changed

22 files changed

+3824
-120
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
ci:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
12+
13+
- name: Set up Node.js
14+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
15+
with:
16+
node-version: '22'
17+
cache: 'npm'
18+
19+
- name: Install dependencies
20+
run: npm ci
21+
22+
- name: Run lint
23+
run: npm run lint
24+
25+
- name: Run tests
26+
run: npm run test:ci

.gitignore

Lines changed: 28 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,46 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
lerna-debug.log*
8-
.pnpm-debug.log*
9-
10-
# Diagnostic reports (https://nodejs.org/api/report.html)
11-
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12-
13-
# Runtime data
14-
pids
15-
*.pid
16-
*.seed
17-
*.pid.lock
18-
19-
# Directory for instrumented libs generated by jscoverage/JSCover
20-
lib-cov
21-
22-
# Coverage directory used by tools like istanbul
23-
coverage
24-
*.lcov
25-
26-
# nyc test coverage
27-
.nyc_output
28-
29-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30-
.grunt
31-
32-
# Bower dependency directory (https://bower.io/)
33-
bower_components
34-
35-
# node-waf configuration
36-
.lock-wscript
37-
38-
# Compiled binary addons (https://nodejs.org/api/addons.html)
39-
build/Release
40-
41-
# Dependency directories
1+
# Dependencies
422
node_modules/
43-
jspm_packages/
3+
npm-debug.log
444

45-
# Snowpack dependency directory (https://snowpack.dev/)
46-
web_modules/
475

48-
# TypeScript cache
6+
# Build output
7+
build/
8+
dist/
9+
*.js.map
10+
11+
# TypeScript compiled files
4912
*.tsbuildinfo
5013

51-
# Optional npm cache directory
14+
# Cache files
5215
.npm
53-
54-
# Optional eslint cache
5516
.eslintcache
5617

57-
# Optional stylelint cache
58-
.stylelintcache
59-
60-
# Microbundle cache
61-
.rpt2_cache/
62-
.rts2_cache_cjs/
63-
.rts2_cache_es/
64-
.rts2_cache_umd/
65-
66-
# Optional REPL history
67-
.node_repl_history
68-
69-
# Output of 'npm pack'
70-
*.tgz
71-
72-
# Yarn Integrity file
73-
.yarn-integrity
74-
75-
# dotenv environment variable files
18+
# Environment variables
7619
.env
20+
.env.local
7721
.env.development.local
7822
.env.test.local
7923
.env.production.local
80-
.env.local
81-
82-
# parcel-bundler cache (https://parceljs.org/)
83-
.cache
84-
.parcel-cache
85-
86-
# Next.js build output
87-
.next
88-
out
89-
90-
# Nuxt.js build / generate output
91-
.nuxt
92-
dist
93-
94-
# Gatsby files
95-
.cache/
96-
# Comment in the public line in if your project uses Gatsby and not Next.js
97-
# https://nextjs.org/blog/next-9-1#public-directory-support
98-
# public
9924

100-
# vuepress build output
101-
.vuepress/dist
25+
# OS specific files
26+
.DS_Store
27+
Thumbs.db
10228

103-
# vuepress v2.x temp and cache directory
104-
.temp
105-
.cache
29+
# Editor directories and files
30+
.idea/
31+
.vscode/
32+
*.swp
33+
*.swo
10634

107-
# vitepress build output
108-
**/.vitepress/dist
35+
# Temporary directories
36+
tmp/
37+
temp/
10938

110-
# vitepress cache directory
111-
**/.vitepress/cache
112-
113-
# Docusaurus cache and generated files
114-
.docusaurus
115-
116-
# Serverless directories
117-
.serverless/
118-
119-
# FuseBox cache
120-
.fusebox/
121-
122-
# DynamoDB Local files
123-
.dynamodb/
124-
125-
# TernJS port file
126-
.tern-port
39+
# Logs
40+
logs/
41+
*.log
42+
npm-debug.log*
12743

128-
# Stores VSCode versions used for testing VSCode extensions
129-
.vscode-test
44+
# Files
45+
files/
13046

131-
# yarn v2
132-
.yarn/cache
133-
.yarn/unplugged
134-
.yarn/build-state.yml
135-
.yarn/install-state.gz
136-
.pnp.*

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,4 @@
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201201
limitations under the License.
202+

README.md

Lines changed: 169 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,169 @@
1-
# bucketeer-docs-local-mcp-server
2-
Local MCP Server to query Bucketeer documentation
1+
# Bucketeer Docs Local MCP Server
2+
3+
## Overview
4+
5+
This project provides a Model Context Protocol (MCP) server for Bucketeer documentation. It offers an interface for searching and retrieving content from Bucketeer's feature flag and experimentation platform documentation, enabling AI assistants to provide accurate information about Bucketeer's features and usage.
6+
7+
## Environment Setup
8+
9+
### Requirements
10+
11+
- Node.js 18+
12+
- npm
13+
14+
### Installation Steps
15+
16+
1. Clone the repository:
17+
18+
```bash
19+
git clone <repository-url>
20+
cd bucketeer-docs-local-mcp-server
21+
```
22+
23+
2. Install dependencies:
24+
25+
```bash
26+
npm install
27+
```
28+
29+
3. Build the project:
30+
31+
```bash
32+
npm run build
33+
```
34+
35+
4. Build the document index:
36+
37+
```bash
38+
npm run build:index
39+
```
40+
41+
## Starting the Server
42+
43+
```bash
44+
npm start
45+
```
46+
47+
## Document Sources
48+
49+
The server automatically fetches and indexes documentation from the [bucketeer-io/bucketeer-docs](https://github.com/bucketeer-io/bucketeer-docs) repository:
50+
51+
- **GitHub Repository Integration**:
52+
- Automatically fetches `.mdx` files from the `docs/` directory and all subdirectories
53+
- Processes frontmatter and markdown content for optimal search indexing
54+
- Caches fetched content using SHA hashes and only updates when files are modified
55+
- Supports recursive directory traversal to capture all documentation files
56+
57+
- **Intelligent Indexing**:
58+
- Extracts keywords from titles, descriptions, headers, and content
59+
- Builds searchable index with relevance scoring based on keyword matches and full-text search
60+
- Optimized for Bucketeer-specific terminology (feature flags, experiments, SDKs, targeting, etc.)
61+
- Handles frontmatter extraction (title, description) from MDX files
62+
63+
- **Cache Management**:
64+
- Files are cached locally in `files/docs/` directory as JSON files
65+
- Document index is stored in `files/index/document-index.json`
66+
- GitHub cache stored in `files/docs/github_cache.json` with SHA-based change detection
67+
- Use `npm run build:index:force` to force rebuild the entire index
68+
69+
## Cursor and Claude Desktop Configuration
70+
71+
### Setup
72+
73+
Configure the MCP Server by adding the following to your `mcp.json` or `claude_desktop_config.json` file, referring to the documentation for Cursor (https://docs.cursor.com/context/model-context-protocol#configuring-mcp-servers) and Claude Desktop (https://modelcontextprotocol.io/quickstart/user):
74+
75+
```json
76+
{
77+
"mcpServers": {
78+
"bucketeer-docs": {
79+
"command": "node",
80+
"args": ["/path/to/bucketeer-docs-local-mcp-server/dist/main.js"]
81+
}
82+
}
83+
}
84+
```
85+
86+
**Important**: Make sure to use the absolute path to the `dist/main.js` file after building the project.
87+
88+
## Usage
89+
90+
When the MCP server is running, the following tools are available:
91+
92+
### 1. `search-docs` - Search Bucketeer Documentation
93+
- **Parameter**: `query` (string) - The search query
94+
- **Parameter**: `limit` (number, optional) - Maximum number of results to return (default: 5)
95+
96+
**Example**:
97+
```json
98+
{
99+
"name": "search-docs",
100+
"arguments": {
101+
"query": "feature flags SDK integration",
102+
"limit": 5
103+
}
104+
}
105+
```
106+
107+
**Response**: Returns an array of search results with title, URL, path, description, excerpt, and relevance score.
108+
109+
### 2. `get-document` - Get Specific Document Content
110+
- **Parameter**: `path` (string) - Document path obtained from search results
111+
112+
**Example**:
113+
```json
114+
{
115+
"name": "get-document",
116+
"arguments": {
117+
"path": "getting-started/create-feature-flag"
118+
}
119+
}
120+
```
121+
122+
**Response**: Returns the full document content including title, description, URL, and complete markdown content.
123+
124+
125+
## Development Commands
126+
127+
- `npm run build` - Compile TypeScript files to `dist/` directory
128+
- `npm run build:index` - Build/update the document index from GitHub repository
129+
- `npm run build:index:force` - Force rebuild the entire index (ignores cache)
130+
- `npm run dev:index` - Build and update index in development mode
131+
- `npm run dev` - Build and start server in development mode
132+
133+
## Configuration
134+
135+
The server is configured via `src/config/index.ts`:
136+
137+
- **siteName**: "Bucketeer"
138+
- **websiteUrl**: "https://docs.bucketeer.io"
139+
- **githubRepo**: "https://github.com/bucketeer-io/bucketeer-docs"
140+
- **docsDirectory**: "docs" (directory in GitHub repo containing documentation)
141+
- **searchLimitDefault**: 5 (default number of search results)
142+
- **useGithubSource**: true (always uses GitHub as source)
143+
144+
## File Structure
145+
146+
```
147+
files/
148+
├── docs/ # Cached JSON files from GitHub repository
149+
├── index/ # Document search index
150+
│ └── document-index.json
151+
└── [created automatically when building index]
152+
```
153+
154+
## Architecture
155+
156+
The server consists of several key components:
157+
158+
1. **GithubDocumentFetcher**: Recursively fetches `.mdx` files from the GitHub repository
159+
2. **IndexManager**: Builds and manages the searchable document index
160+
3. **SearchService**: Provides search functionality with keyword matching and full-text search
161+
4. **MCP Server**: Exposes tools via the Model Context Protocol
162+
163+
## Contributing
164+
165+
Contributions are welcome! Please feel free to submit a Pull Request.
166+
167+
## License
168+
169+
MIT

biome.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
3+
"organizeImports": {
4+
"enabled": true
5+
},
6+
"linter": {
7+
"enabled": true,
8+
"rules": {
9+
"recommended": true
10+
},
11+
"ignore": ["dist/**"]
12+
},
13+
"formatter": {
14+
"enabled": true,
15+
"indentStyle": "space",
16+
"indentWidth": 2,
17+
"ignore": ["dist/**"]
18+
},
19+
"javascript": {
20+
"formatter": {
21+
"quoteStyle": "single",
22+
"trailingComma": "es5",
23+
"semicolons": "always"
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)