Skip to content

Commit 8137bc6

Browse files
authored
feat: Create remote MCP Server for 10xRules (#44)
* feat: add initial version of mcp server * fix: update lock * feat: provide rules interface * docs: add READMEs * feat: adjust ci/cd for prod needs
1 parent 5a0bb23 commit 8137bc6

19 files changed

+9443
-143
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy MCP Server Worker
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
CLOUDFLARE_API_TOKEN:
7+
required: true
8+
CLOUDFLARE_ACCOUNT_ID:
9+
required: true
10+
11+
jobs:
12+
deploy-worker:
13+
name: Deploy Worker (mcp-server)
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
# We need Node.js to generate rules and run wrangler/npm
20+
- name: Set up Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version-file: '.nvmrc' # Assuming .nvmrc is in the root
24+
cache: 'npm'
25+
cache-dependency-path: '**/package-lock.json' # Cache npm deps for root and worker
26+
27+
- name: Install root dependencies
28+
run: npm ci
29+
30+
- name: Generate preparedRules.json
31+
run: npm run generate-rules # Assuming direct execution works
32+
33+
- name: Install worker dependencies
34+
run: cd mcp-server && npm ci
35+
36+
- name: Deploy Worker (mcp-server)
37+
env:
38+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
39+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
40+
run: cd mcp-server && npx wrangler deploy # Assumes wrangler.jsonc is configured

.github/workflows/master.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,19 @@ jobs:
6363
node-version-file: '.nvmrc'
6464
cache: 'npm'
6565

66-
- name: Install dependencies
66+
- name: Install root dependencies
6767
run: npm ci
6868

69+
- name: Generate preparedRules.json
70+
run: npm run generate-rules # Assuming direct execution works
71+
6972
- name: Build Astro site
7073
env:
7174
PUBLIC_ENV_NAME: ${{ secrets.PUBLIC_ENV_NAME }}
7275
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
7376
SUPABASE_PUBLIC_KEY: ${{ secrets.SUPABASE_PUBLIC_KEY }}
7477
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
75-
run: npm run build
78+
run: npm run build # This should create the dist/ directory
7679

7780
- name: Deploy to Cloudflare Pages
7881
id: deployment
@@ -82,3 +85,16 @@ jobs:
8285
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} # Secret needed for Cloudflare Account ID
8386
command: pages deploy dist --project-name='ai-rules-builder' # Use the command input
8487
gitHubToken: ${{ secrets.GITHUB_TOKEN }} # Optional: Adds commit details to deployments
88+
89+
deploy-worker:
90+
name: Deploy Worker
91+
needs: deploy # Run after successful pages deployment
92+
runs-on: ubuntu-latest
93+
permissions:
94+
contents: read # Needed to checkout the repository
95+
steps:
96+
- name: Call Deploy Worker Workflow
97+
uses: ./.github/workflows/deploy-mcp-server.yml
98+
with:
99+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
100+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ test-results
3131
coverage
3232
playwright-report/*
3333
playwright-report/index.html
34+
35+
# Generated data files
36+
src/data/preparedRules.json
37+
mcp-server/src/preparedRules.json

README.md

Lines changed: 149 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -1,143 +1,151 @@
1-
# 10xRules.ai by 10xDevs
2-
1+
# 10xRules.ai by 10xDevs
2+
33
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
44
[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-)
5-
<!-- ALL-CONTRIBUTORS-BADGE:END -->
6-
7-
[![Build and Deploy](https://github.com/przeprogramowani/ai-rules-builder/actions/workflows/master.yml/badge.svg)](https://github.com/przeprogramowani/ai-rules-builder/actions/workflows/master.yml)
8-
9-
![](./public/demo.png)
10-
11-
👉 [10xRules.ai](https://10xrules.ai)
12-
13-
Create so called "rules for AI" written in Markdown, used by tools such as GitHub Copilot, Cursor and Windsurf, through an interactive, visual interface.
14-
15-
## Features
16-
17-
- **Build AI Rules:** Create customized rule sets for different editors (Copilot, Cursor, Windsurf)
18-
- **Export Options:** Easily copy to clipboard or download as markdown files
19-
- **Smart Import:** Automatically generate rules by dropping package.json or requirements.txt files
20-
21-
## Getting Started
22-
23-
1. **Installation**
24-
25-
```bash
26-
npm install
27-
```
28-
29-
2. **Development**
30-
31-
```bash
32-
npm run dev
33-
```
34-
35-
3. **Build**
36-
```bash
37-
npm run build
38-
```
39-
40-
## Tech Stack
41-
42-
- Astro 5
43-
- TypeScript 5
44-
- React 18.3
45-
- Tailwind 4
46-
- Zustand
47-
- Lucide React
48-
49-
### Feature Flags
50-
51-
The project uses a feature flags system to separate deployments from releases. Feature flags can be used to control functionality availability based on the environment (`local`, `integration`, `prod`). The system supports flags for:
52-
53-
- API endpoints
54-
- Astro pages
55-
- UI components visibility
56-
57-
For detailed documentation about feature flags implementation, see `.ai/feature-flags.md`.
58-
59-
### Testing
60-
61-
This project uses a comprehensive testing stack including unit tests and end-to-end tests.
62-
63-
### Unit Testing with Vitest
64-
65-
Unit tests are implemented using Vitest with JSDOM for browser environment simulation and React Testing Library for component testing.
66-
67-
Available commands:
68-
69-
```bash
70-
# Run unit tests
71-
npm run test
72-
73-
# Run tests in watch mode
74-
npm run test:watch
75-
76-
# Run tests with UI
77-
npm run test:ui
78-
79-
# Generate coverage report
80-
npm run test:coverage
81-
```
82-
83-
### End-to-End Testing with Playwright
84-
85-
E2E tests are implemented using Playwright with the Page Object Model pattern for maintainable tests.
86-
87-
Available commands:
88-
89-
```bash
90-
# Run E2E tests
91-
npm run test:e2e
92-
93-
# Run E2E tests with UI
94-
npm run test:e2e:ui
95-
96-
# Generate test code with codegen
97-
npm run test:e2e:codegen
98-
```
99-
100-
### Test Structure
101-
102-
- `tests/unit/` - Unit tests
103-
- `tests/setup/` - Test setup files
104-
- `e2e/` - End-to-end tests
105-
- `e2e/page-objects/` - Page Object Model classes
106-
- `e2e/fixtures/` - Test fixtures and data
107-
108-
### CI/CD Integration
109-
110-
Tests are automatically run in the CI/CD pipeline using GitHub Actions. See `.github/workflows/tests.yml` for configuration.
111-
112-
## Contributions
113-
114-
Send updates to:
115-
116-
- `src/data/dictionaries.ts`
117-
- `src/data/rules/...`
118-
119-
Important: Introduce translations for new rules in `src/i18n/translations.ts`, otherwise the unit test will fail.
120-
121-
## How to Write Effective Rules
122-
123-
When contributing new rules, please:
124-
125-
- **Be specific:** "Use React.memo for expensive components" not "Optimize components"
126-
- **Make it actionable:** Provide clear guidance that can be immediately applied
127-
- **Include placeholders:** Use `{{placeholder_text}}` for project-specific values
128-
- **Follow conventions:** Match the style and structure of existing rules
129-
- **Focus on best practices:** Rules should represent industry standards, not personal preferences
130-
131-
See examples in `src/data/rules/` directory for each technology stack.
132-
133-
---
134-
135-
[10xDevs](https://10xdevs.pl) - launching soon 🚀
136-
137-
## Contributors ✨
138-
139-
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
140-
5+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
6+
7+
[![Build and Deploy](https://github.com/przeprogramowani/ai-rules-builder/actions/workflows/master.yml/badge.svg)](https://github.com/przeprogramowani/ai-rules-builder/actions/workflows/master.yml)
8+
9+
![](./public/demo.png)
10+
11+
👉 [10xRules.ai](https://10xrules.ai)
12+
13+
Create so called "rules for AI" written in Markdown, used by tools such as GitHub Copilot, Cursor and Windsurf, through an interactive, visual interface.
14+
15+
## Features
16+
17+
- **Build AI Rules:** Create customized rule sets for different editors (Copilot, Cursor, Windsurf)
18+
- **Export Options:** Easily copy to clipboard or download as markdown files
19+
- **Smart Import:** Automatically generate rules by dropping package.json or requirements.txt files
20+
- **Editor Integration:** Provides programmatic access to rules via an [MCP Server](./mcp-server/README.md) for integration with AI assistants in editors like Cursor.
21+
22+
## Getting Started
23+
24+
1. **Installation**
25+
26+
```bash
27+
npm install
28+
```
29+
30+
2. **Development**
31+
32+
```bash
33+
npm run dev
34+
```
35+
36+
3. **Build**
37+
```bash
38+
npm run build
39+
```
40+
41+
## Tech Stack
42+
43+
- Astro 5
44+
- TypeScript 5
45+
- React 18.3
46+
- Tailwind 4
47+
- Zustand
48+
- Lucide React
49+
50+
## Project Components
51+
52+
This repository contains multiple key components:
53+
54+
- **AI Rules Builder UI (Root):** The main Astro/React application providing the web interface for creating and managing AI rules.
55+
- **MCP Server (`./mcp-server`):** A Cloudflare Worker implementing the Model Context Protocol (MCP). This server allows AI assistants (like Cursor, Claude, etc.) to programmatically access the defined AI rules via specific tools (`listAvailableRules`, `getRuleContent`). This enables integration with editors for fetching context-aware coding guidelines. For detailed setup, usage, and planned features, see the [MCP Server README](./mcp-server/README.md).
56+
57+
### Feature Flags
58+
59+
The project uses a feature flags system to separate deployments from releases. Feature flags can be used to control functionality availability based on the environment (`local`, `integration`, `prod`). The system supports flags for:
60+
61+
- API endpoints
62+
- Astro pages
63+
- UI components visibility
64+
65+
For detailed documentation about feature flags implementation, see `.ai/feature-flags.md`.
66+
67+
### Testing
68+
69+
This project uses a comprehensive testing stack including unit tests and end-to-end tests.
70+
71+
### Unit Testing with Vitest
72+
73+
Unit tests are implemented using Vitest with JSDOM for browser environment simulation and React Testing Library for component testing.
74+
75+
Available commands:
76+
77+
```bash
78+
# Run unit tests
79+
npm run test
80+
81+
# Run tests in watch mode
82+
npm run test:watch
83+
84+
# Run tests with UI
85+
npm run test:ui
86+
87+
# Generate coverage report
88+
npm run test:coverage
89+
```
90+
91+
### End-to-End Testing with Playwright
92+
93+
E2E tests are implemented using Playwright with the Page Object Model pattern for maintainable tests.
94+
95+
Available commands:
96+
97+
```bash
98+
# Run E2E tests
99+
npm run test:e2e
100+
101+
# Run E2E tests with UI
102+
npm run test:e2e:ui
103+
104+
# Generate test code with codegen
105+
npm run test:e2e:codegen
106+
```
107+
108+
### Test Structure
109+
110+
- `tests/unit/` - Unit tests
111+
- `tests/setup/` - Test setup files
112+
- `e2e/` - End-to-end tests
113+
- `e2e/page-objects/` - Page Object Model classes
114+
- `e2e/fixtures/` - Test fixtures and data
115+
116+
### CI/CD Integration
117+
118+
Tests are automatically run in the CI/CD pipeline using GitHub Actions. See `.github/workflows/tests.yml` for configuration.
119+
120+
## Contributions
121+
122+
Send updates to:
123+
124+
- `src/data/dictionaries.ts`
125+
- `src/data/rules/...`
126+
127+
Important: Introduce translations for new rules in `src/i18n/translations.ts`, otherwise the unit test will fail.
128+
129+
## How to Write Effective Rules
130+
131+
When contributing new rules, please:
132+
133+
- **Be specific:** "Use React.memo for expensive components" not "Optimize components"
134+
- **Make it actionable:** Provide clear guidance that can be immediately applied
135+
- **Include placeholders:** Use `{{placeholder_text}}` for project-specific values
136+
- **Follow conventions:** Match the style and structure of existing rules
137+
- **Focus on best practices:** Rules should represent industry standards, not personal preferences
138+
139+
See examples in `src/data/rules/` directory for each technology stack.
140+
141+
---
142+
143+
[10xDevs](https://10xdevs.pl) - launching soon 🚀
144+
145+
## Contributors ✨
146+
147+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
148+
141149
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
142150
<!-- prettier-ignore-start -->
143151
<!-- markdownlint-disable -->
@@ -156,6 +164,6 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
156164
<!-- markdownlint-restore -->
157165
<!-- prettier-ignore-end -->
158166

159-
<!-- ALL-CONTRIBUTORS-LIST:END -->
160-
161-
We're recognizing all contributors with [all-contributors](https://github.com/all-contributors/all-contributors). Feel invited to collaborate!
167+
<!-- ALL-CONTRIBUTORS-LIST:END -->
168+
169+
We're recognizing all contributors with [all-contributors](https://github.com/all-contributors/all-contributors). Feel invited to collaborate!

mcp-server/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
3+
# wrangler files
4+
.wrangler
5+
.dev.vars*

0 commit comments

Comments
 (0)