tideways-mcp-server 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/README.md +447 -0
- package/bin/cli.js +156 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +55 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/errors.d.ts +22 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +97 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/logger.d.ts +12 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +54 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/tideways-client.d.ts +36 -0
- package/dist/lib/tideways-client.d.ts.map +1 -0
- package/dist/lib/tideways-client.js +203 -0
- package/dist/lib/tideways-client.js.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +94 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/definitions.d.ts +6 -0
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/definitions.js +158 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/handlers/historical-handler.d.ts +4 -0
- package/dist/tools/handlers/historical-handler.d.ts.map +1 -0
- package/dist/tools/handlers/historical-handler.js +12 -0
- package/dist/tools/handlers/historical-handler.js.map +1 -0
- package/dist/tools/handlers/issues-handler.d.ts +4 -0
- package/dist/tools/handlers/issues-handler.d.ts.map +1 -0
- package/dist/tools/handlers/issues-handler.js +11 -0
- package/dist/tools/handlers/issues-handler.js.map +1 -0
- package/dist/tools/handlers/performance-handler.d.ts +4 -0
- package/dist/tools/handlers/performance-handler.d.ts.map +1 -0
- package/dist/tools/handlers/performance-handler.js +11 -0
- package/dist/tools/handlers/performance-handler.js.map +1 -0
- package/dist/tools/handlers/performance-summary-handler.d.ts +4 -0
- package/dist/tools/handlers/performance-summary-handler.d.ts.map +1 -0
- package/dist/tools/handlers/performance-summary-handler.js +11 -0
- package/dist/tools/handlers/performance-summary-handler.js.map +1 -0
- package/dist/tools/handlers/traces-handler.d.ts +4 -0
- package/dist/tools/handlers/traces-handler.d.ts.map +1 -0
- package/dist/tools/handlers/traces-handler.js +30 -0
- package/dist/tools/handlers/traces-handler.js.map +1 -0
- package/dist/tools/registry.d.ts +3 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +20 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/types/error.d.ts +7 -0
- package/dist/types/error.d.ts.map +1 -0
- package/dist/types/error.js +2 -0
- package/dist/types/error.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/logging.d.ts +11 -0
- package/dist/types/logging.d.ts.map +1 -0
- package/dist/types/logging.js +2 -0
- package/dist/types/logging.js.map +1 -0
- package/dist/types/mcp.d.ts +32 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +2 -0
- package/dist/types/mcp.js.map +1 -0
- package/dist/types/tideways-api.d.ts +151 -0
- package/dist/types/tideways-api.d.ts.map +1 -0
- package/dist/types/tideways-api.js +2 -0
- package/dist/types/tideways-api.js.map +1 -0
- package/dist/types/tideways-config.d.ts +15 -0
- package/dist/types/tideways-config.d.ts.map +1 -0
- package/dist/types/tideways-config.js +2 -0
- package/dist/types/tideways-config.js.map +1 -0
- package/dist/utils/date-utils.d.ts +4 -0
- package/dist/utils/date-utils.d.ts.map +1 -0
- package/dist/utils/date-utils.js +16 -0
- package/dist/utils/date-utils.js.map +1 -0
- package/package.json +86 -0
package/README.md
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
# Tideways MCP Server
|
|
2
|
+
|
|
3
|
+
A Model Context Protocol (MCP) server that enables AI assistants to query Tideways performance monitoring data and provide conversational performance insights for PHP applications.
|
|
4
|
+
|
|
5
|
+
## 🚀 Features
|
|
6
|
+
|
|
7
|
+
- **Conversational Performance Insights**: Get performance data in natural language format optimized for AI assistants
|
|
8
|
+
- **AI Assistant Integration**: Works with Claude Desktop, Cursor, Claude Code, and other MCP-compatible tools
|
|
9
|
+
- **Real-time Performance Metrics**: Query current performance data with intelligent caching
|
|
10
|
+
- **Issue Analysis**: Retrieve and analyze errors, exceptions, and performance issues
|
|
11
|
+
- **Rate Limiting & Caching**: Intelligent API management with respect for Tideways rate limits
|
|
12
|
+
- **Robust Error Handling**: Comprehensive error handling with user-friendly messages
|
|
13
|
+
|
|
14
|
+
## 📋 Prerequisites
|
|
15
|
+
|
|
16
|
+
- Node.js 18.0 or higher
|
|
17
|
+
- Valid Tideways API token with appropriate scopes (`metrics`, `issues`, `traces`)
|
|
18
|
+
- Access to a Tideways organization and project
|
|
19
|
+
|
|
20
|
+
## 🛠️ Installation
|
|
21
|
+
|
|
22
|
+
### Option 1: Clone and Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
git clone https://github.com/abuhamza/mcp-tideways.git
|
|
26
|
+
cd mcp-tideways
|
|
27
|
+
npm install
|
|
28
|
+
npm run build
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Option 2: Install from npm (coming soon)
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install -g tideways-mcp-server
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## ⚙️ Configuration
|
|
38
|
+
|
|
39
|
+
Create a `.env` file in the project root:
|
|
40
|
+
|
|
41
|
+
```env
|
|
42
|
+
# Required Configuration
|
|
43
|
+
TIDEWAYS_TOKEN=your_tideways_api_token
|
|
44
|
+
TIDEWAYS_ORG=your_organization_name
|
|
45
|
+
TIDEWAYS_PROJECT=your_project_name
|
|
46
|
+
|
|
47
|
+
# Optional Configuration
|
|
48
|
+
TIDEWAYS_BASE_URL=https://app.tideways.io/apps/api
|
|
49
|
+
TIDEWAYS_MAX_RETRIES=3
|
|
50
|
+
TIDEWAYS_REQUEST_TIMEOUT=30000
|
|
51
|
+
SERVER_PORT=3000
|
|
52
|
+
LOG_LEVEL=info
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Environment Variables
|
|
56
|
+
|
|
57
|
+
| Variable | Required | Default | Description |
|
|
58
|
+
|----------|----------|---------|-------------|
|
|
59
|
+
| `TIDEWAYS_TOKEN` | ✅ | - | Tideways API access token (see Security section) |
|
|
60
|
+
| `TIDEWAYS_ORG` | ✅ | - | Tideways organization name |
|
|
61
|
+
| `TIDEWAYS_PROJECT` | ✅ | - | Tideways project name |
|
|
62
|
+
| `TIDEWAYS_BASE_URL` | ❌ | `https://app.tideways.io/apps/api` | Tideways API base URL |
|
|
63
|
+
| `TIDEWAYS_MAX_RETRIES` | ❌ | `3` | Maximum API retry attempts |
|
|
64
|
+
| `TIDEWAYS_REQUEST_TIMEOUT` | ❌ | `30000` | API request timeout (ms) |
|
|
65
|
+
| `SERVER_PORT` | ❌ | `3000` | Server port |
|
|
66
|
+
| `LOG_LEVEL` | ❌ | `info` | Log level (debug, info, warn, error) |
|
|
67
|
+
|
|
68
|
+
## 🚀 Usage
|
|
69
|
+
|
|
70
|
+
### Running the Server
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Development mode
|
|
74
|
+
npm run dev
|
|
75
|
+
|
|
76
|
+
# Production mode
|
|
77
|
+
npm run start
|
|
78
|
+
|
|
79
|
+
# Or run built version directly
|
|
80
|
+
node dist/index.js
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Claude Desktop Integration
|
|
84
|
+
|
|
85
|
+
Add to your Claude Desktop MCP configuration (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"mcpServers": {
|
|
90
|
+
"tideways": {
|
|
91
|
+
"command": "node",
|
|
92
|
+
"args": ["/path/to/tideways-mcp-server/dist/index.js"],
|
|
93
|
+
"env": {
|
|
94
|
+
"TIDEWAYS_TOKEN": "your_token",
|
|
95
|
+
"TIDEWAYS_ORG": "your_org",
|
|
96
|
+
"TIDEWAYS_PROJECT": "your_project"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Using with AI Assistants
|
|
104
|
+
|
|
105
|
+
Once configured, you can ask your AI assistant questions like:
|
|
106
|
+
|
|
107
|
+
#### Basic Performance Queries
|
|
108
|
+
- "What's the current performance of my application?"
|
|
109
|
+
- "Show me recent errors in the last 24 hours"
|
|
110
|
+
- "How is my API performing compared to yesterday?"
|
|
111
|
+
- "What are the slowest transactions right now?"
|
|
112
|
+
|
|
113
|
+
#### Advanced Trace Analysis & Optimization
|
|
114
|
+
- "Analyze the `/api/users/{id}` endpoint and identify bottlenecks"
|
|
115
|
+
- "Find the root cause of slow performance in my checkout process"
|
|
116
|
+
- "Detect N+1 queries in my product listing endpoint and suggest fixes"
|
|
117
|
+
- "Analyze traces for `/dashboard` and recommend code optimizations"
|
|
118
|
+
- "Identify database query bottlenecks in my user authentication flow"
|
|
119
|
+
- "Find memory leaks or inefficient code paths in my API endpoints"
|
|
120
|
+
- "Analyze dependency injection overhead in my application"
|
|
121
|
+
- "Detect redundant database calls and suggest caching strategies"
|
|
122
|
+
|
|
123
|
+
#### Performance Optimization Suggestions
|
|
124
|
+
- "Recommend performance improvements for my slowest endpoints"
|
|
125
|
+
- "Analyze my SQL queries and suggest indexing strategies"
|
|
126
|
+
- "Identify opportunities for query batching or lazy loading"
|
|
127
|
+
- "Find inefficient loops or recursive calls in my traces"
|
|
128
|
+
- "Suggest code refactoring based on performance bottlenecks"
|
|
129
|
+
- "Analyze memory usage patterns and recommend optimizations"
|
|
130
|
+
|
|
131
|
+
## 🛠️ Available MCP Tools
|
|
132
|
+
|
|
133
|
+
All tools return structured JSON data for optimal AI assistant integration. The MCP server follows a "raw JSON approach" where tools return complete API responses without formatting, allowing AI assistants to analyze and present data flexibly.
|
|
134
|
+
|
|
135
|
+
### `get_performance_metrics`
|
|
136
|
+
|
|
137
|
+
Retrieve aggregate performance metrics and system-wide statistics.
|
|
138
|
+
|
|
139
|
+
**Parameters:**
|
|
140
|
+
- `ts` (optional): End timestamp in Y-m-d H:i format (e.g., "2025-08-12 18:30")
|
|
141
|
+
- `m` (optional): Number of minutes backward from timestamp (e.g., 60 for 1 hour, 1440 for 24 hours)
|
|
142
|
+
- `env` (optional): Filter by specific environment
|
|
143
|
+
- `s` (optional): Filter by specific service name
|
|
144
|
+
|
|
145
|
+
**Example Usage:**
|
|
146
|
+
```
|
|
147
|
+
Claude, get my performance metrics for the last 6 hours
|
|
148
|
+
Claude, show me metrics for the API service in production
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### `get_performance_summary`
|
|
152
|
+
|
|
153
|
+
Retrieve time-series performance summary data in 15-minute intervals for trend analysis.
|
|
154
|
+
|
|
155
|
+
**Parameters:**
|
|
156
|
+
- `s` (optional): Service name to filter by (e.g., "web", "api", "worker"). Default: "web"
|
|
157
|
+
|
|
158
|
+
**Example Usage:**
|
|
159
|
+
```
|
|
160
|
+
Claude, show me the performance summary trends
|
|
161
|
+
Claude, get performance summary for the API service
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### `get_issues`
|
|
165
|
+
|
|
166
|
+
Retrieve and analyze recent errors, exceptions, and performance issues.
|
|
167
|
+
|
|
168
|
+
**Parameters:**
|
|
169
|
+
- `issue_type` (optional): "error", "slowsql", "deprecated", "all" (default: "all")
|
|
170
|
+
- `status` (optional): "open", "new", "resolved", "not_error", "ignored", "all" (default: "open")
|
|
171
|
+
- `page` (optional): Page number for pagination (default: 1)
|
|
172
|
+
|
|
173
|
+
**Example Usage:**
|
|
174
|
+
```
|
|
175
|
+
Claude, show me all open errors
|
|
176
|
+
Claude, get slow SQL queries from today
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### `get_traces`
|
|
180
|
+
|
|
181
|
+
Analyze individual trace samples for detailed bottleneck identification and performance debugging.
|
|
182
|
+
|
|
183
|
+
**Parameters:**
|
|
184
|
+
- `env` (optional): Environment name (e.g., "production", "staging")
|
|
185
|
+
- `s` (optional): Service name (e.g., "web", "api", "worker")
|
|
186
|
+
- `transaction_name` (optional): Filter by specific transaction/endpoint name
|
|
187
|
+
- `has_callgraph` (optional): Only return traces with detailed callgraph data
|
|
188
|
+
- `search` (optional): Word-based search on transaction_name, host, and URL
|
|
189
|
+
- `min_date` (optional): Minimal date in YYYY-MM-DD HH:MM format (requires max_date)
|
|
190
|
+
- `max_date` (optional): Maximal date in YYYY-MM-DD HH:MM format (requires min_date)
|
|
191
|
+
- `min_response_time_ms` (optional): Minimum response time filter
|
|
192
|
+
- `max_response_time_ms` (optional): Maximum response time filter
|
|
193
|
+
- `sort_by` (optional): "response_time", "date", "memory" (default: "response_time")
|
|
194
|
+
- `sort_order` (optional): "ASC", "DESC" (default: "DESC")
|
|
195
|
+
|
|
196
|
+
**Example Usage:**
|
|
197
|
+
```
|
|
198
|
+
Claude, analyze traces for /api/products and find slow requests
|
|
199
|
+
Claude, get traces with response time over 1000ms from the last hour
|
|
200
|
+
Claude, find traces with callgraph data for the checkout endpoint
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### `get_historical_data`
|
|
204
|
+
|
|
205
|
+
Retrieve historical performance data for specific dates with configurable granularity.
|
|
206
|
+
|
|
207
|
+
**Parameters:**
|
|
208
|
+
- `date` (required): Date in YYYY-MM-DD format
|
|
209
|
+
- `granularity` (optional): "day", "week", "month" (default: "day")
|
|
210
|
+
|
|
211
|
+
**Example Usage:**
|
|
212
|
+
```
|
|
213
|
+
Claude, get historical data for 2025-08-01
|
|
214
|
+
Claude, show me weekly performance data for last Monday
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## 🧪 Development
|
|
218
|
+
|
|
219
|
+
### Project Structure
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
├── src/
|
|
223
|
+
│ ├── config/ # Configuration management
|
|
224
|
+
│ ├── lib/ # Core libraries
|
|
225
|
+
│ │ ├── errors.ts # Error handling utilities
|
|
226
|
+
│ │ ├── logger.ts # Structured logging
|
|
227
|
+
│ │ └── tideways-client.ts # Tideways API client
|
|
228
|
+
│ ├── tools/ # MCP tool implementations
|
|
229
|
+
│ │ ├── definitions.ts # Tool schema definitions
|
|
230
|
+
│ │ ├── registry.ts # Tool execution registry
|
|
231
|
+
│ │ └── handlers/ # Individual tool handlers
|
|
232
|
+
│ ├── types/ # TypeScript type definitions
|
|
233
|
+
│ ├── utils/ # Utility functions
|
|
234
|
+
│ ├── server.ts # Main MCP server implementation
|
|
235
|
+
│ └── index.ts # Application entry point
|
|
236
|
+
├── tests/ # Test suites
|
|
237
|
+
└── dist/ # Compiled JavaScript (generated)
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Running Tests
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
# Run all tests
|
|
244
|
+
npm test
|
|
245
|
+
|
|
246
|
+
# Run tests with coverage
|
|
247
|
+
npm run test:coverage
|
|
248
|
+
|
|
249
|
+
# Run tests in watch mode
|
|
250
|
+
npm run test:watch
|
|
251
|
+
|
|
252
|
+
# Run type checking
|
|
253
|
+
npm run typecheck
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Building
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
# Build TypeScript to JavaScript
|
|
260
|
+
npm run build
|
|
261
|
+
|
|
262
|
+
# Clean build artifacts
|
|
263
|
+
npm run clean
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Code Quality
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# Run linter
|
|
270
|
+
npm run lint
|
|
271
|
+
|
|
272
|
+
# Fix linting issues
|
|
273
|
+
npm run lint:fix
|
|
274
|
+
|
|
275
|
+
# Format code
|
|
276
|
+
npm run format
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## 🏗️ Architecture
|
|
280
|
+
|
|
281
|
+
### Core Components
|
|
282
|
+
|
|
283
|
+
1. **MCP Server** (`src/server.ts`): Main server implementing MCP protocol, handles tool definitions and routing
|
|
284
|
+
2. **Tideways API Client** (`src/lib/tideways-client.ts`): HTTP client with rate limiting, retry logic, and security measures
|
|
285
|
+
3. **Tool Registry** (`src/tools/`): Modular tool system with individual handlers for each MCP tool
|
|
286
|
+
4. **Error Handler** (`src/lib/errors.ts`): Centralized error handling with user-friendly messages
|
|
287
|
+
5. **Logger** (`src/lib/logger.ts`): Structured JSON logging for monitoring and debugging
|
|
288
|
+
6. **Configuration** (`src/config/index.ts`): Environment-based configuration management
|
|
289
|
+
|
|
290
|
+
### Data Flow
|
|
291
|
+
|
|
292
|
+
```
|
|
293
|
+
AI Assistant → MCP Protocol → TidewaysMCPServer → TidewaysClient → Tideways API
|
|
294
|
+
↓
|
|
295
|
+
Raw JSON Response → AI Assistant
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Response Format Philosophy
|
|
299
|
+
|
|
300
|
+
This server uses a **simplified raw JSON approach** for optimal performance:
|
|
301
|
+
- **Direct API-to-LLM Pipeline**: Tools return `JSON.stringify(apiData, null, 2)` without formatting
|
|
302
|
+
- **Zero Processing Overhead**: No complex formatting, caching, or interpretation logic
|
|
303
|
+
- **Complete Data Preservation**: LLM receives all available data for flexible analysis
|
|
304
|
+
- **Modern LLM Optimized**: GPT-4/Claude excel at parsing structured JSON data
|
|
305
|
+
- **Minimal Maintenance**: No formatter or caching logic to maintain or debug
|
|
306
|
+
|
|
307
|
+
### Rate Limiting Strategy
|
|
308
|
+
|
|
309
|
+
- **Rate Limiter**: Built-in rate limiting respects Tideways API constraints (900 requests/hour by default)
|
|
310
|
+
- **Direct API Calls**: All requests go directly to Tideways API without caching layer
|
|
311
|
+
- **Retry Logic**: Automatic retries for transient failures with exponential backoff
|
|
312
|
+
- **YAGNI Principle**: No caching complexity until performance issues are observed
|
|
313
|
+
|
|
314
|
+
## 🛡️ Security
|
|
315
|
+
|
|
316
|
+
- API tokens stored securely in environment variables
|
|
317
|
+
- Rate limiting to respect Tideways API constraints
|
|
318
|
+
- Input validation on all MCP function parameters
|
|
319
|
+
- No sensitive data logged or exposed in error messages
|
|
320
|
+
|
|
321
|
+
## 📊 Monitoring
|
|
322
|
+
|
|
323
|
+
The server provides structured JSON logs for monitoring:
|
|
324
|
+
|
|
325
|
+
```json
|
|
326
|
+
{
|
|
327
|
+
"timestamp": "2025-08-09T10:00:00.000Z",
|
|
328
|
+
"level": "info",
|
|
329
|
+
"message": "Tool called",
|
|
330
|
+
"context": {
|
|
331
|
+
"toolName": "get_performance_metrics",
|
|
332
|
+
"arguments": {"time_range": "24h"}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## 🔧 Troubleshooting
|
|
338
|
+
|
|
339
|
+
### Common Issues
|
|
340
|
+
|
|
341
|
+
**Authentication Error**
|
|
342
|
+
```
|
|
343
|
+
Error: Authentication failed. Please check your API token.
|
|
344
|
+
```
|
|
345
|
+
- Verify `TIDEWAYS_TOKEN` is correct and has required scopes
|
|
346
|
+
- Check token hasn't expired
|
|
347
|
+
- Ensure organization and project names are correct
|
|
348
|
+
|
|
349
|
+
**Rate Limit Exceeded**
|
|
350
|
+
```
|
|
351
|
+
Error: Rate limit exceeded. Please try again later.
|
|
352
|
+
```
|
|
353
|
+
- Wait for rate limit reset (shown in error message)
|
|
354
|
+
- Reduce query frequency
|
|
355
|
+
- Enable caching to minimize API calls
|
|
356
|
+
|
|
357
|
+
**Connection Issues**
|
|
358
|
+
```
|
|
359
|
+
Error: Network error: Unable to connect to Tideways API.
|
|
360
|
+
```
|
|
361
|
+
- Check internet connection
|
|
362
|
+
- Verify Tideways API is accessible
|
|
363
|
+
- Check if corporate firewall blocks API access
|
|
364
|
+
|
|
365
|
+
### Debug Mode
|
|
366
|
+
|
|
367
|
+
Enable debug logging for detailed troubleshooting:
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
LOG_LEVEL=debug npm run dev
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
## 🚧 Roadmap
|
|
374
|
+
|
|
375
|
+
### Phase 2 (Planned)
|
|
376
|
+
- **MCP Prompts**: Pre-defined analysis templates and guided workflows for systematic performance investigation
|
|
377
|
+
- **Streamable Responses**: Real-time streaming of large datasets for better user experience
|
|
378
|
+
- **Advanced Trace Analysis**: Enhanced bottleneck detection with AI-powered recommendations
|
|
379
|
+
- **Multi-project Support**: Manage performance across multiple applications
|
|
380
|
+
- **Integration with Other APM Providers**: Support for New Relic, DataDog, Elastic APM
|
|
381
|
+
|
|
382
|
+
### Phase 3 (Future)
|
|
383
|
+
- **Real-time Performance Monitoring**: Live performance alerts and recommendations
|
|
384
|
+
- **Custom Dashboard Generation**: AI-generated performance dashboards
|
|
385
|
+
- **Performance Regression Detection**: Automatic detection of performance degradations in deployments
|
|
386
|
+
- **Load Testing Integration**: Performance analysis under different load scenarios
|
|
387
|
+
- **Security Performance Analysis**: Identification of security-related performance bottlenecks
|
|
388
|
+
|
|
389
|
+
## 🔒 Security
|
|
390
|
+
|
|
391
|
+
This MCP server implements several security measures to protect your Tideways API credentials:
|
|
392
|
+
|
|
393
|
+
### Token Security
|
|
394
|
+
- **Validation**: API tokens are validated to ensure they are set (any format accepted)
|
|
395
|
+
- **Logging Protection**: Authorization headers are automatically redacted in debug logs as `Bearer [REDACTED]`
|
|
396
|
+
- **Secure Storage**: Tokens should be stored in environment variables, never in code
|
|
397
|
+
|
|
398
|
+
### Best Practices
|
|
399
|
+
- Store your API token securely in environment variables or `.env` files
|
|
400
|
+
- Never commit API tokens to version control
|
|
401
|
+
- Use unique, strong tokens with minimal required permissions
|
|
402
|
+
- Regularly rotate your API tokens
|
|
403
|
+
- Monitor access logs for suspicious activity
|
|
404
|
+
|
|
405
|
+
### Reporting Security Issues
|
|
406
|
+
If you discover a security vulnerability, please report it responsibly through GitHub's security advisory feature.
|
|
407
|
+
|
|
408
|
+
## 🤝 Contributing
|
|
409
|
+
|
|
410
|
+
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
411
|
+
|
|
412
|
+
### Development Setup
|
|
413
|
+
|
|
414
|
+
1. Fork the repository
|
|
415
|
+
2. Create a feature branch: `git checkout -b feature/your-feature`
|
|
416
|
+
3. Make changes and add tests
|
|
417
|
+
4. Run tests: `npm test`
|
|
418
|
+
5. Submit a pull request
|
|
419
|
+
|
|
420
|
+
## 📄 License
|
|
421
|
+
|
|
422
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
423
|
+
|
|
424
|
+
## 🆘 Support
|
|
425
|
+
|
|
426
|
+
- GitHub Issues: [Report bugs or request features](https://github.com/abuhamza/mcp-tideways/issues)
|
|
427
|
+
- Documentation: [Project Wiki](https://github.com/abuhamza/mcp-tideways/wiki)
|
|
428
|
+
|
|
429
|
+
## 📈 Performance
|
|
430
|
+
|
|
431
|
+
- Average response time: <2 seconds for cached queries
|
|
432
|
+
- Memory usage: <100MB with default cache settings
|
|
433
|
+
- Supports concurrent AI assistant connections
|
|
434
|
+
- Efficient rate limiting prevents API quota exhaustion
|
|
435
|
+
|
|
436
|
+
## 🏷️ Version History
|
|
437
|
+
|
|
438
|
+
- **v0.1.0** - Initial release with core MCP functionality
|
|
439
|
+
- Foundation setup with performance metrics and issues analysis
|
|
440
|
+
- Comprehensive error handling and caching
|
|
441
|
+
|
|
442
|
+
---
|
|
443
|
+
|
|
444
|
+
Add example for :
|
|
445
|
+
DANGEROUSLY_OMIT_AUTH=true npx @modelcontextprotocol/inspector -e TIDEWAYS_TOKEN= -e TIDEWAYS_ORG=check24_hotel -e TIDEWAYS_PROJECT=api -e LOG_LEVEL=debug node /home/mouhammed/Work/tideways-mcp/dist/index.js
|
|
446
|
+
|
|
447
|
+
Built with ❤️ for the PHP development community
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { dirname, join } from 'path';
|
|
6
|
+
|
|
7
|
+
// Import compiled modules
|
|
8
|
+
import { TidewaysMCPServer } from '../dist/server.js';
|
|
9
|
+
|
|
10
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const packageJson = JSON.parse(
|
|
12
|
+
readFileSync(join(__dirname, '..', 'package.json'), 'utf8')
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
function showHelp() {
|
|
16
|
+
console.log(`
|
|
17
|
+
${packageJson.name} v${packageJson.version}
|
|
18
|
+
|
|
19
|
+
${packageJson.description}
|
|
20
|
+
|
|
21
|
+
Usage:
|
|
22
|
+
npx ${packageJson.name} [options]
|
|
23
|
+
|
|
24
|
+
Options:
|
|
25
|
+
--help, -h Show this help message
|
|
26
|
+
--version, -v Show version information
|
|
27
|
+
--stdio Use stdio transport (default for MCP)
|
|
28
|
+
--http Use HTTP transport (experimental)
|
|
29
|
+
--port <port> HTTP port (default: 3000, requires --http)
|
|
30
|
+
|
|
31
|
+
Environment Variables (required):
|
|
32
|
+
TIDEWAYS_TOKEN Your Tideways API token
|
|
33
|
+
TIDEWAYS_ORG Your Tideways organization name
|
|
34
|
+
TIDEWAYS_PROJECT Your Tideways project name
|
|
35
|
+
|
|
36
|
+
Examples:
|
|
37
|
+
# Start MCP server with stdio transport (default)
|
|
38
|
+
npx ${packageJson.name}
|
|
39
|
+
|
|
40
|
+
# Start with HTTP transport on custom port
|
|
41
|
+
npx ${packageJson.name} --http --port 3001
|
|
42
|
+
|
|
43
|
+
# Show version
|
|
44
|
+
npx ${packageJson.name} --version
|
|
45
|
+
|
|
46
|
+
For more information, visit: ${packageJson.homepage}
|
|
47
|
+
`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function showVersion() {
|
|
51
|
+
console.log(`${packageJson.name} v${packageJson.version}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function main() {
|
|
55
|
+
const args = process.argv.slice(2);
|
|
56
|
+
|
|
57
|
+
// Parse command line arguments
|
|
58
|
+
let useHttp = false;
|
|
59
|
+
let port = 3000;
|
|
60
|
+
|
|
61
|
+
for (let i = 0; i < args.length; i++) {
|
|
62
|
+
const arg = args[i];
|
|
63
|
+
|
|
64
|
+
switch (arg) {
|
|
65
|
+
case '--help':
|
|
66
|
+
case '-h':
|
|
67
|
+
showHelp();
|
|
68
|
+
process.exit(0);
|
|
69
|
+
break;
|
|
70
|
+
|
|
71
|
+
case '--version':
|
|
72
|
+
case '-v':
|
|
73
|
+
showVersion();
|
|
74
|
+
process.exit(0);
|
|
75
|
+
break;
|
|
76
|
+
|
|
77
|
+
case '--stdio':
|
|
78
|
+
useHttp = false;
|
|
79
|
+
break;
|
|
80
|
+
|
|
81
|
+
case '--http':
|
|
82
|
+
useHttp = true;
|
|
83
|
+
break;
|
|
84
|
+
|
|
85
|
+
case '--port':
|
|
86
|
+
if (i + 1 >= args.length) {
|
|
87
|
+
console.error('Error: --port requires a value');
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
port = parseInt(args[++i], 10);
|
|
91
|
+
if (isNaN(port) || port < 1 || port > 65535) {
|
|
92
|
+
console.error('Error: Invalid port number');
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
|
|
97
|
+
default:
|
|
98
|
+
console.error(`Error: Unknown option '${arg}'`);
|
|
99
|
+
console.error('Use --help for usage information');
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Validate required environment variables
|
|
105
|
+
const requiredEnvVars = ['TIDEWAYS_TOKEN', 'TIDEWAYS_ORG', 'TIDEWAYS_PROJECT'];
|
|
106
|
+
const missingVars = requiredEnvVars.filter(varName => !process.env[varName]);
|
|
107
|
+
|
|
108
|
+
if (missingVars.length > 0) {
|
|
109
|
+
console.error('Error: Missing required environment variables:');
|
|
110
|
+
missingVars.forEach(varName => {
|
|
111
|
+
console.error(` ${varName}`);
|
|
112
|
+
});
|
|
113
|
+
console.error('\nPlease set these environment variables and try again.');
|
|
114
|
+
console.error('Use --help for more information.');
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
// Create and start the MCP server
|
|
120
|
+
const server = new TidewaysMCPServer();
|
|
121
|
+
|
|
122
|
+
if (useHttp) {
|
|
123
|
+
console.log(`Starting Tideways MCP Server on HTTP port ${port}...`);
|
|
124
|
+
console.log('Note: HTTP transport is experimental');
|
|
125
|
+
// HTTP transport would be implemented here when available
|
|
126
|
+
console.error('Error: HTTP transport is not yet implemented');
|
|
127
|
+
console.error('Please use stdio transport (default) for now');
|
|
128
|
+
process.exit(1);
|
|
129
|
+
} else {
|
|
130
|
+
console.log('Starting Tideways MCP Server with stdio transport...');
|
|
131
|
+
console.log('Server is ready to receive MCP requests');
|
|
132
|
+
|
|
133
|
+
// Start the server with stdio transport
|
|
134
|
+
await server.start();
|
|
135
|
+
}
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error('Error starting server:', error.message);
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Handle graceful shutdown
|
|
143
|
+
process.on('SIGINT', () => {
|
|
144
|
+
console.log('\nShutting down Tideways MCP Server...');
|
|
145
|
+
process.exit(0);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
process.on('SIGTERM', () => {
|
|
149
|
+
console.log('\nShutting down Tideways MCP Server...');
|
|
150
|
+
process.exit(0);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
main().catch(error => {
|
|
154
|
+
console.error('Fatal error:', error.message);
|
|
155
|
+
process.exit(1);
|
|
156
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,MAAM,WAAW,YAAa,SAAQ,cAAc;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AASD,wBAAgB,UAAU,IAAI,YAAY,CAuBzC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { config } from 'dotenv';
|
|
2
|
+
config();
|
|
3
|
+
const DEFAULT_CONFIG = {
|
|
4
|
+
baseUrl: 'https://app.tideways.io/apps/api',
|
|
5
|
+
maxRetries: 3,
|
|
6
|
+
requestTimeout: 30000,
|
|
7
|
+
port: 3000,
|
|
8
|
+
};
|
|
9
|
+
export function loadConfig() {
|
|
10
|
+
const config = {
|
|
11
|
+
token: process.env.TIDEWAYS_TOKEN || '',
|
|
12
|
+
organization: process.env.TIDEWAYS_ORG || '',
|
|
13
|
+
project: process.env.TIDEWAYS_PROJECT || '',
|
|
14
|
+
...DEFAULT_CONFIG,
|
|
15
|
+
};
|
|
16
|
+
if (process.env.TIDEWAYS_BASE_URL) {
|
|
17
|
+
config.baseUrl = process.env.TIDEWAYS_BASE_URL;
|
|
18
|
+
}
|
|
19
|
+
if (process.env.TIDEWAYS_MAX_RETRIES) {
|
|
20
|
+
config.maxRetries = parseInt(process.env.TIDEWAYS_MAX_RETRIES, 10);
|
|
21
|
+
}
|
|
22
|
+
if (process.env.TIDEWAYS_REQUEST_TIMEOUT) {
|
|
23
|
+
config.requestTimeout = parseInt(process.env.TIDEWAYS_REQUEST_TIMEOUT, 10);
|
|
24
|
+
}
|
|
25
|
+
if (process.env.SERVER_PORT) {
|
|
26
|
+
config.port = parseInt(process.env.SERVER_PORT, 10);
|
|
27
|
+
}
|
|
28
|
+
validateConfig(config);
|
|
29
|
+
return config;
|
|
30
|
+
}
|
|
31
|
+
function validateConfig(config) {
|
|
32
|
+
const errors = [];
|
|
33
|
+
if (!config.token) {
|
|
34
|
+
errors.push('TIDEWAYS_TOKEN environment variable is required');
|
|
35
|
+
}
|
|
36
|
+
if (!config.organization) {
|
|
37
|
+
errors.push('TIDEWAYS_ORG environment variable is required');
|
|
38
|
+
}
|
|
39
|
+
if (!config.project) {
|
|
40
|
+
errors.push('TIDEWAYS_PROJECT environment variable is required');
|
|
41
|
+
}
|
|
42
|
+
if (config.maxRetries && (config.maxRetries < 0 || config.maxRetries > 10)) {
|
|
43
|
+
errors.push('maxRetries must be between 0 and 10');
|
|
44
|
+
}
|
|
45
|
+
if (config.requestTimeout && config.requestTimeout < 1000) {
|
|
46
|
+
errors.push('requestTimeout must be at least 1000ms');
|
|
47
|
+
}
|
|
48
|
+
if (config.port && (config.port < 1 || config.port > 65535)) {
|
|
49
|
+
errors.push('port must be between 1 and 65535');
|
|
50
|
+
}
|
|
51
|
+
if (errors.length > 0) {
|
|
52
|
+
throw new Error(`Configuration validation failed:\n${errors.join('\n')}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,MAAM,EAAE,CAAC;AAMT,MAAM,cAAc,GAA0B;IAC5C,OAAO,EAAE,kCAAkC;IAC3C,UAAU,EAAE,CAAC;IACb,cAAc,EAAE,KAAK;IACrB,IAAI,EAAE,IAAI;CACX,CAAC;AAEF,MAAM,UAAU,UAAU;IACxB,MAAM,MAAM,GAAiB;QAC3B,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE;QACvC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE;QAC5C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE;QAC3C,GAAG,cAAc;KACF,CAAC;IAElB,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;QAClC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACjD,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,CAAC;QACrC,MAAM,CAAC,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,CAAC;QACzC,MAAM,CAAC,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QAC5B,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,cAAc,CAAC,MAAM,CAAC,CAAC;IACvB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,MAAoB;IAC1C,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;IAC/D,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,IAAI,MAAM,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC;QAC3E,MAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,MAAM,CAAC,cAAc,IAAI,MAAM,CAAC,cAAc,GAAG,IAAI,EAAE,CAAC;QAC1D,MAAM,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;IACxD,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;QAC5D,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC"}
|
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,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { TidewaysMCPServer } from './server.js';
|
|
3
|
+
import { logger } from './lib/logger.js';
|
|
4
|
+
async function main() {
|
|
5
|
+
try {
|
|
6
|
+
const server = new TidewaysMCPServer();
|
|
7
|
+
await server.start();
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
logger.error('Failed to start Tideways MCP Server', error);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
main().catch(error => {
|
|
15
|
+
logger.error('Unhandled error in main', error);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=index.js.map
|