@sparrowai/sparrow-mcp 1.0.3
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 +189 -0
- package/README.md +361 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/config/appConfig.d.ts +2 -0
- package/dist/config/appConfig.js +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +2 -0
- package/dist/services/analysis.service.d.ts +46 -0
- package/dist/services/analysis.service.js +1 -0
- package/dist/services/llm.service.d.ts +9 -0
- package/dist/services/llm.service.js +1 -0
- package/dist/services/s3.service.d.ts +75 -0
- package/dist/services/s3.service.js +1 -0
- package/dist/services/sparrow.service.d.ts +32 -0
- package/dist/services/sparrow.service.js +1 -0
- package/dist/types/types.d.ts +88 -0
- package/dist/types/types.js +1 -0
- package/dist/utils/crypto.util.d.ts +36 -0
- package/dist/utils/crypto.util.js +1 -0
- package/dist/utils/diff.util.d.ts +5 -0
- package/dist/utils/diff.util.js +1 -0
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/logger.js +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
PROPRIETARY SOFTWARE LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 All Rights Reserved
|
|
4
|
+
|
|
5
|
+
NOTICE: This software and associated documentation files (the "Software") are
|
|
6
|
+
the proprietary and confidential property of the copyright holder. Unauthorized
|
|
7
|
+
copying, modification, distribution, or use of this Software, via any medium,
|
|
8
|
+
is strictly prohibited and may result in severe civil and criminal penalties.
|
|
9
|
+
|
|
10
|
+
TERMS AND CONDITIONS:
|
|
11
|
+
|
|
12
|
+
1. OWNERSHIP
|
|
13
|
+
The Software is protected by copyright laws and international copyright
|
|
14
|
+
treaties, as well as other intellectual property laws and treaties. All
|
|
15
|
+
rights, title, and interest in and to the Software remain with the copyright
|
|
16
|
+
holder.
|
|
17
|
+
|
|
18
|
+
2. RESTRICTIONS ON USE
|
|
19
|
+
You are granted a limited, non-exclusive, non-transferable license to use
|
|
20
|
+
the Software solely for the purposes authorized by the copyright holder.
|
|
21
|
+
You may NOT:
|
|
22
|
+
|
|
23
|
+
a) Copy, reproduce, or duplicate the Software in any form;
|
|
24
|
+
b) Modify, adapt, alter, translate, or create derivative works based upon
|
|
25
|
+
the Software;
|
|
26
|
+
c) Reverse engineer, decompile, disassemble, or otherwise attempt to derive
|
|
27
|
+
the source code of the Software;
|
|
28
|
+
d) Remove, alter, or obscure any proprietary notices, labels, or marks on
|
|
29
|
+
the Software;
|
|
30
|
+
e) Distribute, sublicense, lease, rent, loan, or otherwise transfer the
|
|
31
|
+
Software to any third party;
|
|
32
|
+
f) Use the Software for any purpose other than that for which it was
|
|
33
|
+
expressly provided;
|
|
34
|
+
g) Share, publish, or make available the Software or any portion thereof
|
|
35
|
+
through any means, including but not limited to file sharing, cloud
|
|
36
|
+
storage, or public repositories.
|
|
37
|
+
|
|
38
|
+
3. NO REDISTRIBUTION
|
|
39
|
+
Redistribution of this Software, in whole or in part, in any form or by any
|
|
40
|
+
means, is STRICTLY PROHIBITED. This includes, but is not limited to:
|
|
41
|
+
- Distribution via software repositories
|
|
42
|
+
- Distribution via package managers
|
|
43
|
+
- Distribution via file sharing services
|
|
44
|
+
- Distribution via cloud storage services
|
|
45
|
+
- Distribution via any public or private network
|
|
46
|
+
- Distribution as part of another software product
|
|
47
|
+
- Distribution in modified or unmodified form
|
|
48
|
+
|
|
49
|
+
4. NO MODIFICATION
|
|
50
|
+
Modification, alteration, or tampering with this Software, in whole or in
|
|
51
|
+
part, is STRICTLY PROHIBITED. This includes, but is not limited to:
|
|
52
|
+
- Changing any code, configuration, or documentation
|
|
53
|
+
- Removing or altering copyright notices
|
|
54
|
+
- Adding or removing features
|
|
55
|
+
- Creating derivative works
|
|
56
|
+
- Obfuscating or attempting to hide modifications
|
|
57
|
+
|
|
58
|
+
5. CONFIDENTIALITY
|
|
59
|
+
The Software contains proprietary and confidential information. You agree to
|
|
60
|
+
maintain the confidentiality of the Software and not to disclose it to any
|
|
61
|
+
third party without the express written consent of the copyright holder.
|
|
62
|
+
|
|
63
|
+
6. TERMINATION
|
|
64
|
+
This license is effective until terminated. Your rights under this license
|
|
65
|
+
will terminate automatically without notice if you fail to comply with any
|
|
66
|
+
of its terms. Upon termination, you must immediately destroy all copies of
|
|
67
|
+
the Software in your possession.
|
|
68
|
+
|
|
69
|
+
7. NO WARRANTY
|
|
70
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
71
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
72
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
73
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
74
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
75
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
76
|
+
IN THE SOFTWARE.
|
|
77
|
+
|
|
78
|
+
8. ENFORCEMENT
|
|
79
|
+
Any violation of these terms may result in legal action. The copyright
|
|
80
|
+
holder reserves the right to pursue all available legal remedies, including
|
|
81
|
+
but not limited to injunctive relief and monetary damages.
|
|
82
|
+
|
|
83
|
+
9. GOVERNING LAW
|
|
84
|
+
This license shall be governed by and construed in accordance with the laws
|
|
85
|
+
of the jurisdiction in which the copyright holder is located, without regard
|
|
86
|
+
to its conflict of law provisions.
|
|
87
|
+
|
|
88
|
+
10. SEVERABILITY
|
|
89
|
+
If any provision of this license is found to be unenforceable or invalid,
|
|
90
|
+
that provision shall be limited or eliminated to the minimum extent
|
|
91
|
+
necessary so that this license shall otherwise remain in full force and
|
|
92
|
+
effect.
|
|
93
|
+
|
|
94
|
+
BY USING THIS SOFTWARE, YOU ACKNOWLEDGE THAT YOU HAVE READ THIS LICENSE,
|
|
95
|
+
UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS TERMS AND CONDITIONS. IF YOU DO
|
|
96
|
+
NOT AGREE TO THESE TERMS, DO NOT USE THE SOFTWARE AND DESTROY ALL COPIES IN
|
|
97
|
+
YOUR POSSESSION.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
사유 소프트웨어 라이선스
|
|
102
|
+
|
|
103
|
+
저작권 (c) 2025 모든 권리 보유
|
|
104
|
+
|
|
105
|
+
주의: 본 소프트웨어 및 관련 문서 파일(이하 "소프트웨어")은 저작권 보유자의
|
|
106
|
+
독점적이고 기밀인 재산입니다. 본 소프트웨어의 무단 복사, 수정, 배포 또는
|
|
107
|
+
사용은 어떤 매체를 통해서든 엄격히 금지되며, 심각한 민사 및 형사 처벌을
|
|
108
|
+
받을 수 있습니다.
|
|
109
|
+
|
|
110
|
+
이용 약관:
|
|
111
|
+
|
|
112
|
+
1. 소유권
|
|
113
|
+
본 소프트웨어는 저작권법 및 국제 저작권 조약뿐만 아니라 기타 지적 재산권
|
|
114
|
+
법률 및 조약에 의해 보호됩니다. 소프트웨어에 대한 모든 권리, 소유권 및
|
|
115
|
+
이익은 저작권 보유자에게 있습니다.
|
|
116
|
+
|
|
117
|
+
2. 사용 제한
|
|
118
|
+
귀하는 저작권 보유자가 승인한 목적으로만 소프트웨어를 사용할 수 있는
|
|
119
|
+
제한적이고 비독점적이며 양도 불가능한 라이선스를 부여받습니다.
|
|
120
|
+
귀하는 다음을 수행할 수 없습니다:
|
|
121
|
+
|
|
122
|
+
a) 소프트웨어를 어떤 형태로든 복사, 재생산 또는 복제;
|
|
123
|
+
b) 소프트웨어를 기반으로 수정, 적응, 변경, 번역 또는 파생 작품 생성;
|
|
124
|
+
c) 소프트웨어의 소스 코드를 역공학, 역컴파일, 디어셈블 또는 기타 방법으로
|
|
125
|
+
도출하려는 시도;
|
|
126
|
+
d) 소프트웨어의 모든 독점 고지, 라벨 또는 표시를 제거, 변경 또는 모호하게
|
|
127
|
+
만드는 행위;
|
|
128
|
+
e) 소프트웨어를 제3자에게 배포, 재라이선스, 임대, 대여, 대출 또는 기타
|
|
129
|
+
방법으로 양도;
|
|
130
|
+
f) 소프트웨어가 명시적으로 제공된 목적 이외의 목적으로 사용;
|
|
131
|
+
g) 파일 공유, 클라우드 스토리지 또는 공개 저장소를 포함하되 이에 국한되지
|
|
132
|
+
않는 모든 수단을 통해 소프트웨어 또는 그 일부를 공유, 게시 또는 제공
|
|
133
|
+
|
|
134
|
+
3. 재배포 금지
|
|
135
|
+
본 소프트웨어의 전부 또는 일부를 어떤 형태로든 어떤 수단을 통해서든
|
|
136
|
+
재배포하는 것은 엄격히 금지됩니다. 여기에는 다음이 포함되지만 이에
|
|
137
|
+
국한되지 않습니다:
|
|
138
|
+
- 소프트웨어 저장소를 통한 배포
|
|
139
|
+
- 패키지 관리자를 통한 배포
|
|
140
|
+
- 파일 공유 서비스를 통한 배포
|
|
141
|
+
- 클라우드 스토리지 서비스를 통한 배포
|
|
142
|
+
- 공개 또는 사설 네트워크를 통한 배포
|
|
143
|
+
- 다른 소프트웨어 제품의 일부로 배포
|
|
144
|
+
- 수정되거나 수정되지 않은 형태로 배포
|
|
145
|
+
|
|
146
|
+
4. 변조 금지
|
|
147
|
+
본 소프트웨어의 전부 또는 일부를 수정, 변경 또는 변조하는 것은 엄격히
|
|
148
|
+
금지됩니다. 여기에는 다음이 포함되지만 이에 국한되지 않습니다:
|
|
149
|
+
- 모든 코드, 구성 또는 문서 변경
|
|
150
|
+
- 저작권 고지 제거 또는 변경
|
|
151
|
+
- 기능 추가 또는 제거
|
|
152
|
+
- 파생 작품 생성
|
|
153
|
+
- 수정 사항을 난독화하거나 숨기려는 시도
|
|
154
|
+
|
|
155
|
+
5. 기밀 유지
|
|
156
|
+
소프트웨어에는 독점적이고 기밀인 정보가 포함되어 있습니다. 귀하는
|
|
157
|
+
소프트웨어의 기밀을 유지하고 저작권 보유자의 명시적 서면 동의 없이
|
|
158
|
+
제3자에게 공개하지 않기로 동의합니다.
|
|
159
|
+
|
|
160
|
+
6. 종료
|
|
161
|
+
본 라이선스는 종료될 때까지 유효합니다. 귀하가 본 약관의 조항을 준수하지
|
|
162
|
+
않으면 통지 없이 자동으로 종료됩니다. 종료 시 귀하는 즉시 보유하고 있는
|
|
163
|
+
소프트웨어의 모든 사본을 파기해야 합니다.
|
|
164
|
+
|
|
165
|
+
7. 보증 없음
|
|
166
|
+
소프트웨어는 "있는 그대로" 제공되며, 상품성, 특정 목적에의 적합성 및
|
|
167
|
+
비침해에 대한 보증을 포함하되 이에 국한되지 않는 모든 명시적 또는 묵시적
|
|
168
|
+
보증 없이 제공됩니다. 저자 또는 저작권 보유자는 계약, 불법 행위 또는
|
|
169
|
+
기타 행위에 따른 소프트웨어 또는 사용 또는 기타 거래와 관련하여 발생하는
|
|
170
|
+
모든 청구, 손해 또는 기타 책임에 대해 책임을 지지 않습니다.
|
|
171
|
+
|
|
172
|
+
8. 집행
|
|
173
|
+
본 약관의 위반은 법적 조치를 초래할 수 있습니다. 저작권 보유자는 금지
|
|
174
|
+
명령 및 금전적 손해를 포함하되 이에 국한되지 않는 모든 이용 가능한 법적
|
|
175
|
+
구제책을 추구할 권리를 보유합니다.
|
|
176
|
+
|
|
177
|
+
9. 준거법
|
|
178
|
+
본 라이선스는 저작권 보유자가 위치한 관할권의 법률에 따라 해석되고
|
|
179
|
+
적용되며, 법률 충돌 조항을 고려하지 않습니다.
|
|
180
|
+
|
|
181
|
+
10. 분리 가능성
|
|
182
|
+
본 라이선스의 조항이 시행 불가능하거나 무효한 것으로 판단되는 경우,
|
|
183
|
+
해당 조항은 본 라이선스가 그 외에는 완전한 효력을 유지하도록 최소한의
|
|
184
|
+
범위로 제한되거나 제거됩니다.
|
|
185
|
+
|
|
186
|
+
본 소프트웨어를 사용함으로써 귀하는 본 라이선스를 읽고 이해하며 그 약관과
|
|
187
|
+
조건에 구속되는 것에 동의합니다. 본 약관에 동의하지 않는 경우 소프트웨어를
|
|
188
|
+
사용하지 말고 보유하고 있는 모든 사본을 파기하십시오.
|
|
189
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
# Sparrow MCP - Security Code Analysis Server
|
|
2
|
+
|
|
3
|
+
A Model Context Protocol (MCP) server that automatically analyzes security vulnerabilities in your code and generates secure code alternatives. This server integrates with Cursor IDE to provide real-time security analysis and secure code generation capabilities.
|
|
4
|
+
|
|
5
|
+
## ✨ Features
|
|
6
|
+
|
|
7
|
+
- **File Security Analysis**: Automatically analyze security vulnerabilities in Java code
|
|
8
|
+
- **AI-Powered Briefing**: Get easy-to-understand explanations of analysis results
|
|
9
|
+
- **Secure Code Generation**: Automatically generate secure code that fixes discovered vulnerabilities
|
|
10
|
+
- **Diff Generation**: Visualize differences between original and secure code
|
|
11
|
+
- **Real-time Status Monitoring**: Track analysis progress in real-time
|
|
12
|
+
- **Multi-file Analysis**: Analyze multiple files, folders, or ZIP archives at once
|
|
13
|
+
- **Progress Tracking**: Monitor analysis progress with detailed notifications
|
|
14
|
+
|
|
15
|
+
## 🛠️ Technology Stack
|
|
16
|
+
|
|
17
|
+
- **TypeScript**: Main development language
|
|
18
|
+
- **MCP SDK**: Model Context Protocol implementation
|
|
19
|
+
- **Ollama**: LLM integration (gemma2:27b model)
|
|
20
|
+
- **Sparrow OnDemand API**: SAST security analysis
|
|
21
|
+
- **Winston**: Logging
|
|
22
|
+
|
|
23
|
+
## 📦 Installation
|
|
24
|
+
|
|
25
|
+
### Prerequisites
|
|
26
|
+
|
|
27
|
+
- Node.js 18+ and npm
|
|
28
|
+
- Sparrow OnDemand API key
|
|
29
|
+
- (Optional) Ollama for LLM features
|
|
30
|
+
|
|
31
|
+
### Install from npm
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install -g @sparrowai/sparrow-mcp
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or install locally in your project:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install @sparrowai/sparrow-mcp
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Verify Installation
|
|
44
|
+
|
|
45
|
+
After installation, verify that the package is installed correctly by checking if the server file exists:
|
|
46
|
+
|
|
47
|
+
**For local installation:**
|
|
48
|
+
```bash
|
|
49
|
+
# Check if the package is installed
|
|
50
|
+
ls node_modules/@sparrowai/sparrow-mcp/dist/server.js
|
|
51
|
+
|
|
52
|
+
# Or verify the package version
|
|
53
|
+
npm list @sparrowai/sparrow-mcp
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**For global installation:**
|
|
57
|
+
```bash
|
|
58
|
+
# Check if the package is installed globally
|
|
59
|
+
npm list -g @sparrowai/sparrow-mcp
|
|
60
|
+
|
|
61
|
+
# Find the exact global installation path
|
|
62
|
+
npm root -g
|
|
63
|
+
|
|
64
|
+
# Verify the server file exists (path may vary by system)
|
|
65
|
+
# Windows: %APPDATA%\npm\node_modules\@sparrowai\sparrow-mcp\dist\server.js
|
|
66
|
+
# (typically: C:\Users\<username>\AppData\Roaming\npm\node_modules\@sparrowai\sparrow-mcp\dist\server.js)
|
|
67
|
+
# macOS/Linux: /usr/local/lib/node_modules/@sparrowai/sparrow-mcp/dist/server.js
|
|
68
|
+
# (or ~/.npm-global/lib/node_modules/@sparrowai/sparrow-mcp/dist/server.js if using custom prefix)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Note**: This package is an MCP server, not a CLI tool. It doesn't provide a direct command-line executable. The server is meant to be run by Cursor IDE through the MCP configuration (see Cursor IDE Configuration section below).
|
|
72
|
+
|
|
73
|
+
## ⚙️ Configuration
|
|
74
|
+
|
|
75
|
+
### Sparrow OnDemand API Setup
|
|
76
|
+
|
|
77
|
+
1. Sign up for Sparrow OnDemand service
|
|
78
|
+
2. Obtain your API key from the dashboard
|
|
79
|
+
3. Set the `SPARROW_API_KEY` environment variable in your MCP configuration (see below)
|
|
80
|
+
|
|
81
|
+
## 🔧 Cursor IDE Configuration
|
|
82
|
+
|
|
83
|
+
Configure the MCP server in Cursor IDE. The server requires environment variables to be set in the MCP configuration:
|
|
84
|
+
|
|
85
|
+
**Location**: `~/.cursor/mcp.json` (macOS/Linux) or `%APPDATA%\Cursor\mcp.json` (Windows)
|
|
86
|
+
|
|
87
|
+
### For Local Installation
|
|
88
|
+
|
|
89
|
+
If you installed the package locally in your project:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"mcpServers": {
|
|
94
|
+
"sparrow-mcp": {
|
|
95
|
+
"command": "node",
|
|
96
|
+
"args": ["./node_modules/@sparrowai/sparrow-mcp/dist/server.js"],
|
|
97
|
+
"env": {
|
|
98
|
+
"SPARROW_API_KEY": "your-ondemand-token",
|
|
99
|
+
"SPARROW_API_URL": "https://ondemand.sparrowcloud.ai",
|
|
100
|
+
"OLLAMA_BASE_URL": "http://localhost:11434",
|
|
101
|
+
"OLLAMA_MODEL": "gpt-oss:20b",
|
|
102
|
+
"NODE_ENV": "development"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### For Global Installation
|
|
110
|
+
|
|
111
|
+
If you installed the package globally with `npm install -g`, use the absolute path. First, find your global installation path:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npm root -g
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Then use the full path in your configuration:
|
|
118
|
+
|
|
119
|
+
**Windows example:**
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"mcpServers": {
|
|
123
|
+
"sparrow-mcp": {
|
|
124
|
+
"command": "node",
|
|
125
|
+
"args": ["C:\\Users\\<username>\\AppData\\Roaming\\npm\\node_modules\\@sparrowai\\sparrow-mcp\\dist\\server.js"],
|
|
126
|
+
"env": {
|
|
127
|
+
"SPARROW_API_KEY": "your-ondemand-token",
|
|
128
|
+
"SPARROW_API_URL": "https://ondemand.sparrowcloud.ai",
|
|
129
|
+
"OLLAMA_BASE_URL": "http://localhost:11434",
|
|
130
|
+
"OLLAMA_MODEL": "gpt-oss:20b",
|
|
131
|
+
"NODE_ENV": "development"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**macOS/Linux example:**
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"mcpServers": {
|
|
142
|
+
"sparrow-mcp": {
|
|
143
|
+
"command": "node",
|
|
144
|
+
"args": ["/usr/local/lib/node_modules/@sparrowai/sparrow-mcp/dist/server.js"],
|
|
145
|
+
"env": {
|
|
146
|
+
"SPARROW_API_KEY": "your-ondemand-token",
|
|
147
|
+
"SPARROW_API_URL": "https://ondemand.sparrowcloud.ai",
|
|
148
|
+
"OLLAMA_BASE_URL": "http://localhost:11434",
|
|
149
|
+
"OLLAMA_MODEL": "gpt-oss:20b",
|
|
150
|
+
"NODE_ENV": "development"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Note**:
|
|
158
|
+
- If you're using a local development build, replace `./node_modules/@sparrowai/sparrow-mcp/dist/server.js` with `dist/server.js` and add `"cwd"` pointing to your project root.
|
|
159
|
+
- Replace `"OLLAMA_BASE_URL"` with your actual Ollama server URL (e.g., `http://192.168.30.169:11434` for remote servers).
|
|
160
|
+
- Replace `"your-ondemand-token"` with your actual Sparrow OnDemand API key.
|
|
161
|
+
- For global installation, replace `<username>` in the Windows path with your actual username, or use `npm root -g` to get the exact path.
|
|
162
|
+
|
|
163
|
+
### Restart Cursor
|
|
164
|
+
|
|
165
|
+
After updating the MCP configuration:
|
|
166
|
+
|
|
167
|
+
1. Save the `mcp.json` file
|
|
168
|
+
2. Restart Cursor IDE completely
|
|
169
|
+
3. The MCP server should connect automatically
|
|
170
|
+
|
|
171
|
+
### Verify Connection
|
|
172
|
+
|
|
173
|
+
To verify that the MCP server is connected:
|
|
174
|
+
|
|
175
|
+
1. Open Cursor IDE
|
|
176
|
+
2. Check the MCP server status in the status bar or settings
|
|
177
|
+
3. Try using one of the MCP tools (see Usage section below)
|
|
178
|
+
|
|
179
|
+
## 🚀 Usage
|
|
180
|
+
|
|
181
|
+
### Available MCP Tools
|
|
182
|
+
|
|
183
|
+
The server provides the following MCP tools:
|
|
184
|
+
|
|
185
|
+
#### 1. `analyze_file_security`
|
|
186
|
+
|
|
187
|
+
Analyze a single file for security vulnerabilities.
|
|
188
|
+
|
|
189
|
+
**Parameters:**
|
|
190
|
+
- `fileContent` (string): The content of the file to analyze
|
|
191
|
+
- `fileName` (string): The name of the file
|
|
192
|
+
|
|
193
|
+
**Returns:**
|
|
194
|
+
- `analysisId`: Unique identifier for the analysis
|
|
195
|
+
- `status`: Current analysis status
|
|
196
|
+
|
|
197
|
+
**Example Usage in Cursor:**
|
|
198
|
+
```
|
|
199
|
+
Analyze this file for security vulnerabilities:
|
|
200
|
+
[file content]
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### 2. `get_analysis_status`
|
|
204
|
+
|
|
205
|
+
Check the progress of an ongoing analysis.
|
|
206
|
+
|
|
207
|
+
**Parameters:**
|
|
208
|
+
- `analysisId` (string): The analysis ID returned from `analyze_file_security`
|
|
209
|
+
|
|
210
|
+
**Returns:**
|
|
211
|
+
- `status`: Current status (pending, processing, completed, failed)
|
|
212
|
+
- `progress`: Progress percentage (0-100)
|
|
213
|
+
- `message`: Status message
|
|
214
|
+
|
|
215
|
+
#### 3. `get_analysis_results`
|
|
216
|
+
|
|
217
|
+
Get detailed results from a completed analysis.
|
|
218
|
+
|
|
219
|
+
**Parameters:**
|
|
220
|
+
- `analysisId` (string): The analysis ID
|
|
221
|
+
- `fileContent` (string): The original file content
|
|
222
|
+
|
|
223
|
+
**Returns:**
|
|
224
|
+
- `vulnerabilities`: List of discovered vulnerabilities
|
|
225
|
+
- `analysisBrief`: AI-generated analysis briefing
|
|
226
|
+
- `secureCode`: Generated secure code
|
|
227
|
+
- `secureCodeBrief`: Explanation of the secure code
|
|
228
|
+
- `diff`: Unified diff showing changes
|
|
229
|
+
|
|
230
|
+
#### 4. `analyze_files_security`
|
|
231
|
+
|
|
232
|
+
Analyze multiple files at once. Files are automatically zipped and analyzed.
|
|
233
|
+
|
|
234
|
+
**Parameters:**
|
|
235
|
+
- `filePaths` (array of strings): List of file paths to analyze (absolute or relative to working directory)
|
|
236
|
+
- `zipFileName` (optional string): Name for the generated ZIP file
|
|
237
|
+
|
|
238
|
+
**Returns:**
|
|
239
|
+
- `analysisId`: Unique identifier for the analysis
|
|
240
|
+
- `status`: Current analysis status
|
|
241
|
+
- `filePathCount`: Number of files being analyzed
|
|
242
|
+
|
|
243
|
+
#### 5. `analyze_zip_security`
|
|
244
|
+
|
|
245
|
+
Analyze a ZIP file for security vulnerabilities.
|
|
246
|
+
|
|
247
|
+
**Parameters:**
|
|
248
|
+
- `zipFilePath` (string): Path to the ZIP file to analyze
|
|
249
|
+
- `zipFileName` (optional string): Name for the ZIP file
|
|
250
|
+
|
|
251
|
+
**Returns:**
|
|
252
|
+
- `analysisId`: Unique identifier for the analysis
|
|
253
|
+
- `status`: Current analysis status
|
|
254
|
+
|
|
255
|
+
#### 6. `analyze_folder_security`
|
|
256
|
+
|
|
257
|
+
Analyze an entire folder for security vulnerabilities. The folder is automatically zipped before analysis.
|
|
258
|
+
|
|
259
|
+
**Parameters:**
|
|
260
|
+
- `folderPath` (string): Path to the folder to analyze
|
|
261
|
+
- `zipFileName` (optional string): Name for the generated ZIP file
|
|
262
|
+
|
|
263
|
+
**Returns:**
|
|
264
|
+
- `analysisId`: Unique identifier for the analysis
|
|
265
|
+
- `status`: Current analysis status
|
|
266
|
+
|
|
267
|
+
#### 7. `track_analysis_progress`
|
|
268
|
+
|
|
269
|
+
Track the progress of an analysis with real-time notifications.
|
|
270
|
+
|
|
271
|
+
**Parameters:**
|
|
272
|
+
- `analysisId` (string): The analysis ID
|
|
273
|
+
- `intervalMs` (optional number): Status check interval in milliseconds (default: 3000)
|
|
274
|
+
|
|
275
|
+
**Returns:**
|
|
276
|
+
- Progress notifications sent via MCP progress notifications
|
|
277
|
+
- Final status when analysis completes
|
|
278
|
+
|
|
279
|
+
**Analysis Stages:**
|
|
280
|
+
- `INIT`: Initialization
|
|
281
|
+
- `READY`: Ready to start
|
|
282
|
+
- `PRE_PROCESS`: Pre-processing
|
|
283
|
+
- `ANALYSIS`: Analysis in progress (progress percentage available)
|
|
284
|
+
- `POST_PROCESS`: Post-processing
|
|
285
|
+
- `COMPLETE`: Analysis complete
|
|
286
|
+
|
|
287
|
+
### Typical Workflow
|
|
288
|
+
|
|
289
|
+
1. **Write Code**: Write your Java code in Cursor
|
|
290
|
+
2. **Request Analysis**: Use the `analyze_file_security` tool to request analysis
|
|
291
|
+
3. **Track Progress**: Use `track_analysis_progress` to monitor the analysis
|
|
292
|
+
4. **Get Results**: Use `get_analysis_results` to retrieve detailed results
|
|
293
|
+
5. **Review**: Review the vulnerabilities, secure code, and diff
|
|
294
|
+
6. **Apply Changes**: Apply the suggested secure code changes
|
|
295
|
+
|
|
296
|
+
## 🐛 Troubleshooting
|
|
297
|
+
|
|
298
|
+
### Common Issues
|
|
299
|
+
|
|
300
|
+
#### 1. MCP Server Not Connecting
|
|
301
|
+
|
|
302
|
+
**Symptoms**: The MCP server doesn't appear in Cursor or shows as disconnected.
|
|
303
|
+
|
|
304
|
+
**Solutions**:
|
|
305
|
+
- Verify the `mcp.json` file is in the correct location
|
|
306
|
+
- Check that all environment variables are set correctly
|
|
307
|
+
- Ensure Node.js is installed and accessible in PATH
|
|
308
|
+
- Restart Cursor IDE completely
|
|
309
|
+
- Check Cursor's MCP server logs for error messages
|
|
310
|
+
|
|
311
|
+
#### 2. Ollama Connection Failed
|
|
312
|
+
|
|
313
|
+
**Symptoms**: LLM features are not working, errors about Ollama connection.
|
|
314
|
+
|
|
315
|
+
**Solutions**:
|
|
316
|
+
- Verify Ollama is installed and running: `ollama serve`
|
|
317
|
+
- Check that `OLLAMA_BASE_URL` is correct (default: `http://localhost:11434`)
|
|
318
|
+
- Verify the model is downloaded: `ollama list`
|
|
319
|
+
- Check firewall settings if using a remote Ollama instance
|
|
320
|
+
|
|
321
|
+
#### 3. Sparrow API Errors
|
|
322
|
+
|
|
323
|
+
**Symptoms**: Analysis requests fail with API errors.
|
|
324
|
+
|
|
325
|
+
**Solutions**:
|
|
326
|
+
- Verify `SPARROW_API_KEY` is correct and not expired
|
|
327
|
+
- Check `SPARROW_API_URL` is correct
|
|
328
|
+
- Verify your API key has sufficient permissions
|
|
329
|
+
- Check network connectivity to Sparrow API
|
|
330
|
+
|
|
331
|
+
#### 4. Analysis Timeout
|
|
332
|
+
|
|
333
|
+
**Symptoms**: Analysis takes too long or times out.
|
|
334
|
+
|
|
335
|
+
**Solutions**:
|
|
336
|
+
- Large files may take longer to analyze
|
|
337
|
+
- Check network connectivity
|
|
338
|
+
- Verify Sparrow API service status
|
|
339
|
+
- Consider analyzing smaller files or folders separately
|
|
340
|
+
|
|
341
|
+
### Logging
|
|
342
|
+
|
|
343
|
+
The server logs to both console and log files:
|
|
344
|
+
|
|
345
|
+
- **Console**: Real-time logs during development
|
|
346
|
+
- **Log Files**:
|
|
347
|
+
- `logs/combined.log`: All logs
|
|
348
|
+
- `logs/error.log`: Error logs only
|
|
349
|
+
|
|
350
|
+
To enable more detailed logging, add `"LOG_LEVEL": "debug"` to the `"env"` section in your MCP configuration.
|
|
351
|
+
|
|
352
|
+
## 📝 License
|
|
353
|
+
|
|
354
|
+
ISC
|
|
355
|
+
|
|
356
|
+
## 🔗 Related Links
|
|
357
|
+
|
|
358
|
+
- [Model Context Protocol Documentation](https://modelcontextprotocol.io/)
|
|
359
|
+
- [Cursor IDE Documentation](https://cursor.sh/docs)
|
|
360
|
+
- [Sparrow OnDemand API Documentation](https://ondemand.sparrowcloud.ai/docs)
|
|
361
|
+
- [Ollama Documentation](https://ollama.com/docs)
|