@mseep/ai-tech-app-agent 1.0.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/.env +24 -0
- package/.env.example +24 -0
- package/Jenkinsfile +210 -0
- package/MCP-SERVER-GUIDE.md +405 -0
- package/README.MD +450 -0
- package/dist/config/app.config.d.ts +65 -0
- package/dist/config/app.config.d.ts.map +1 -0
- package/dist/config/app.config.js +94 -0
- package/dist/config/app.config.js.map +1 -0
- package/dist/config/llm.config.d.ts +63 -0
- package/dist/config/llm.config.d.ts.map +1 -0
- package/dist/config/llm.config.js +158 -0
- package/dist/config/llm.config.js.map +1 -0
- package/dist/config/mcp.config.d.ts +175 -0
- package/dist/config/mcp.config.d.ts.map +1 -0
- package/dist/config/mcp.config.js +215 -0
- package/dist/config/mcp.config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +175 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/llamaClient.d.ts +14 -0
- package/dist/llm/llamaClient.d.ts.map +1 -0
- package/dist/llm/llamaClient.js +136 -0
- package/dist/llm/llamaClient.js.map +1 -0
- package/dist/mcp/mcpClient.d.ts +132 -0
- package/dist/mcp/mcpClient.d.ts.map +1 -0
- package/dist/mcp/mcpClient.js +784 -0
- package/dist/mcp/mcpClient.js.map +1 -0
- package/dist/models/testSpec.d.ts +78 -0
- package/dist/models/testSpec.d.ts.map +1 -0
- package/dist/models/testSpec.js +3 -0
- package/dist/models/testSpec.js.map +1 -0
- package/dist/orchestrator/aiTestRunner.d.ts +18 -0
- package/dist/orchestrator/aiTestRunner.d.ts.map +1 -0
- package/dist/orchestrator/aiTestRunner.js +247 -0
- package/dist/orchestrator/aiTestRunner.js.map +1 -0
- package/dist/utils/logger.d.ts +4 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +49 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/promptBuilder.d.ts +62 -0
- package/dist/utils/promptBuilder.d.ts.map +1 -0
- package/dist/utils/promptBuilder.js +333 -0
- package/dist/utils/promptBuilder.js.map +1 -0
- package/knowledge/app-knowledge.txt +100 -0
- package/logs/combined.log +486 -0
- package/logs/error.log +50 -0
- package/package.json +62 -0
- package/reports/screenshots/screenshot_1764535110518.png +0 -0
- package/reports/test-report.json +106 -0
- package/scripts/check-mcp-server.sh +100 -0
- package/scripts/extract-pom-knowledge.js +222 -0
- package/scripts/pre-test-setup.js +262 -0
- package/scripts/start-mcp-server.sh +76 -0
- package/src/config/app.config.ts +175 -0
- package/src/config/llm.config.ts +220 -0
- package/src/config/mcp.config.ts +291 -0
- package/src/index.ts +161 -0
- package/src/llm/llamaClient.ts +159 -0
- package/src/mcp/mcpClient.ts +878 -0
- package/src/models/testSpec.ts +85 -0
- package/src/orchestrator/aiTestRunner.ts +286 -0
- package/src/utils/logger.ts +59 -0
- package/src/utils/promptBuilder.ts +384 -0
- package/tests/nlp-specs/login-flow.yaml +31 -0
- package/tsconfig.json +31 -0
package/.env
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# LambdaTest Configuration
|
|
2
|
+
LAMBDATEST_USERNAME="dineshkumarjdivisionsinc"
|
|
3
|
+
LAMBDATEST_ACCESS_KEY="LT_EKyT3FZ9kwxlLruvGS1TaO7RVDhwAU6Yn89KhG6kP3LColW"
|
|
4
|
+
LAMBDATEST_GRID_URL=https://mobile-hub.lambdatest.com/wd/hub
|
|
5
|
+
|
|
6
|
+
# Ollama/LLM Configuration
|
|
7
|
+
OLLAMA_BASE_URL=http://localhost:11434
|
|
8
|
+
LLM_MODEL=llama3.2:3b
|
|
9
|
+
LLM_TEMPERATURE=0.1
|
|
10
|
+
LLM_MAX_TOKENS=2000
|
|
11
|
+
|
|
12
|
+
# MCP Configuration
|
|
13
|
+
MCP_SERVER_PORT=3000
|
|
14
|
+
APPIUM_SERVER_URL=https://mobile-hub.lambdatest.com/wd/hub
|
|
15
|
+
|
|
16
|
+
# Test Configuration
|
|
17
|
+
DEFAULT_TIMEOUT=30000
|
|
18
|
+
SCREENSHOT_ON_FAILURE=true
|
|
19
|
+
RETRY_FAILED_STEPS=true
|
|
20
|
+
MAX_RETRY_ATTEMPTS=2
|
|
21
|
+
|
|
22
|
+
# Logging
|
|
23
|
+
LOG_LEVEL=info
|
|
24
|
+
LOG_DIR=./logs
|
package/.env.example
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# LambdaTest Configuration
|
|
2
|
+
LAMBDATEST_USERNAME=your_username
|
|
3
|
+
LAMBDATEST_ACCESS_KEY=your_access_key
|
|
4
|
+
LAMBDATEST_GRID_URL=https://mobile-hub.lambdatest.com/wd/hub
|
|
5
|
+
|
|
6
|
+
# Ollama/LLM Configuration
|
|
7
|
+
OLLAMA_BASE_URL=http://localhost:11434
|
|
8
|
+
LLM_MODEL=llama3.2:3b
|
|
9
|
+
LLM_TEMPERATURE=0.1
|
|
10
|
+
LLM_MAX_TOKENS=2000
|
|
11
|
+
|
|
12
|
+
# MCP Configuration
|
|
13
|
+
MCP_SERVER_PORT=3000
|
|
14
|
+
APPIUM_SERVER_URL=http://localhost:4723
|
|
15
|
+
|
|
16
|
+
# Test Configuration
|
|
17
|
+
DEFAULT_TIMEOUT=30000
|
|
18
|
+
SCREENSHOT_ON_FAILURE=true
|
|
19
|
+
RETRY_FAILED_STEPS=true
|
|
20
|
+
MAX_RETRY_ATTEMPTS=2
|
|
21
|
+
|
|
22
|
+
# Logging
|
|
23
|
+
LOG_LEVEL=info
|
|
24
|
+
LOG_DIR=./logs
|
package/Jenkinsfile
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
pipeline {
|
|
2
|
+
agent {
|
|
3
|
+
kubernetes {
|
|
4
|
+
yaml """
|
|
5
|
+
apiVersion: v1
|
|
6
|
+
kind: Pod
|
|
7
|
+
metadata:
|
|
8
|
+
labels:
|
|
9
|
+
jenkins: agent
|
|
10
|
+
spec:
|
|
11
|
+
containers:
|
|
12
|
+
- name: node-appium
|
|
13
|
+
image: node:20-bullseye
|
|
14
|
+
command:
|
|
15
|
+
- cat
|
|
16
|
+
tty: true
|
|
17
|
+
env:
|
|
18
|
+
- name: LAMBDATEST_USERNAME
|
|
19
|
+
valueFrom:
|
|
20
|
+
secretKeyRef:
|
|
21
|
+
name: lambdatest-creds
|
|
22
|
+
key: username
|
|
23
|
+
- name: LAMBDATEST_ACCESS_KEY
|
|
24
|
+
valueFrom:
|
|
25
|
+
secretKeyRef:
|
|
26
|
+
name: lambdatest-creds
|
|
27
|
+
key: accessKey
|
|
28
|
+
- name: OLLAMA_BASE_URL
|
|
29
|
+
value: "http://ollama-service:11434"
|
|
30
|
+
volumeMounts:
|
|
31
|
+
- name: workspace
|
|
32
|
+
mountPath: /workspace
|
|
33
|
+
- name: ollama
|
|
34
|
+
image: ollama/ollama:latest
|
|
35
|
+
command:
|
|
36
|
+
- ollama
|
|
37
|
+
- serve
|
|
38
|
+
ports:
|
|
39
|
+
- containerPort: 11434
|
|
40
|
+
resources:
|
|
41
|
+
requests:
|
|
42
|
+
memory: "4Gi"
|
|
43
|
+
cpu: "2"
|
|
44
|
+
limits:
|
|
45
|
+
memory: "8Gi"
|
|
46
|
+
cpu: "4"
|
|
47
|
+
volumes:
|
|
48
|
+
- name: workspace
|
|
49
|
+
emptyDir: {}
|
|
50
|
+
"""
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
environment {
|
|
55
|
+
REPO_URL = 'https://github.com/your-org/ai-tech-app-agent.git'
|
|
56
|
+
TEST_SPEC_DIR = 'tests/nlp-specs'
|
|
57
|
+
REPORT_DIR = 'reports'
|
|
58
|
+
LOG_DIR = 'logs'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
stages {
|
|
62
|
+
stage('Setup') {
|
|
63
|
+
steps {
|
|
64
|
+
container('node-appium') {
|
|
65
|
+
script {
|
|
66
|
+
echo "Setting up environment..."
|
|
67
|
+
|
|
68
|
+
// Install dependencies
|
|
69
|
+
sh '''
|
|
70
|
+
apt-get update && apt-get install -y \
|
|
71
|
+
openjdk-11-jdk \
|
|
72
|
+
android-sdk \
|
|
73
|
+
curl \
|
|
74
|
+
git
|
|
75
|
+
'''
|
|
76
|
+
|
|
77
|
+
// Clone repository
|
|
78
|
+
sh "git clone ${REPO_URL} /workspace/ai-agent || true"
|
|
79
|
+
|
|
80
|
+
// Install Node dependencies
|
|
81
|
+
dir('/workspace/ai-agent') {
|
|
82
|
+
sh 'npm install'
|
|
83
|
+
sh 'npm run build'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
container('ollama') {
|
|
89
|
+
script {
|
|
90
|
+
echo "Pulling Llama model..."
|
|
91
|
+
|
|
92
|
+
// Pull the Llama model (this may take a few minutes first time)
|
|
93
|
+
sh 'ollama pull llama3.2:3b || echo "Model already exists"'
|
|
94
|
+
|
|
95
|
+
// Verify model is available
|
|
96
|
+
sh 'ollama list'
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
stage('Health Check') {
|
|
103
|
+
steps {
|
|
104
|
+
container('node-appium') {
|
|
105
|
+
dir('/workspace/ai-agent') {
|
|
106
|
+
script {
|
|
107
|
+
echo "Performing health checks..."
|
|
108
|
+
|
|
109
|
+
// Check LLM availability
|
|
110
|
+
sh 'npm run health'
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
stage('Validate Test Specs') {
|
|
118
|
+
steps {
|
|
119
|
+
container('node-appium') {
|
|
120
|
+
dir('/workspace/ai-agent') {
|
|
121
|
+
script {
|
|
122
|
+
echo "Validating test specifications..."
|
|
123
|
+
|
|
124
|
+
sh "npm run validate"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
stage('Run AI Tests') {
|
|
132
|
+
steps {
|
|
133
|
+
container('node-appium') {
|
|
134
|
+
dir('/workspace/ai-agent') {
|
|
135
|
+
script {
|
|
136
|
+
echo "Executing AI-powered tests..."
|
|
137
|
+
|
|
138
|
+
// Run tests with NLP specifications
|
|
139
|
+
sh """
|
|
140
|
+
npm run test || true
|
|
141
|
+
"""
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
stage('Generate Reports') {
|
|
149
|
+
steps {
|
|
150
|
+
container('node-appium') {
|
|
151
|
+
dir('/workspace/ai-agent') {
|
|
152
|
+
script {
|
|
153
|
+
echo "Generating test reports..."
|
|
154
|
+
|
|
155
|
+
// Archive test results
|
|
156
|
+
archiveArtifacts artifacts: "${REPORT_DIR}/**/*", allowEmptyArchive: true
|
|
157
|
+
|
|
158
|
+
// Archive logs
|
|
159
|
+
archiveArtifacts artifacts: "${LOG_DIR}/**/*", allowEmptyArchive: true
|
|
160
|
+
|
|
161
|
+
// Parse and publish results
|
|
162
|
+
if (fileExists("${REPORT_DIR}/test-report.json")) {
|
|
163
|
+
def report = readJSON file: "${REPORT_DIR}/test-report.json"
|
|
164
|
+
|
|
165
|
+
echo "Test Summary:"
|
|
166
|
+
echo " Total: ${report.summary.total}"
|
|
167
|
+
echo " Passed: ${report.summary.passed}"
|
|
168
|
+
echo " Failed: ${report.summary.failed}"
|
|
169
|
+
echo " Skipped: ${report.summary.skipped}"
|
|
170
|
+
|
|
171
|
+
// Set build status
|
|
172
|
+
if (report.summary.failed > 0) {
|
|
173
|
+
currentBuild.result = 'UNSTABLE'
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
post {
|
|
184
|
+
always {
|
|
185
|
+
container('node-appium') {
|
|
186
|
+
dir('/workspace/ai-agent') {
|
|
187
|
+
script {
|
|
188
|
+
echo "Cleaning up..."
|
|
189
|
+
|
|
190
|
+
// Clean up any running processes
|
|
191
|
+
sh 'pkill -f "appium" || true'
|
|
192
|
+
sh 'pkill -f "node" || true'
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
success {
|
|
199
|
+
echo "AI Test Execution completed successfully!"
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
failure {
|
|
203
|
+
echo "AI Test Execution failed. Check logs for details."
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
unstable {
|
|
207
|
+
echo "AI Test Execution completed with failures."
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
# MCP Server Management Guide
|
|
2
|
+
|
|
3
|
+
## Understanding the MCP Server
|
|
4
|
+
|
|
5
|
+
The **MCP (Model Context Protocol) Server** acts as a bridge between the LLM and Appium. In this architecture:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
LLM (Llama 3.2:3b) → MCP Server → Appium → Mobile Device
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Important**: The MCP server **starts automatically** when you run tests, so you typically don't need to start it manually.
|
|
12
|
+
|
|
13
|
+
## Quick Check: Is Everything Running?
|
|
14
|
+
|
|
15
|
+
### Option 1: Automated Check Script
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Make script executable
|
|
19
|
+
chmod +x scripts/check-mcp-server.sh
|
|
20
|
+
|
|
21
|
+
# Run the checker
|
|
22
|
+
./scripts/check-mcp-server.sh
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Option 2: Node.js Pre-Test Setup
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Run comprehensive setup check
|
|
29
|
+
npm run setup
|
|
30
|
+
|
|
31
|
+
# Or manually
|
|
32
|
+
node scripts/pre-test-setup.js
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Option 3: Manual Checks
|
|
36
|
+
|
|
37
|
+
Check each service individually:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# 1. Check Ollama (LLM)
|
|
41
|
+
curl http://localhost:11434/api/tags
|
|
42
|
+
|
|
43
|
+
# 2. Check if llama3.2:3b is available
|
|
44
|
+
ollama list | grep llama3.2
|
|
45
|
+
|
|
46
|
+
# 3. Check Appium (if local)
|
|
47
|
+
curl http://localhost:4723/status
|
|
48
|
+
|
|
49
|
+
# 4. Check MCP Server (optional)
|
|
50
|
+
lsof -i :3000
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Starting Services
|
|
54
|
+
|
|
55
|
+
### 1. Start Ollama (REQUIRED)
|
|
56
|
+
|
|
57
|
+
**Terminal 1 - Keep this running:**
|
|
58
|
+
```bash
|
|
59
|
+
ollama serve
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
You should see:
|
|
63
|
+
```
|
|
64
|
+
Listening on 127.0.0.1:11434 (version 0.x.x)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Verify model is available:**
|
|
68
|
+
```bash
|
|
69
|
+
# In another terminal
|
|
70
|
+
ollama list
|
|
71
|
+
|
|
72
|
+
# Should show:
|
|
73
|
+
# NAME ID SIZE MODIFIED
|
|
74
|
+
# llama3.2:3b abc123 2.0 GB 2 hours ago
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**If model is missing:**
|
|
78
|
+
```bash
|
|
79
|
+
ollama pull llama3.2:3b
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 2. Start Appium (OPTIONAL - Only for Local Testing)
|
|
83
|
+
|
|
84
|
+
**Terminal 2 - Only if testing locally:**
|
|
85
|
+
```bash
|
|
86
|
+
appium
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**If using LambdaTest:** You don't need to start Appium locally - skip this step.
|
|
90
|
+
|
|
91
|
+
### 3. MCP Server (AUTO-STARTS)
|
|
92
|
+
|
|
93
|
+
The MCP server **automatically starts** when you run tests via the `MCPClient.initialize()` method.
|
|
94
|
+
|
|
95
|
+
**To start manually (optional):**
|
|
96
|
+
```bash
|
|
97
|
+
# Make script executable
|
|
98
|
+
chmod +x scripts/start-mcp-server.sh
|
|
99
|
+
|
|
100
|
+
# Start MCP server
|
|
101
|
+
./scripts/start-mcp-server.sh
|
|
102
|
+
|
|
103
|
+
# Or with npm
|
|
104
|
+
npm run start-mcp
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**To run in background:**
|
|
108
|
+
```bash
|
|
109
|
+
npx mcp-appium > logs/mcp-server.log 2>&1 &
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Complete Startup Sequence
|
|
113
|
+
|
|
114
|
+
Here's the recommended order to start everything:
|
|
115
|
+
|
|
116
|
+
### Step-by-Step:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Terminal 1: Start Ollama
|
|
120
|
+
ollama serve
|
|
121
|
+
|
|
122
|
+
# Terminal 2: Verify model (in a new tab/window)
|
|
123
|
+
ollama list
|
|
124
|
+
# If llama3.2:3b missing, run: ollama pull llama3.2:3b
|
|
125
|
+
|
|
126
|
+
# Terminal 3: Check all services
|
|
127
|
+
npm run check-services
|
|
128
|
+
|
|
129
|
+
# Terminal 4: Run comprehensive setup check
|
|
130
|
+
npm run setup
|
|
131
|
+
|
|
132
|
+
# If all checks pass, run tests
|
|
133
|
+
npm run test
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Automated Pre-Test Check
|
|
137
|
+
|
|
138
|
+
The framework automatically runs pre-test checks when you use:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
npm run test # Runs pretest script automatically
|
|
142
|
+
npm run test:single # Runs pretest script automatically
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
To skip pre-test checks:
|
|
146
|
+
```bash
|
|
147
|
+
npm run test:no-check
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Troubleshooting
|
|
151
|
+
|
|
152
|
+
### Issue 1: "LLM is not available"
|
|
153
|
+
|
|
154
|
+
**Check:**
|
|
155
|
+
```bash
|
|
156
|
+
# Is Ollama running?
|
|
157
|
+
ps aux | grep ollama
|
|
158
|
+
|
|
159
|
+
# Can you reach the API?
|
|
160
|
+
curl http://localhost:11434/api/tags
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Fix:**
|
|
164
|
+
```bash
|
|
165
|
+
# Start Ollama
|
|
166
|
+
ollama serve
|
|
167
|
+
|
|
168
|
+
# In another terminal, verify
|
|
169
|
+
ollama list
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Issue 2: "Cannot connect to Appium server"
|
|
173
|
+
|
|
174
|
+
**If using LambdaTest (recommended):**
|
|
175
|
+
- ✅ This is normal - you don't need local Appium
|
|
176
|
+
- Check `.env` has correct LambdaTest credentials:
|
|
177
|
+
```bash
|
|
178
|
+
LAMBDATEST_GRID_URL=https://mobile-hub.lambdatest.com/wd/hub
|
|
179
|
+
LAMBDATEST_USERNAME=your_username
|
|
180
|
+
LAMBDATEST_ACCESS_KEY=your_key
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**If testing locally:**
|
|
184
|
+
```bash
|
|
185
|
+
# Start Appium
|
|
186
|
+
appium --allow-cors --log-level info
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Issue 3: "MCP Server not found"
|
|
190
|
+
|
|
191
|
+
**This is usually OK** - MCP starts automatically.
|
|
192
|
+
|
|
193
|
+
**To verify MCP can start:**
|
|
194
|
+
```bash
|
|
195
|
+
# Check if mcp-appium is available
|
|
196
|
+
npx mcp-appium --version
|
|
197
|
+
|
|
198
|
+
# If not found, you might need to install it
|
|
199
|
+
# (Note: mcp-appium might be in development)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Issue 4: Port 3000 already in use
|
|
203
|
+
|
|
204
|
+
**Check what's using it:**
|
|
205
|
+
```bash
|
|
206
|
+
lsof -i :3000
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Kill the process:**
|
|
210
|
+
```bash
|
|
211
|
+
kill -9 $(lsof -t -i:3000)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Or change MCP port in `.env`:**
|
|
215
|
+
```bash
|
|
216
|
+
MCP_SERVER_PORT=3001
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Issue 5: Model not found
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Check available models
|
|
223
|
+
ollama list
|
|
224
|
+
|
|
225
|
+
# Pull the required model
|
|
226
|
+
ollama pull llama3.2:3b
|
|
227
|
+
|
|
228
|
+
# Verify it's downloaded
|
|
229
|
+
ollama list | grep llama3.2
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Health Check Commands
|
|
233
|
+
|
|
234
|
+
### Quick Health Check
|
|
235
|
+
```bash
|
|
236
|
+
npm run health
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Comprehensive Check
|
|
240
|
+
```bash
|
|
241
|
+
npm run setup
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Service Status Check
|
|
245
|
+
```bash
|
|
246
|
+
npm run check-services
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Process Management
|
|
250
|
+
|
|
251
|
+
### Check Running Processes
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# Check Ollama
|
|
255
|
+
pgrep -f ollama
|
|
256
|
+
|
|
257
|
+
# Check Appium
|
|
258
|
+
pgrep -f appium
|
|
259
|
+
|
|
260
|
+
# Check MCP
|
|
261
|
+
pgrep -f mcp-appium
|
|
262
|
+
|
|
263
|
+
# Check all on port 3000
|
|
264
|
+
lsof -i :3000
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Stop All Services
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
# Stop Ollama
|
|
271
|
+
pkill ollama
|
|
272
|
+
|
|
273
|
+
# Stop Appium
|
|
274
|
+
pkill -f appium
|
|
275
|
+
|
|
276
|
+
# Stop MCP
|
|
277
|
+
pkill -f mcp-appium
|
|
278
|
+
|
|
279
|
+
# Or use the process ID
|
|
280
|
+
kill -9 <PID>
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Restart Services
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
# Stop everything
|
|
287
|
+
pkill ollama
|
|
288
|
+
pkill -f appium
|
|
289
|
+
pkill -f mcp-appium
|
|
290
|
+
|
|
291
|
+
# Wait a moment
|
|
292
|
+
sleep 2
|
|
293
|
+
|
|
294
|
+
# Start fresh
|
|
295
|
+
ollama serve &
|
|
296
|
+
# MCP will auto-start with tests
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## Running Tests with Service Checks
|
|
300
|
+
|
|
301
|
+
### Recommended Workflow
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
# 1. One-time setup (ensure Ollama is running)
|
|
305
|
+
ollama serve # Keep this terminal open
|
|
306
|
+
|
|
307
|
+
# 2. In a new terminal, run setup check
|
|
308
|
+
npm run setup
|
|
309
|
+
|
|
310
|
+
# 3. If all checks pass, run tests
|
|
311
|
+
npm run test
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### CI/CD Environment
|
|
315
|
+
|
|
316
|
+
In Jenkins/CI, the Jenkinsfile handles service startup automatically:
|
|
317
|
+
|
|
318
|
+
```groovy
|
|
319
|
+
stage('Setup') {
|
|
320
|
+
steps {
|
|
321
|
+
container('ollama') {
|
|
322
|
+
sh 'ollama pull llama3.2:3b'
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
stage('Health Check') {
|
|
328
|
+
steps {
|
|
329
|
+
sh 'npm run health'
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Configuration
|
|
335
|
+
|
|
336
|
+
### Environment Variables for MCP
|
|
337
|
+
|
|
338
|
+
Add to `.env`:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
# MCP Server Configuration
|
|
342
|
+
MCP_SERVER_TYPE=mcp-appium
|
|
343
|
+
MCP_SERVER_HOST=localhost
|
|
344
|
+
MCP_SERVER_PORT=3000
|
|
345
|
+
MCP_PROTOCOL=http
|
|
346
|
+
MCP_TIMEOUT=30000
|
|
347
|
+
|
|
348
|
+
# Appium Configuration
|
|
349
|
+
APPIUM_SERVER_URL=http://localhost:4723
|
|
350
|
+
# Or for LambdaTest:
|
|
351
|
+
# APPIUM_SERVER_URL=https://mobile-hub.lambdatest.com/wd/hub
|
|
352
|
+
|
|
353
|
+
# Enable/disable MCP features
|
|
354
|
+
MCP_CAPTURE_PAGE_SOURCE=true
|
|
355
|
+
MCP_PARSE_XML=true
|
|
356
|
+
MCP_SCREENSHOT_ON_ERROR=true
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## Best Practices
|
|
360
|
+
|
|
361
|
+
### 1. Keep Ollama Running
|
|
362
|
+
- Start once, keep it running all day
|
|
363
|
+
- Uses ~2-4GB RAM when loaded
|
|
364
|
+
- Fast subsequent requests
|
|
365
|
+
|
|
366
|
+
### 2. Let MCP Auto-Start
|
|
367
|
+
- Don't start MCP manually unless debugging
|
|
368
|
+
- Framework handles initialization
|
|
369
|
+
- Cleaner process management
|
|
370
|
+
|
|
371
|
+
### 3. Use Health Checks
|
|
372
|
+
- Run `npm run setup` before test sessions
|
|
373
|
+
- Catches issues early
|
|
374
|
+
- Validates environment
|
|
375
|
+
|
|
376
|
+
### 4. Monitor Resources
|
|
377
|
+
```bash
|
|
378
|
+
# Check memory usage
|
|
379
|
+
top | grep ollama
|
|
380
|
+
|
|
381
|
+
# Check if model is loaded
|
|
382
|
+
curl http://localhost:11434/api/tags
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### 5. Log Everything
|
|
386
|
+
- MCP logs to `logs/mcp-server.log` if started manually
|
|
387
|
+
- Test runner logs to `logs/combined.log`
|
|
388
|
+
- Check logs when debugging
|
|
389
|
+
|
|
390
|
+
## Summary Checklist
|
|
391
|
+
|
|
392
|
+
Before running tests, ensure:
|
|
393
|
+
|
|
394
|
+
- [ ] Ollama is running (`ollama serve`)
|
|
395
|
+
- [ ] Model is available (`ollama list | grep llama3.2`)
|
|
396
|
+
- [ ] Environment variables are set (`.env` file)
|
|
397
|
+
- [ ] Project is built (`npm run build`)
|
|
398
|
+
- [ ] All checks pass (`npm run setup`)
|
|
399
|
+
|
|
400
|
+
Then run:
|
|
401
|
+
```bash
|
|
402
|
+
npm run test
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
The MCP server will start automatically! 🚀
|