@shuji-bonji/rxjs-mcp 0.1.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.
- package/LICENSE +21 -0
- package/README.ja.md +284 -0
- package/README.md +295 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +94 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/analyze-operators.d.ts +3 -0
- package/dist/tools/analyze-operators.d.ts.map +1 -0
- package/dist/tools/analyze-operators.js +396 -0
- package/dist/tools/analyze-operators.js.map +1 -0
- package/dist/tools/execute-stream-worker.d.ts +2 -0
- package/dist/tools/execute-stream-worker.d.ts.map +1 -0
- package/dist/tools/execute-stream-worker.js +246 -0
- package/dist/tools/execute-stream-worker.js.map +1 -0
- package/dist/tools/execute-stream.d.ts +3 -0
- package/dist/tools/execute-stream.d.ts.map +1 -0
- package/dist/tools/execute-stream.js +219 -0
- package/dist/tools/execute-stream.js.map +1 -0
- package/dist/tools/marble-diagram.d.ts +3 -0
- package/dist/tools/marble-diagram.d.ts.map +1 -0
- package/dist/tools/marble-diagram.js +207 -0
- package/dist/tools/marble-diagram.js.map +1 -0
- package/dist/tools/memory-leak.d.ts +3 -0
- package/dist/tools/memory-leak.d.ts.map +1 -0
- package/dist/tools/memory-leak.js +285 -0
- package/dist/tools/memory-leak.js.map +1 -0
- package/dist/tools/suggest-pattern.d.ts +3 -0
- package/dist/tools/suggest-pattern.d.ts.map +1 -0
- package/dist/tools/suggest-pattern.js +571 -0
- package/dist/tools/suggest-pattern.js.map +1 -0
- package/dist/types.d.ts +85 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Shuji Bonji
|
|
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.ja.md
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# RxJS MCP Server
|
|
2
|
+
|
|
3
|
+
ClaudeなどのAIアシスタントから直接RxJSストリームを実行、デバッグ、可視化できます。
|
|
4
|
+
|
|
5
|
+
## 機能
|
|
6
|
+
|
|
7
|
+
### 🚀 ストリーム実行
|
|
8
|
+
- RxJSコードを実行し、発行された値をキャプチャ
|
|
9
|
+
- タイムスタンプ付きタイムライン可視化
|
|
10
|
+
- メモリ使用量トラッキング
|
|
11
|
+
- 主要なRxJSオペレーターをすべてサポート
|
|
12
|
+
|
|
13
|
+
### 📊 マーブルダイアグラム
|
|
14
|
+
- ASCIIマーブルダイアグラムを生成
|
|
15
|
+
- 時間経過に沿ったストリームの動作を可視化
|
|
16
|
+
- パターンの自動検出
|
|
17
|
+
- 凡例と説明を表示
|
|
18
|
+
|
|
19
|
+
### 🔍 オペレーター分析
|
|
20
|
+
- オペレーターチェーンのパフォーマンスを分析
|
|
21
|
+
- 潜在的な問題やボトルネックを検出
|
|
22
|
+
- 代替アプローチを提案
|
|
23
|
+
- オペレーターを機能別に分類
|
|
24
|
+
|
|
25
|
+
### 🛡️ メモリリーク検出
|
|
26
|
+
- 解除されていないサブスクリプションを特定
|
|
27
|
+
- クリーンアップパターンの欠落を検出
|
|
28
|
+
- フレームワーク固有の推奨事項(Angular、React、Vue)
|
|
29
|
+
- 適切なクリーンアップ例を提供
|
|
30
|
+
|
|
31
|
+
### 💡 パターン提案
|
|
32
|
+
- 実戦で検証済みのRxJSパターンを取得
|
|
33
|
+
- フレームワーク固有の実装
|
|
34
|
+
- 一般的なユースケースをカバー:
|
|
35
|
+
- バックオフ付きHTTPリトライ
|
|
36
|
+
- 検索タイプアヘッド
|
|
37
|
+
- WebSocket再接続
|
|
38
|
+
- フォームバリデーション
|
|
39
|
+
- 状態管理
|
|
40
|
+
- その他多数...
|
|
41
|
+
|
|
42
|
+
## インストール
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# グローバルインストール
|
|
46
|
+
npm install -g @shuji-bonji/rxjs-mcp
|
|
47
|
+
|
|
48
|
+
# またはnpxで使用
|
|
49
|
+
npx @shuji-bonji/rxjs-mcp
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 設定
|
|
53
|
+
|
|
54
|
+
### Claude Desktop
|
|
55
|
+
|
|
56
|
+
`~/Library/Application Support/Claude/claude_desktop_config.json` に追加:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"mcpServers": {
|
|
61
|
+
"rxjs": {
|
|
62
|
+
"command": "npx",
|
|
63
|
+
"args": ["@shuji-bonji/rxjs-mcp"]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### VS Code(Continue/Copilot)
|
|
70
|
+
|
|
71
|
+
`.vscode/mcp.json` に追加:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"mcpServers": {
|
|
76
|
+
"rxjs": {
|
|
77
|
+
"command": "npx",
|
|
78
|
+
"args": ["@shuji-bonji/rxjs-mcp"]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Cursor
|
|
85
|
+
|
|
86
|
+
`~/.cursor/mcp.json` に追加:
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"mcpServers": {
|
|
91
|
+
"rxjs": {
|
|
92
|
+
"command": "npx",
|
|
93
|
+
"args": ["@shuji-bonji/rxjs-mcp"]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## 利用可能なツール
|
|
100
|
+
|
|
101
|
+
### execute_stream
|
|
102
|
+
|
|
103
|
+
RxJSコードを実行し、タイムライン付きでストリームの発行をキャプチャします。
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
// 使用例
|
|
107
|
+
const stream$ = interval(100).pipe(
|
|
108
|
+
take(5),
|
|
109
|
+
map(x => x * 2)
|
|
110
|
+
);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### generate_marble
|
|
114
|
+
|
|
115
|
+
イベントデータからASCIIマーブルダイアグラムを生成します。
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
// 入力:タイムスタンプ付きイベントの配列
|
|
119
|
+
[
|
|
120
|
+
{ time: 0, value: 'A' },
|
|
121
|
+
{ time: 50, value: 'B' },
|
|
122
|
+
{ time: 100, value: 'C' }
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
// 出力: A----B----C--|
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### analyze_operators
|
|
129
|
+
|
|
130
|
+
RxJSオペレーターチェーンのパフォーマンスとベストプラクティスを分析します。
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
// 以下のようなチェーンを分析:
|
|
134
|
+
source$.pipe(
|
|
135
|
+
map(x => x * 2),
|
|
136
|
+
filter(x => x > 10),
|
|
137
|
+
switchMap(x => fetchData(x)),
|
|
138
|
+
retry(3)
|
|
139
|
+
)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### detect_memory_leak
|
|
143
|
+
|
|
144
|
+
潜在的なメモリリークとクリーンアップ漏れを検出します。
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
// 以下のような問題を検出:
|
|
148
|
+
- unsubscribeの欠落
|
|
149
|
+
- takeUntilオペレーターの未使用
|
|
150
|
+
- 完了しないSubject
|
|
151
|
+
- 無限interval
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### suggest_pattern
|
|
155
|
+
|
|
156
|
+
一般的なユースケース向けの本番環境対応パターンを取得します。
|
|
157
|
+
|
|
158
|
+
利用可能なパターン:
|
|
159
|
+
- `http-retry` - リトライ付き堅牢なHTTP
|
|
160
|
+
- `search-typeahead` - デバウンス付き検索
|
|
161
|
+
- `polling` - バックオフ付きスマートポーリング
|
|
162
|
+
- `websocket-reconnect` - 自動再接続WebSocket
|
|
163
|
+
- `form-validation` - リアクティブフォームバリデーション
|
|
164
|
+
- `state-management` - シンプルな状態ストア
|
|
165
|
+
- `cache-refresh` - リフレッシュ戦略付きキャッシュ
|
|
166
|
+
- その他多数...
|
|
167
|
+
|
|
168
|
+
## 使用例
|
|
169
|
+
|
|
170
|
+
### Claudeでの使用
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
ユーザー: 「このRxJSストリームを実行して出力を見せて」
|
|
174
|
+
|
|
175
|
+
Claude: RxJSストリームを実行します。
|
|
176
|
+
|
|
177
|
+
[execute_streamツールを使用]
|
|
178
|
+
|
|
179
|
+
## ストリーム実行結果
|
|
180
|
+
✅ 完了
|
|
181
|
+
実行時間: 523ms
|
|
182
|
+
発行された値: 5
|
|
183
|
+
|
|
184
|
+
### 発行された値
|
|
185
|
+
[0, 2, 4, 6, 8]
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### メモリリークのデバッグ
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
ユーザー: 「このAngularコンポーネントのメモリリークをチェックして」
|
|
192
|
+
|
|
193
|
+
Claude: コンポーネントの潜在的なメモリリークを分析します。
|
|
194
|
+
|
|
195
|
+
[detect_memory_leakツールを使用]
|
|
196
|
+
|
|
197
|
+
## メモリリーク分析
|
|
198
|
+
⚠️ 潜在的なリークを検出
|
|
199
|
+
|
|
200
|
+
1. 🔴 subscription(重大度:高)
|
|
201
|
+
- subscribe()が3回見つかりましたが、unsubscribe()は1回のみ
|
|
202
|
+
- 修正:destroy$ subjectでtakeUntilパターンを使用
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### パターンの取得
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
ユーザー: 「RxJSで検索を実装する方法を教えて」
|
|
209
|
+
|
|
210
|
+
Claude: 検索タイプアヘッドパターンを紹介します。
|
|
211
|
+
|
|
212
|
+
[suggest_patternツールを useCase: 'search-typeahead' で使用]
|
|
213
|
+
|
|
214
|
+
## デバウンス付き検索タイプアヘッド
|
|
215
|
+
[説明付きの完全な実装]
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## 開発
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# リポジトリをクローン
|
|
222
|
+
git clone https://github.com/shuji-bonji/rxjs-mcp-server
|
|
223
|
+
cd rxjs-mcp-server
|
|
224
|
+
|
|
225
|
+
# 依存関係をインストール
|
|
226
|
+
npm install
|
|
227
|
+
|
|
228
|
+
# ビルド
|
|
229
|
+
npm run build
|
|
230
|
+
|
|
231
|
+
# 開発モードで実行
|
|
232
|
+
npm run dev
|
|
233
|
+
|
|
234
|
+
# MCP Inspectorでテスト
|
|
235
|
+
npm test
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## 他のMCPサーバーとの連携
|
|
239
|
+
|
|
240
|
+
RxJS MCP Serverは以下と組み合わせて使用できます:
|
|
241
|
+
- **Angular MCP** - Angularプロジェクトのスキャフォールディング用
|
|
242
|
+
- **TypeScript MCP** - 型チェック用
|
|
243
|
+
- **ESLint MCP** - コード品質用
|
|
244
|
+
|
|
245
|
+
将来的なMeta-MCP統合により、これらのツール間のシームレスな連携が可能になります。
|
|
246
|
+
|
|
247
|
+
## アーキテクチャ
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
┌─────────────────┐
|
|
251
|
+
│ AIアシスタント │
|
|
252
|
+
│ (Claude など) │
|
|
253
|
+
└────────┬────────┘
|
|
254
|
+
│
|
|
255
|
+
MCPプロトコル
|
|
256
|
+
│
|
|
257
|
+
┌────────┴────────┐
|
|
258
|
+
│ RxJS MCP Server│
|
|
259
|
+
├─────────────────┤
|
|
260
|
+
│ • execute_stream│
|
|
261
|
+
│ • generate_marble│
|
|
262
|
+
│ • analyze_operators│
|
|
263
|
+
│ • detect_memory_leak│
|
|
264
|
+
│ • suggest_pattern│
|
|
265
|
+
└─────────────────┘
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## コントリビューション
|
|
269
|
+
|
|
270
|
+
コントリビューションを歓迎します!お気軽にPRを送ってください。
|
|
271
|
+
|
|
272
|
+
## ライセンス
|
|
273
|
+
|
|
274
|
+
MIT
|
|
275
|
+
|
|
276
|
+
## 作者
|
|
277
|
+
|
|
278
|
+
Shuji Bonji
|
|
279
|
+
|
|
280
|
+
## リンク
|
|
281
|
+
|
|
282
|
+
- [GitHubリポジトリ](https://github.com/shuji-bonji/rxjs-mcp-server)
|
|
283
|
+
- [RxJSドキュメント](https://rxjs.dev)
|
|
284
|
+
- [Model Context Protocol](https://modelcontextprotocol.io)
|
package/README.md
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# RxJS MCP Server
|
|
2
|
+
|
|
3
|
+
Execute, debug, and visualize RxJS streams directly from AI assistants like Claude.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
### 🚀 Stream Execution
|
|
8
|
+
- Execute RxJS code and capture emissions
|
|
9
|
+
- Timeline visualization with timestamps
|
|
10
|
+
- Memory usage tracking
|
|
11
|
+
- Support for all major RxJS operators
|
|
12
|
+
|
|
13
|
+
### 📊 Marble Diagrams
|
|
14
|
+
- Generate ASCII marble diagrams
|
|
15
|
+
- Visualize stream behavior over time
|
|
16
|
+
- Automatic pattern detection
|
|
17
|
+
- Clear legend and explanations
|
|
18
|
+
|
|
19
|
+
### 🔍 Operator Analysis
|
|
20
|
+
- Analyze operator chains for performance
|
|
21
|
+
- Detect potential issues and bottlenecks
|
|
22
|
+
- Suggest alternative approaches
|
|
23
|
+
- Categorize operators by function
|
|
24
|
+
|
|
25
|
+
### 🛡️ Memory Leak Detection
|
|
26
|
+
- Identify unsubscribed subscriptions
|
|
27
|
+
- Detect missing cleanup patterns
|
|
28
|
+
- Framework-specific recommendations (Angular, React, Vue)
|
|
29
|
+
- Provide proper cleanup examples
|
|
30
|
+
|
|
31
|
+
### 💡 Pattern Suggestions
|
|
32
|
+
- Get battle-tested RxJS patterns
|
|
33
|
+
- Framework-specific implementations
|
|
34
|
+
- Common use cases covered:
|
|
35
|
+
- HTTP retry with backoff
|
|
36
|
+
- Search typeahead
|
|
37
|
+
- WebSocket reconnection
|
|
38
|
+
- Form validation
|
|
39
|
+
- State management
|
|
40
|
+
- And more...
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Install globally
|
|
46
|
+
npm install -g @shuji-bonji/rxjs-mcp
|
|
47
|
+
|
|
48
|
+
# Or use with npx
|
|
49
|
+
npx @shuji-bonji/rxjs-mcp
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Configuration
|
|
53
|
+
|
|
54
|
+
### Claude Desktop
|
|
55
|
+
|
|
56
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"mcpServers": {
|
|
61
|
+
"rxjs": {
|
|
62
|
+
"command": "npx",
|
|
63
|
+
"args": ["@shuji-bonji/rxjs-mcp"]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### VS Code with Continue/Copilot
|
|
70
|
+
|
|
71
|
+
Add to `.vscode/mcp.json`:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"mcpServers": {
|
|
76
|
+
"rxjs": {
|
|
77
|
+
"command": "npx",
|
|
78
|
+
"args": ["@shuji-bonji/rxjs-mcp"]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Cursor
|
|
85
|
+
|
|
86
|
+
Add to `~/.cursor/mcp.json`:
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"mcpServers": {
|
|
91
|
+
"rxjs": {
|
|
92
|
+
"command": "npx",
|
|
93
|
+
"args": ["@shuji-bonji/rxjs-mcp"]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Available Tools
|
|
100
|
+
|
|
101
|
+
### execute_stream
|
|
102
|
+
|
|
103
|
+
Execute RxJS code and capture stream emissions with timeline.
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
// Example usage
|
|
107
|
+
const stream$ = interval(100).pipe(
|
|
108
|
+
take(5),
|
|
109
|
+
map(x => x * 2)
|
|
110
|
+
);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### generate_marble
|
|
114
|
+
|
|
115
|
+
Generate ASCII marble diagrams from event data.
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
// Input: array of timed events
|
|
119
|
+
[
|
|
120
|
+
{ time: 0, value: 'A' },
|
|
121
|
+
{ time: 50, value: 'B' },
|
|
122
|
+
{ time: 100, value: 'C' }
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
// Output: A----B----C--|
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### analyze_operators
|
|
129
|
+
|
|
130
|
+
Analyze RxJS operator chains for performance and best practices.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
// Analyzes chains like:
|
|
134
|
+
source$.pipe(
|
|
135
|
+
map(x => x * 2),
|
|
136
|
+
filter(x => x > 10),
|
|
137
|
+
switchMap(x => fetchData(x)),
|
|
138
|
+
retry(3)
|
|
139
|
+
)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### detect_memory_leak
|
|
143
|
+
|
|
144
|
+
Detect potential memory leaks and missing cleanup.
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
// Detects issues like:
|
|
148
|
+
- Missing unsubscribe
|
|
149
|
+
- No takeUntil operator
|
|
150
|
+
- Uncompleted Subjects
|
|
151
|
+
- Infinite intervals
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### suggest_pattern
|
|
155
|
+
|
|
156
|
+
Get production-ready patterns for common use cases.
|
|
157
|
+
|
|
158
|
+
Available patterns:
|
|
159
|
+
- `http-retry` - Resilient HTTP with retry
|
|
160
|
+
- `search-typeahead` - Debounced search
|
|
161
|
+
- `polling` - Smart polling with backoff
|
|
162
|
+
- `websocket-reconnect` - Auto-reconnecting WebSocket
|
|
163
|
+
- `form-validation` - Reactive form validation
|
|
164
|
+
- `state-management` - Simple state store
|
|
165
|
+
- `cache-refresh` - Cache with refresh strategy
|
|
166
|
+
- And more...
|
|
167
|
+
|
|
168
|
+
## Usage Examples
|
|
169
|
+
|
|
170
|
+
### With Claude
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
User: "Execute this RxJS stream and show me the output"
|
|
174
|
+
|
|
175
|
+
Claude: I'll execute that RxJS stream for you.
|
|
176
|
+
|
|
177
|
+
[Uses execute_stream tool]
|
|
178
|
+
|
|
179
|
+
## Stream Execution Result
|
|
180
|
+
✅ Completed
|
|
181
|
+
Execution Time: 523ms
|
|
182
|
+
Values Emitted: 5
|
|
183
|
+
|
|
184
|
+
### Emitted Values
|
|
185
|
+
[0, 2, 4, 6, 8]
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Debugging Memory Leaks
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
User: "Check this Angular component for memory leaks"
|
|
192
|
+
|
|
193
|
+
Claude: I'll analyze your component for potential memory leaks.
|
|
194
|
+
|
|
195
|
+
[Uses detect_memory_leak tool]
|
|
196
|
+
|
|
197
|
+
## Memory Leak Analysis
|
|
198
|
+
⚠️ Potential leaks detected
|
|
199
|
+
|
|
200
|
+
1. 🔴 subscription (high severity)
|
|
201
|
+
- Found 3 subscribe() calls but only 1 unsubscribe()
|
|
202
|
+
- Fix: Use takeUntil pattern with destroy$ subject
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Getting Patterns
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
User: "Show me how to implement search with RxJS"
|
|
209
|
+
|
|
210
|
+
Claude: I'll show you the search typeahead pattern.
|
|
211
|
+
|
|
212
|
+
[Uses suggest_pattern tool with useCase: 'search-typeahead']
|
|
213
|
+
|
|
214
|
+
## Search Typeahead with Debounce
|
|
215
|
+
[Full implementation with explanation]
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Security
|
|
219
|
+
|
|
220
|
+
The `execute_stream` tool runs user-provided code in an **isolated Worker thread** to prevent:
|
|
221
|
+
- Main process pollution
|
|
222
|
+
- Resource leaks from infinite loops or timers
|
|
223
|
+
- Access to sensitive Node.js APIs (process, fs, etc.)
|
|
224
|
+
|
|
225
|
+
Execution is forcefully terminated if it exceeds the configured timeout.
|
|
226
|
+
|
|
227
|
+
## Development
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Clone the repository
|
|
231
|
+
git clone https://github.com/shuji-bonji/rxjs-mcp-server
|
|
232
|
+
cd rxjs-mcp-server
|
|
233
|
+
|
|
234
|
+
# Install dependencies
|
|
235
|
+
npm install
|
|
236
|
+
|
|
237
|
+
# Build
|
|
238
|
+
npm run build
|
|
239
|
+
|
|
240
|
+
# Run tests
|
|
241
|
+
npm test # Unit tests (vitest)
|
|
242
|
+
npm run test:mcp # MCP integration test
|
|
243
|
+
npm run test:inspector # MCP Inspector (GUI)
|
|
244
|
+
|
|
245
|
+
# Run in development
|
|
246
|
+
npm run dev
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Integration with Other MCP Servers
|
|
250
|
+
|
|
251
|
+
RxJS MCP Server works great alongside:
|
|
252
|
+
- **Angular MCP** - For Angular project scaffolding
|
|
253
|
+
- **TypeScript MCP** - For type checking
|
|
254
|
+
- **ESLint MCP** - For code quality
|
|
255
|
+
|
|
256
|
+
Future Meta-MCP integration will allow seamless coordination between these tools.
|
|
257
|
+
|
|
258
|
+
## Architecture
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
┌─────────────────┐
|
|
262
|
+
│ AI Assistant │
|
|
263
|
+
│ (Claude, etc) │
|
|
264
|
+
└────────┬────────┘
|
|
265
|
+
│
|
|
266
|
+
MCP Protocol
|
|
267
|
+
│
|
|
268
|
+
┌────────┴────────┐
|
|
269
|
+
│ RxJS MCP Server│
|
|
270
|
+
├─────────────────┤
|
|
271
|
+
│ • execute_stream│
|
|
272
|
+
│ • generate_marble│
|
|
273
|
+
│ • analyze_operators│
|
|
274
|
+
│ • detect_memory_leak│
|
|
275
|
+
│ • suggest_pattern│
|
|
276
|
+
└─────────────────┘
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Contributing
|
|
280
|
+
|
|
281
|
+
Contributions are welcome! Please feel free to submit a PR.
|
|
282
|
+
|
|
283
|
+
## License
|
|
284
|
+
|
|
285
|
+
MIT
|
|
286
|
+
|
|
287
|
+
## Author
|
|
288
|
+
|
|
289
|
+
Shuji Bonji
|
|
290
|
+
|
|
291
|
+
## Links
|
|
292
|
+
|
|
293
|
+
- [GitHub Repository](https://github.com/shuji-bonji/rxjs-mcp-server)
|
|
294
|
+
- [RxJS Documentation](https://rxjs.dev)
|
|
295
|
+
- [Model Context Protocol](https://modelcontextprotocol.io)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { executeStreamTool } from './tools/execute-stream.js';
|
|
6
|
+
import { generateMarbleTool } from './tools/marble-diagram.js';
|
|
7
|
+
import { analyzeOperatorsTool } from './tools/analyze-operators.js';
|
|
8
|
+
import { detectMemoryLeakTool } from './tools/memory-leak.js';
|
|
9
|
+
import { suggestPatternTool } from './tools/suggest-pattern.js';
|
|
10
|
+
// Server configuration
|
|
11
|
+
const server = new Server({
|
|
12
|
+
name: 'rxjs-mcp',
|
|
13
|
+
version: '0.1.0',
|
|
14
|
+
}, {
|
|
15
|
+
capabilities: {
|
|
16
|
+
tools: {},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
// Tool definitions
|
|
20
|
+
const tools = [
|
|
21
|
+
executeStreamTool.definition,
|
|
22
|
+
generateMarbleTool.definition,
|
|
23
|
+
analyzeOperatorsTool.definition,
|
|
24
|
+
detectMemoryLeakTool.definition,
|
|
25
|
+
suggestPatternTool.definition,
|
|
26
|
+
];
|
|
27
|
+
// Tool handlers mapping
|
|
28
|
+
const toolHandlers = {
|
|
29
|
+
'execute_stream': executeStreamTool.handler,
|
|
30
|
+
'generate_marble': generateMarbleTool.handler,
|
|
31
|
+
'analyze_operators': analyzeOperatorsTool.handler,
|
|
32
|
+
'detect_memory_leak': detectMemoryLeakTool.handler,
|
|
33
|
+
'suggest_pattern': suggestPatternTool.handler,
|
|
34
|
+
};
|
|
35
|
+
// Handle list tools request
|
|
36
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
37
|
+
return {
|
|
38
|
+
tools: tools.map(tool => ({
|
|
39
|
+
name: tool.name,
|
|
40
|
+
description: tool.description,
|
|
41
|
+
inputSchema: tool.inputSchema,
|
|
42
|
+
outputSchema: tool.outputSchema,
|
|
43
|
+
annotations: tool.annotations,
|
|
44
|
+
})),
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
// Handle tool execution request
|
|
48
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
49
|
+
const { name, arguments: args } = request.params;
|
|
50
|
+
const handler = toolHandlers[name];
|
|
51
|
+
if (!handler) {
|
|
52
|
+
throw new McpError(ErrorCode.MethodNotFound, `Tool "${name}" not found. Available tools: ${Object.keys(toolHandlers).join(', ')}`);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const result = await handler(args);
|
|
56
|
+
return {
|
|
57
|
+
content: result.content,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (error instanceof McpError) {
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
65
|
+
throw new McpError(ErrorCode.InternalError, `Tool "${name}" failed: ${errorMessage}`);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
// Start the server
|
|
69
|
+
async function main() {
|
|
70
|
+
const transport = new StdioServerTransport();
|
|
71
|
+
try {
|
|
72
|
+
await server.connect(transport);
|
|
73
|
+
console.error('RxJS MCP Server started successfully');
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error('Failed to start RxJS MCP Server:', error);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Handle graceful shutdown
|
|
81
|
+
process.on('SIGINT', async () => {
|
|
82
|
+
console.error('Shutting down RxJS MCP Server...');
|
|
83
|
+
process.exit(0);
|
|
84
|
+
});
|
|
85
|
+
process.on('SIGTERM', async () => {
|
|
86
|
+
console.error('Shutting down RxJS MCP Server...');
|
|
87
|
+
process.exit(0);
|
|
88
|
+
});
|
|
89
|
+
// Run the server
|
|
90
|
+
main().catch((error) => {
|
|
91
|
+
console.error('Fatal error:', error);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACxH,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,uBAAuB;AACvB,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;IACE,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,OAAO;CACjB,EACD;IACE,YAAY,EAAE;QAC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