mcp-openstack-ops 0.0.1__tar.gz

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.
@@ -0,0 +1 @@
1
+ #include src/mcp_openstack_ops/test.txt
@@ -0,0 +1,580 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-openstack-ops
3
+ Version: 0.0.1
4
+ Summary: OpenStack operations automation MCP server
5
+ Author-email: JungJungIn <call518@gmail.com>
6
+ Requires-Python: >=3.11
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: fastmcp>=2.11.1
9
+ Requires-Dist: openstacksdk>=4.7.1
10
+ Requires-Dist: python-dotenv>=1.1.1
11
+ Provides-Extra: dev
12
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
13
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
14
+
15
+ # MCP-OpenStack-Ops
16
+
17
+ > **MCP OpenStack Operations Server**: A comprehensive MCP (Model Context Protocol) server providing OpenStack cluster management and monitoring capabilities. This server enables AI assistants to interact with OpenStack infrastructure through standardized tools for real-time monitoring, resource management, and operational tasks.
18
+
19
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
20
+ [![Deploy to PyPI with tag](https://github.com/call518/MCP-OpenStack-Ops/actions/workflows/pypi-publish.yml/badge.svg)](https://github.com/call518/MCP-OpenStack-Ops/actions/workflows/pypi-publish.yml)
21
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/call518/MCP-OpenStack-Ops)
22
+ [![BuyMeACoffee](https://raw.githubusercontent.com/pachadotdev/buymeacoffee-badges/main/bmc-donate-yellow.svg)](https://www.buymeacoffee.com/call518)
23
+
24
+ ## Features
25
+
26
+ - ✅ **OpenStack Integration**: Direct integration with OpenStack SDK for real-time cluster operations
27
+ - ✅ **Comprehensive Monitoring**: Cluster status, service monitoring, resource utilization tracking
28
+ - ✅ **Instance Management**: Start, stop, restart, pause/unpause OpenStack instances
29
+ - ✅ **Volume Operations**: Create, delete, list, and manage OpenStack volumes
30
+ - ✅ **Network Analysis**: Detailed network, subnet, router, and security group information
31
+ - ✅ **Flexible Transport**: Support for both `stdio` and `streamable-http` transports
32
+ - ✅ **Comprehensive Logging**: Configurable logging levels with structured output
33
+ - ✅ **Environment Configuration**: Support for environment variables and CLI arguments
34
+ - ✅ **Error Handling**: Robust error handling and configuration validation
35
+ - ✅ **Docker Support**: Containerized deployment with Docker Compose
36
+
37
+ ## MCP Tools Available
38
+
39
+ ### 🔍 Monitoring Tools
40
+ 1. **`get_openstack_cluster_status`** - Overall cluster status with instances, networks, and services
41
+ 2. **`get_openstack_service_status`** - OpenStack service health and API endpoint status
42
+ 3. **`get_openstack_instance_details`** - Detailed information for specific instances
43
+ 4. **`monitor_openstack_resources`** - Real-time resource usage and capacity monitoring
44
+
45
+ ### 🌐 Network Tools
46
+ 5. **`get_openstack_network_details`** - Network, subnet, router, and security group details
47
+
48
+ ### ⚙️ Management Tools
49
+ 6. **`manage_openstack_instance`** - Instance lifecycle operations (start/stop/restart/pause/unpause)
50
+ 7. **`manage_openstack_volume`** - Volume management operations (create/delete/list)
51
+
52
+ ## Quick Start
53
+
54
+ ### 1. Environment Setup
55
+
56
+ ```bash
57
+ # Clone and navigate to project
58
+ cd MCP-OpenStack-Ops
59
+
60
+ # Install dependencies
61
+ uv sync
62
+
63
+ # Configure environment
64
+ cp .env.example .env
65
+ # Edit .env with your OpenStack credentials
66
+ ```
67
+
68
+ ### 2. OpenStack Configuration
69
+
70
+ Configure your `.env` file with OpenStack credentials:
71
+
72
+ ```bash
73
+ # OpenStack Authentication
74
+ OS_AUTH_URL=https://your-openstack:5000/v3
75
+ OS_IDENTITY_API_VERSION=3
76
+ OS_USERNAME=your-username
77
+ OS_PASSWORD=your-password
78
+ OS_PROJECT_NAME=your-project
79
+ OS_PROJECT_DOMAIN_NAME=default
80
+ OS_USER_DOMAIN_NAME=default
81
+ OS_REGION_NAME=RegionOne
82
+
83
+ # MCP Server Configuration (optional)
84
+ MCP_LOG_LEVEL=INFO
85
+ FASTMCP_TYPE=stdio
86
+ FASTMCP_HOST=127.0.0.1
87
+ FASTMCP_PORT=8080
88
+ ```
89
+
90
+ ### 3. Run Server
91
+
92
+ #### For Development & Testing
93
+ ```bash
94
+ # Local testing with MCP Inspector
95
+ ./scripts/run-mcp-inspector-local.sh
96
+
97
+ # Direct execution for debugging
98
+ uv run python -m mcp_openstack_ops --log-level DEBUG
99
+ ```
100
+
101
+ #### For Production (Docker)
102
+ ```bash
103
+ # Build and run with Docker Compose
104
+ docker-compose up -d
105
+
106
+ # Check logs
107
+ docker-compose logs -f mcp-server
108
+ ```
109
+
110
+ #### For Claude Desktop Integration
111
+ Add to your Claude Desktop configuration:
112
+ ```json
113
+ {
114
+ "mcpServers": {
115
+ "openstack-ops": {
116
+ "command": "uv",
117
+ "args": ["run", "python", "-m", "mcp_openstack_ops"],
118
+ "cwd": "/path/to/MCP-OpenStack-Ops"
119
+ }
120
+ }
121
+ }
122
+ ```
123
+
124
+ ## Server Configuration
125
+
126
+ ### Command Line Options
127
+
128
+ ```bash
129
+ uv run python -m mcp_openstack_ops --help
130
+
131
+ Options:
132
+ --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
133
+ Logging level
134
+ --type {stdio,streamable-http}
135
+ Transport type (default: stdio)
136
+ --host HOST Host address for HTTP transport (default: 127.0.0.1)
137
+ --port PORT Port number for HTTP transport (default: 8080)
138
+ --auth-enable Enable Bearer token authentication for streamable-http mode
139
+ --secret-key SECRET Secret key for Bearer token authentication
140
+ ```
141
+
142
+ ### Environment Variables
143
+
144
+ | Variable | Description | Default | Usage |
145
+ |----------|-------------|---------|--------|
146
+ | **OpenStack Authentication** |
147
+ | `OS_AUTH_URL` | OpenStack Identity service URL | Required | Authentication endpoint |
148
+ | `OS_USERNAME` | OpenStack username | Required | User credentials |
149
+ | `OS_PASSWORD` | OpenStack password | Required | User credentials |
150
+ | `OS_PROJECT_NAME` | OpenStack project name | Required | Project scope |
151
+ | `OS_IDENTITY_API_VERSION` | Identity API version | `3` | API version |
152
+ | `OS_PROJECT_DOMAIN_NAME` | Project domain name | `default` | Domain scope |
153
+ | `OS_USER_DOMAIN_NAME` | User domain name | `default` | Domain scope |
154
+ | `OS_REGION_NAME` | OpenStack region | `RegionOne` | Regional scope |
155
+ | **MCP Server Configuration** |
156
+ | `MCP_LOG_LEVEL` | Logging level | `INFO` | Development debugging |
157
+ | `FASTMCP_TYPE` | Transport type | `stdio` | Rarely needed to change |
158
+ | `FASTMCP_HOST` | HTTP host address | `127.0.0.1` | For HTTP mode only |
159
+ | `FASTMCP_PORT` | HTTP port number | `8080` | For HTTP mode only |
160
+ | **Authentication (Optional)** |
161
+ | `REMOTE_AUTH_ENABLE` | Enable Bearer token authentication for streamable-http mode | `false` | Production security |
162
+ | `REMOTE_SECRET_KEY` | Secret key for Bearer token authentication | Required when auth enabled | Production security |
163
+
164
+ **Note**: MCP servers typically use `stdio` transport. HTTP mode is mainly for testing and development.
165
+
166
+ ## Project Structure
167
+
168
+ ```
169
+ .
170
+ ├── main.py # Main entry point
171
+ ├── MANIFEST.in # Package manifest
172
+ ├── pyproject.toml # Project configuration
173
+ ├── README.md # This file
174
+ ├── uv.lock # Dependency lock file
175
+ ├── .env.example # Environment configuration template
176
+ ├── Dockerfile.MCP-Server # Docker container configuration
177
+ ├── docker-compose.yml # Docker Compose setup
178
+ ├── docs/ # Documentation
179
+ ├── scripts/
180
+ │ ├── mcp-server-docker-cmd.sh # Docker container startup script
181
+ │ ├── run-mcp-inspector-local.sh # Development & testing
182
+ │ └── run-mcp-inspector-pypi.sh # Test published package
183
+ └── src/
184
+ └── mcp_openstack_ops/
185
+ ├── __init__.py
186
+ ├── __main__.py # Module execution entry point
187
+ ├── functions.py # OpenStack utility functions
188
+ ├── mcp_main.py # FastMCP server implementation
189
+ └── prompt_template.md # AI assistant prompt template
190
+ ```
191
+
192
+ ## Tool Usage Examples
193
+
194
+ ### 🔍 Monitoring Examples
195
+
196
+ ```bash
197
+ # Get overall cluster status
198
+ → "Show me the OpenStack cluster status"
199
+ → Calls: get_openstack_cluster_status()
200
+
201
+ # Check service health
202
+ → "Are all OpenStack services running properly?"
203
+ → Calls: get_openstack_service_status()
204
+
205
+ # Monitor resource usage
206
+ → "What's the current resource utilization?"
207
+ → Calls: monitor_openstack_resources()
208
+
209
+ # Get instance details
210
+ → "Show details for instance web-server-01"
211
+ → Calls: get_openstack_instance_details("web-server-01")
212
+ ```
213
+
214
+ ### 🌐 Network Examples
215
+
216
+ ```bash
217
+ # Check all networks
218
+ → "Show me all network configurations"
219
+ → Calls: get_openstack_network_details("all")
220
+
221
+ # Specific network details
222
+ → "Get details for the internal network"
223
+ → Calls: get_openstack_network_details("internal")
224
+ ```
225
+
226
+ ### ⚙️ Management Examples
227
+
228
+ ```bash
229
+ # Instance management
230
+ → "Start the web-server-01 instance"
231
+ → Calls: manage_openstack_instance("web-server-01", "start")
232
+
233
+ → "Restart the database server"
234
+ → Calls: manage_openstack_instance("db-server", "restart")
235
+
236
+ # Volume management
237
+ → "Create a 100GB volume named backup-vol"
238
+ → Calls: manage_openstack_volume("backup-vol", "create", 100)
239
+
240
+ → "List all volumes"
241
+ → Calls: manage_openstack_volume("", "list")
242
+ ```
243
+
244
+ ## Development
245
+
246
+ ### Adding New Tools
247
+
248
+ Edit `src/mcp_openstack_ops/mcp_main.py` to add new MCP tools:
249
+
250
+ ```python
251
+ @mcp.tool()
252
+ async def my_openstack_tool(param: str) -> str:
253
+ """
254
+ Brief description of the tool's purpose.
255
+
256
+ Functions:
257
+ - List specific functions this tool performs
258
+ - Describe the operations it enables
259
+ - Mention when to use this tool
260
+
261
+ Use when user requests [specific scenarios].
262
+
263
+ Args:
264
+ param: Description of the parameter
265
+
266
+ Returns:
267
+ Description of return value format.
268
+ """
269
+ try:
270
+ logger.info(f"Tool called with param: {param}")
271
+ # Implementation using functions.py helpers
272
+ result = my_helper_function(param)
273
+
274
+ response = {
275
+ "timestamp": datetime.now().isoformat(),
276
+ "result": result
277
+ }
278
+
279
+ return json.dumps(response, indent=2, ensure_ascii=False)
280
+
281
+ except Exception as e:
282
+ error_msg = f"Error: Failed to execute tool - {str(e)}"
283
+ logger.error(error_msg)
284
+ return error_msg
285
+ ```
286
+
287
+ ### Helper Functions
288
+
289
+ Add utility functions to `src/mcp_openstack_ops/functions.py`:
290
+
291
+ ```python
292
+ def my_helper_function(param: str) -> dict:
293
+ """Helper function for OpenStack operations"""
294
+ try:
295
+ conn = get_openstack_connection()
296
+
297
+ # OpenStack SDK operations
298
+ result = conn.some_service.some_operation(param)
299
+
300
+ logger.info(f"Operation completed successfully")
301
+ return {"success": True, "data": result}
302
+
303
+ except Exception as e:
304
+ logger.error(f"Helper function error: {e}")
305
+ raise
306
+ ```
307
+
308
+ ## Testing & Validation
309
+
310
+ ### Local Testing
311
+ ```bash
312
+ # Test with MCP Inspector (recommended)
313
+ ./scripts/run-mcp-inspector-local.sh
314
+
315
+ # Test with debug logging
316
+ MCP_LOG_LEVEL=DEBUG uv run python -m mcp_openstack_ops
317
+
318
+ # Validate OpenStack connection
319
+ uv run python -c "from src.mcp_openstack_ops.functions import get_openstack_connection; print(get_openstack_connection())"
320
+ ```
321
+
322
+ ### Docker Testing
323
+ ```bash
324
+ # Build and test in container
325
+ docker-compose build
326
+ docker-compose up -d
327
+
328
+ # Check container logs
329
+ docker-compose logs -f mcp-server
330
+
331
+ # Test HTTP endpoint (if using HTTP transport)
332
+ curl -X POST http://localhost:18005/mcp \
333
+ -H "Content-Type: application/json" \
334
+ -d '{"method": "tools/list"}'
335
+ ```
336
+
337
+ ## 🔐 Security & Authentication
338
+
339
+ ### Bearer Token Authentication
340
+
341
+ For `streamable-http` mode, this MCP server supports Bearer token authentication to secure remote access. This is especially important when running the server in production environments.
342
+
343
+ #### Configuration
344
+
345
+ **Enable Authentication:**
346
+
347
+ ```bash
348
+ # In .env file
349
+ REMOTE_AUTH_ENABLE=true
350
+ REMOTE_SECRET_KEY=your-secure-secret-key-here
351
+ ```
352
+
353
+ **Or via CLI:**
354
+
355
+ ```bash
356
+ uv run python -m mcp_openstack_ops --type streamable-http --auth-enable --secret-key your-secure-secret-key-here
357
+ ```
358
+
359
+ #### Security Levels
360
+
361
+ 1. **stdio mode** (Default): Local-only access, no authentication needed
362
+ 2. **streamable-http + REMOTE_AUTH_ENABLE=false/undefined**: Remote access without authentication ⚠️ **NOT RECOMMENDED for production**
363
+ 3. **streamable-http + REMOTE_AUTH_ENABLE=true**: Remote access with Bearer token authentication ✅ **RECOMMENDED for production**
364
+
365
+ > **🔒 Default Policy**: `REMOTE_AUTH_ENABLE` defaults to `false` if undefined, empty, or null. This ensures the server starts even without explicit authentication configuration.
366
+
367
+ #### Client Configuration
368
+
369
+ When authentication is enabled, MCP clients must include the Bearer token in the Authorization header:
370
+
371
+ ```json
372
+ {
373
+ "mcpServers": {
374
+ "openstack-ops": {
375
+ "type": "streamable-http",
376
+ "url": "http://your-server:8080/mcp",
377
+ "headers": {
378
+ "Authorization": "Bearer your-secure-secret-key-here"
379
+ }
380
+ }
381
+ }
382
+ }
383
+ ```
384
+
385
+ #### Security Best Practices
386
+
387
+ - **Always enable authentication** when using streamable-http mode in production
388
+ - **Use strong, randomly generated secret keys** (32+ characters recommended)
389
+ - **Use HTTPS** when possible (configure reverse proxy with SSL/TLS)
390
+ - **Restrict network access** using firewalls or network policies
391
+ - **Rotate secret keys regularly** for enhanced security
392
+ - **Monitor access logs** for unauthorized access attempts
393
+
394
+ #### Error Handling
395
+
396
+ When authentication fails, the server returns:
397
+ - **401 Unauthorized** for missing or invalid tokens
398
+ - **Detailed error messages** in JSON format for debugging
399
+
400
+ ---
401
+
402
+ ## Deployment
403
+
404
+ ### Local Development
405
+ ```bash
406
+ # Test with MCP Inspector (recommended)
407
+ ./scripts/run-mcp-inspector-local.sh
408
+
409
+ # Test with debug logging
410
+ MCP_LOG_LEVEL=DEBUG uv run python -m mcp_openstack_ops
411
+
412
+ # Validate OpenStack connection
413
+ uv run python -c "from src.mcp_openstack_ops.functions import get_openstack_connection; print(get_openstack_connection())"
414
+ ```
415
+
416
+ ### Docker Testing
417
+ ```bash
418
+ # Build and test in container
419
+ docker-compose build
420
+ docker-compose up -d
421
+
422
+ # Check container logs
423
+ docker-compose logs -f mcp-server
424
+
425
+ # Test HTTP endpoint (if using HTTP transport)
426
+ curl -X POST http://localhost:18005/mcp \
427
+ -H "Content-Type: application/json" \
428
+ -d '{"method": "tools/list"}'
429
+
430
+ ### Claude Desktop Integration
431
+ Add to your Claude Desktop configuration (`claude_desktop_config.json`):
432
+
433
+ #### Method 1: Local MCP (transport="stdio")
434
+
435
+ ```json
436
+ {
437
+ "mcpServers": {
438
+ "openstack-ops": {
439
+ "command": "uv",
440
+ "args": ["run", "python", "-m", "mcp_openstack_ops"],
441
+ "cwd": "/path/to/MCP-OpenStack-Ops",
442
+ "env": {
443
+ "OS_AUTH_URL": "https://your-openstack:5000/v3",
444
+ "OS_USERNAME": "your-username",
445
+ "OS_PASSWORD": "your-password",
446
+ "OS_PROJECT_NAME": "your-project",
447
+ "MCP_LOG_LEVEL": "INFO"
448
+ }
449
+ }
450
+ }
451
+ }
452
+ ```
453
+
454
+ #### Method 2: Remote MCP (transport="streamable-http")
455
+
456
+ **Without Authentication:**
457
+ ```json
458
+ {
459
+ "mcpServers": {
460
+ "openstack-ops": {
461
+ "type": "streamable-http",
462
+ "url": "http://localhost:18005/mcp"
463
+ }
464
+ }
465
+ }
466
+ ```
467
+
468
+ **With Bearer Token Authentication (Recommended for production):**
469
+ ```json
470
+ {
471
+ "mcpServers": {
472
+ "openstack-ops": {
473
+ "type": "streamable-http",
474
+ "url": "http://localhost:18005/mcp",
475
+ "headers": {
476
+ "Authorization": "Bearer your-secure-secret-key-here"
477
+ }
478
+ }
479
+ }
480
+ }
481
+ ```
482
+
483
+ ### Production Deployment
484
+ ```bash
485
+ # Using Docker Compose (recommended)
486
+ docker-compose up -d
487
+
488
+ # Manual Docker run
489
+ docker build -f Dockerfile.MCP-Server -t mcp-openstack-ops .
490
+ docker run -d --name mcp-openstack-ops \
491
+ --env-file .env \
492
+ -p 18005:8000 \
493
+ mcp-openstack-ops
494
+ ```
495
+
496
+ ## Troubleshooting
497
+
498
+ ### Common Issues
499
+
500
+ 1. **Authentication Errors**
501
+ - Verify OpenStack credentials in `.env`
502
+ - Check network connectivity to OpenStack API endpoints
503
+ - Validate user permissions and project access
504
+
505
+ 2. **Tool Execution Failures**
506
+ - Review logs with `MCP_LOG_LEVEL=DEBUG`
507
+ - Ensure OpenStack services are accessible
508
+ - Verify instance/volume/network names exist
509
+
510
+ 3. **Transport Issues**
511
+ - Use `stdio` for Claude Desktop integration
512
+ - Use `streamable-http` for testing and development
513
+ - Check port availability for HTTP transport
514
+
515
+ 4. **Authentication Issues (streamable-http mode)**
516
+ - Verify `REMOTE_SECRET_KEY` matches between server and client
517
+ - Ensure Bearer token is included in client Authorization header
518
+ - Check server logs for authentication error details
519
+ - Confirm `REMOTE_AUTH_ENABLE=true` is set when using authentication
520
+
521
+ ### Getting Help
522
+
523
+ - Check logs for detailed error messages
524
+ - Validate OpenStack connectivity independently
525
+ - Test individual tools with MCP Inspector
526
+ - Review OpenStack SDK documentation for API requirements
527
+
528
+ ## License
529
+
530
+ This project is licensed under the MIT License - see the LICENSE file for details.
531
+
532
+ ## Contributing
533
+
534
+ 1. Fork the repository
535
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
536
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
537
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
538
+ 5. Open a Pull Request
539
+
540
+ ### HTTP Mode (Advanced)
541
+ For special testing scenarios only:
542
+
543
+ ```bash
544
+ # Run HTTP server for testing
545
+ python -m src.mcp_openstack_ops.mcp_main \
546
+ --type streamable-http \
547
+ --host 127.0.0.1 \
548
+ --port 8080 \
549
+ --log-level DEBUG
550
+ ```
551
+
552
+ ### Testing & Development
553
+
554
+ ```bash
555
+ # Test with MCP Inspector
556
+ ./scripts/run-mcp-inspector-local.sh
557
+
558
+ # Direct execution for debugging
559
+ python -m src.mcp_openstack_ops.mcp_main --log-level DEBUG
560
+
561
+ # Run tests (if you add any)
562
+ uv run pytest
563
+ ```
564
+
565
+ ## Logging
566
+
567
+ The server provides structured logging with configurable levels:
568
+
569
+ ```
570
+ 2024-08-19 10:30:15 - mcp_main - INFO - Starting MCP server with stdio transport
571
+ 2024-08-19 10:30:15 - mcp_main - INFO - Log level set via CLI to INFO
572
+ 2024-08-19 10:30:16 - functions - DEBUG - Fetching data from source: example.com
573
+ ```
574
+
575
+ ## Notes
576
+
577
+ - The script replaces mcp_openstack_ops (underscore), mcp-openstack-ops (hyphen), and mcp-openstack-ops (display name)
578
+ - Configuration validation ensures proper setup before server start
579
+ - If you need to rename again, revert changes or re-clone and re-run
580
+ - A backup `pyproject.toml.bak` is created when overwriting pyproject