mcp-instana 0.1.0__py3-none-any.whl → 0.2.0__py3-none-any.whl

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.
Files changed (67) hide show
  1. mcp_instana-0.2.0.dist-info/METADATA +1229 -0
  2. mcp_instana-0.2.0.dist-info/RECORD +59 -0
  3. {mcp_instana-0.1.0.dist-info → mcp_instana-0.2.0.dist-info}/WHEEL +1 -1
  4. mcp_instana-0.2.0.dist-info/entry_points.txt +4 -0
  5. mcp_instana-0.1.0.dist-info/LICENSE → mcp_instana-0.2.0.dist-info/licenses/LICENSE.md +3 -3
  6. src/application/__init__.py +1 -0
  7. src/{client/application_alert_config_mcp_tools.py → application/application_alert_config.py} +251 -273
  8. src/application/application_analyze.py +628 -0
  9. src/application/application_catalog.py +155 -0
  10. src/application/application_global_alert_config.py +653 -0
  11. src/{client/application_metrics_mcp_tools.py → application/application_metrics.py} +113 -131
  12. src/{client/application_resources_mcp_tools.py → application/application_resources.py} +131 -151
  13. src/application/application_settings.py +1731 -0
  14. src/application/application_topology.py +111 -0
  15. src/automation/action_catalog.py +416 -0
  16. src/automation/action_history.py +338 -0
  17. src/core/__init__.py +1 -0
  18. src/core/server.py +586 -0
  19. src/core/utils.py +213 -0
  20. src/event/__init__.py +1 -0
  21. src/event/events_tools.py +850 -0
  22. src/infrastructure/__init__.py +1 -0
  23. src/{client/infrastructure_analyze_mcp_tools.py → infrastructure/infrastructure_analyze.py} +207 -206
  24. src/{client/infrastructure_catalog_mcp_tools.py → infrastructure/infrastructure_catalog.py} +197 -265
  25. src/infrastructure/infrastructure_metrics.py +171 -0
  26. src/{client/infrastructure_resources_mcp_tools.py → infrastructure/infrastructure_resources.py} +198 -227
  27. src/{client/infrastructure_topology_mcp_tools.py → infrastructure/infrastructure_topology.py} +110 -109
  28. src/log/__init__.py +1 -0
  29. src/log/log_alert_configuration.py +331 -0
  30. src/prompts/__init__.py +16 -0
  31. src/prompts/application/__init__.py +1 -0
  32. src/prompts/application/application_alerts.py +54 -0
  33. src/prompts/application/application_catalog.py +26 -0
  34. src/prompts/application/application_metrics.py +57 -0
  35. src/prompts/application/application_resources.py +26 -0
  36. src/prompts/application/application_settings.py +75 -0
  37. src/prompts/application/application_topology.py +30 -0
  38. src/prompts/events/__init__.py +1 -0
  39. src/prompts/events/events_tools.py +161 -0
  40. src/prompts/infrastructure/infrastructure_analyze.py +72 -0
  41. src/prompts/infrastructure/infrastructure_catalog.py +53 -0
  42. src/prompts/infrastructure/infrastructure_metrics.py +45 -0
  43. src/prompts/infrastructure/infrastructure_resources.py +74 -0
  44. src/prompts/infrastructure/infrastructure_topology.py +38 -0
  45. src/prompts/settings/__init__.py +0 -0
  46. src/prompts/settings/custom_dashboard.py +157 -0
  47. src/prompts/website/__init__.py +1 -0
  48. src/prompts/website/website_analyze.py +35 -0
  49. src/prompts/website/website_catalog.py +40 -0
  50. src/prompts/website/website_configuration.py +105 -0
  51. src/prompts/website/website_metrics.py +34 -0
  52. src/settings/__init__.py +1 -0
  53. src/settings/custom_dashboard_tools.py +417 -0
  54. src/website/__init__.py +0 -0
  55. src/website/website_analyze.py +433 -0
  56. src/website/website_catalog.py +171 -0
  57. src/website/website_configuration.py +770 -0
  58. src/website/website_metrics.py +241 -0
  59. mcp_instana-0.1.0.dist-info/METADATA +0 -649
  60. mcp_instana-0.1.0.dist-info/RECORD +0 -19
  61. mcp_instana-0.1.0.dist-info/entry_points.txt +0 -3
  62. src/client/What is the sum of queue depth for all q +0 -55
  63. src/client/events_mcp_tools.py +0 -531
  64. src/client/instana_client_base.py +0 -93
  65. src/client/log_alert_configuration_mcp_tools.py +0 -316
  66. src/client/show the top 5 services with the highest +0 -28
  67. src/mcp_server.py +0 -343
@@ -0,0 +1,1229 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-instana
3
+ Version: 0.2.0
4
+ Summary: MCP server for Instana
5
+ Author-email: Elina Priyadarshinee <Elina.priyadarshinee1@ibm.com>, Guangya Liu <gyliu@ibm.com>, Isabell Sippli <ischwert@de.ibm.com>, Jay Sharma <Jay.Sharma3@ibm.com>, Madhu Tadiparthi <madhu.tadiparthi@ibm.com>, Riya Kumari <Riya.Kumari3@ibm.com>
6
+ License: Apache-2.0
7
+ License-File: LICENSE.md
8
+ Requires-Python: >=3.11
9
+ Requires-Dist: fastmcp==2.10.3
10
+ Requires-Dist: instana-client==1.0.0
11
+ Requires-Dist: pydantic==2.11.7
12
+ Requires-Dist: python-dotenv==1.1.0
13
+ Requires-Dist: requests==2.32.4
14
+ Provides-Extra: dev
15
+ Requires-Dist: coverage>=7.10.1; extra == 'dev'
16
+ Requires-Dist: pytest-asyncio>=1.1.0; extra == 'dev'
17
+ Requires-Dist: pytest-cov>=6.2.1; extra == 'dev'
18
+ Requires-Dist: pytest-mock>=3.14.1; extra == 'dev'
19
+ Requires-Dist: pytest>=8.4.1; extra == 'dev'
20
+ Requires-Dist: ruff==0.5.0; extra == 'dev'
21
+ Requires-Dist: uv==0.8.6; extra == 'dev'
22
+ Description-Content-Type: text/markdown
23
+
24
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
25
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
26
+ **Table of Contents**
27
+
28
+ - [MCP Server for IBM Instana](#mcp-server-for-ibm-instana)
29
+ - [Architecture Overview](#architecture-overview)
30
+ - [Workflow](#workflow)
31
+ - [Prerequisites](#prerequisites)
32
+ - [Option 1: Install from PyPI (Recommended)](#option-1-install-from-pypi-recommended)
33
+ - [Option 2: Development Installation](#option-2-development-installation)
34
+ - [Installing uv](#installing-uv)
35
+ - [Setting Up the Environment](#setting-up-the-environment)
36
+ - [Header-Based Authentication for Streamable HTTP Mode](#header-based-authentication-for-streamable-http-mode)
37
+ - [Starting the Local MCP Server](#starting-the-local-mcp-server)
38
+ - [Server Command Options](#server-command-options)
39
+ - [Using the CLI (PyPI Installation)](#using-the-cli-pypi-installation)
40
+ - [Using Development Installation](#using-development-installation)
41
+ - [Starting in Streamable HTTP Mode](#starting-in-streamable-http-mode)
42
+ - [Using CLI (PyPI Installation)](#using-cli-pypi-installation)
43
+ - [Using Development Installation](#using-development-installation-1)
44
+ - [Starting in Stdio Mode](#starting-in-stdio-mode)
45
+ - [Using CLI (PyPI Installation)](#using-cli-pypi-installation-1)
46
+ - [Using Development Installation](#using-development-installation-2)
47
+ - [Tool Categories](#tool-categories)
48
+ - [Using CLI (PyPI Installation)](#using-cli-pypi-installation-2)
49
+ - [Using Development Installation](#using-development-installation-3)
50
+ - [Verifying Server Status](#verifying-server-status)
51
+ - [Common Startup Issues](#common-startup-issues)
52
+ - [Setup and Usage](#setup-and-usage)
53
+ - [Claude Desktop](#claude-desktop)
54
+ - [Streamable HTTP Mode](#streamable-http-mode)
55
+ - [Stdio Mode](#stdio-mode)
56
+ - [GitHub Copilot](#github-copilot)
57
+ - [Streamable HTTP Mode](#streamable-http-mode-1)
58
+ - [Stdio Mode](#stdio-mode-1)
59
+ - [Supported Features](#supported-features)
60
+ - [Available Tools](#available-tools)
61
+ - [Tool Filtering](#tool-filtering)
62
+ - [Available Tool Categories](#available-tool-categories)
63
+ - [Usage Examples](#usage-examples)
64
+ - [Using CLI (PyPI Installation)](#using-cli-pypi-installation-3)
65
+ - [Using Development Installation](#using-development-installation-4)
66
+ - [Benefits of Tool Filtering](#benefits-of-tool-filtering)
67
+ - [Example Prompts](#example-prompts)
68
+ - [Docker Deployment](#docker-deployment)
69
+ - [Docker Architecture](#docker-architecture)
70
+ - [**pyproject.toml** (Development)](#pyprojecttoml-development)
71
+ - [**pyproject-runtime.toml** (Production)](#pyproject-runtimetoml-production)
72
+ - [Building the Docker Image](#building-the-docker-image)
73
+ - [**Prerequisites**](#prerequisites-1)
74
+ - [**Build Command**](#build-command)
75
+ - [**What the Build Does**](#what-the-build-does)
76
+ - [Running the Docker Container](#running-the-docker-container)
77
+ - [**Basic Usage**](#basic-usage)
78
+ - [**Environment Variables**](#environment-variables)
79
+ - [**Docker Compose Example**](#docker-compose-example)
80
+ - [Docker Security Features](#docker-security-features)
81
+ - [**Security Best Practices Implemented**](#security-best-practices-implemented)
82
+ - [**Image Size Optimization**](#image-size-optimization)
83
+ - [Testing the Docker Container](#testing-the-docker-container)
84
+ - [**Health Check**](#health-check)
85
+ - [**MCP Inspector Testing**](#mcp-inspector-testing)
86
+ - [**Logs and Debugging**](#logs-and-debugging)
87
+ - [Production Deployment](#production-deployment)
88
+ - [**Recommended Production Setup**](#recommended-production-setup)
89
+ - [**Kubernetes Example**](#kubernetes-example)
90
+ - [Troubleshooting](#troubleshooting)
91
+ - [**Docker Issues**](#docker-issues)
92
+ - [**Container Won't Start**](#container-wont-start)
93
+ - [**Connection Issues**](#connection-issues)
94
+ - [**Performance Issues**](#performance-issues)
95
+ - [**General Issues**](#general-issues)
96
+
97
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
98
+
99
+ # MCP Server for IBM Instana
100
+
101
+ The Instana MCP server enables seamless interaction with the Instana observability platform, allowing you to access real-time observability data directly within your development workflow.
102
+
103
+ It serves as a bridge between clients (such as AI agents or custom tools) and the Instana REST APIs, converting user queries into Instana API requests and formatting the responses into structured, easily consumable formats.
104
+
105
+ The server supports both **Streamable HTTP** and **Stdio** transport modes for maximum compatibility with different MCP clients. For more details, refer to the [MCP Transport Modes specification](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports).
106
+
107
+ ## Architecture Overview
108
+
109
+ ```mermaid
110
+ graph LR
111
+ subgraph "Application Host Process"
112
+ MH[MCP Host]
113
+ MSI[Instana MCP Server]
114
+ MST[ProductA MCP Server]
115
+ MSC[ProductB MCP Server]
116
+
117
+ MH <--> MSI
118
+ MH <--> MSC
119
+ MH <--> MST
120
+ end
121
+
122
+ subgraph "Remote Service"
123
+ II[Instana Instance]
124
+ TI[ProductA Instance]
125
+ CI[ProductB Instance]
126
+
127
+ MSI <--> II
128
+ MST <--> TI
129
+ MSC <--> CI
130
+ end
131
+
132
+ subgraph "LLM"
133
+ L[LLM]
134
+ MH <--> L
135
+ end
136
+ ```
137
+
138
+ ## Workflow
139
+
140
+ Consider a simple example: You're using an MCP Host (such as Claude Desktop, VS Code, or another client) connected to the Instana MCP Server. When you request information about Instana alerts, the following process occurs:
141
+
142
+ 1. The MCP client retrieves the list of available tools from the Instana MCP server
143
+ 2. Your query is sent to the LLM along with tool descriptions
144
+ 3. The LLM analyzes the available tools and selects the appropriate one(s) for retrieving Instana alerts
145
+ 4. The client executes the chosen tool(s) through the Instana MCP server
146
+ 5. Results (latest alerts) are returned to the LLM
147
+ 6. The LLM formulates a natural language response
148
+ 7. The response is displayed to you
149
+
150
+ ```mermaid
151
+ sequenceDiagram
152
+ participant User
153
+ participant ChatBot as MCP Host
154
+ participant MCPClient as MCP Client
155
+ participant MCPServer as Instana MCP Server
156
+ participant LLM
157
+ participant Instana as Instana Instance
158
+
159
+ ChatBot->>MCPClient: Load available tools from MCP Server
160
+ MCPClient->>MCPServer: Request available tool list
161
+ MCPServer->>MCPClient: Return list of available tools
162
+ User->>ChatBot: Ask "Show me the latest alerts from Instana for application robot-shop"
163
+ ChatBot->>MCPClient: Forward query
164
+ MCPClient->>LLM: Send query and tool description
165
+ LLM->>MCPClient: Select appropriate tool(s) for Instana alert query
166
+ MCPClient->>MCPServer: Execute selected tool(s)
167
+ MCPServer->>Instana: Retrieve alerts for application robot-shop
168
+ MCPServer->>MCPClient: Send alerts of Instana result
169
+ MCPClient->>LLM: Forward alerts of Instana
170
+ LLM->>ChatBot: Generate natural language response for Instana alerts
171
+ ChatBot->>User: Show Instana alert response
172
+ ```
173
+
174
+ ## Prerequisites
175
+
176
+ ### Option 1: Install from PyPI (Recommended)
177
+
178
+ The easiest way to use mcp-instana is to install it directly from PyPI:
179
+
180
+ ```shell
181
+ pip install mcp-instana
182
+ ```
183
+
184
+ After installation, you can run the server using the `mcp-instana` command directly.
185
+
186
+ ### Option 2: Development Installation
187
+
188
+ For development or local customization, you can clone and set up the project locally.
189
+
190
+ #### Installing uv
191
+
192
+ This project uses `uv`, a fast Python package installer and resolver. To install `uv`, you have several options:
193
+
194
+ **Using pip:**
195
+ ```shell
196
+ pip install uv
197
+ ```
198
+
199
+ **Using Homebrew (macOS):**
200
+ ```shell
201
+ brew install uv
202
+ ```
203
+
204
+ For more installation options and detailed instructions, visit the [uv documentation](https://github.com/astral-sh/uv).
205
+
206
+ #### Setting Up the Environment
207
+
208
+ After installing `uv`, set up the project environment by running:
209
+
210
+ ```shell
211
+ uv sync
212
+ ```
213
+
214
+ ### Header-Based Authentication for Streamable HTTP Mode
215
+
216
+ When using **Streamable HTTP mode**, you must pass Instana credentials via HTTP headers. This approach enhances security and flexibility by:
217
+
218
+ - Avoiding credential storage in environment variables
219
+ - Enabling the use of different credentials for different requests
220
+ - Supporting shared environments where environment variable modification is restricted
221
+
222
+ **Required Headers:**
223
+ - `instana-base-url`: Your Instana instance URL
224
+ - `instana-api-token`: Your Instana API token
225
+
226
+ **Authentication Flow:**
227
+ 1. HTTP headers (`instana-base-url`, `instana-api-token`) must be present in each request
228
+ 2. Requests without these headers will fail
229
+
230
+ This design ensures secure credential transmission where credentials are only sent via headers for each request, making it suitable for scenarios requiring different credentials or avoiding credential storage in environment variables.
231
+
232
+ ## Starting the Local MCP Server
233
+
234
+ Before configuring any MCP client (Claude Desktop, GitHub Copilot, or custom MCP clients), you need to start the local MCP server. The server supports two transport modes: **Streamable HTTP** and **Stdio**.
235
+
236
+ ### Server Command Options
237
+
238
+ #### Using the CLI (PyPI Installation)
239
+
240
+ If you installed mcp-instana from PyPI, use the `mcp-instana` command:
241
+
242
+ ```bash
243
+ mcp-instana [OPTIONS]
244
+ ```
245
+
246
+ #### Using Development Installation
247
+
248
+ For local development, use the `uv run` command:
249
+
250
+ ```bash
251
+ uv run src/core/server.py [OPTIONS]
252
+ ```
253
+
254
+ **Available Options:**
255
+ - `--transport <mode>`: Transport mode (choices: `streamable-http`, `stdio`)
256
+ - `--debug`: Enable debug mode with additional logging
257
+ - `--log-level <level>`: Set the logging level (choices: `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`)
258
+ - `--tools <categories>`: Comma-separated list of tool categories to enable (e.g., infra,app,events,automation,website). Enabling a category will also enable its related prompts. For example: `--tools infra` enables the infra tools and all infra-related prompts.
259
+ - `--list-tools`: List all available tool categories and exit
260
+ - `--port <port>`: Port to listen on (default: 8080)
261
+ - `--help`: Show help message and exit
262
+
263
+ ### Starting in Streamable HTTP Mode
264
+
265
+ **Streamable HTTP mode** provides a REST API interface and is recommended for most use cases.
266
+
267
+ #### Using CLI (PyPI Installation)
268
+
269
+ ```bash
270
+ # Start with all tools enabled (default)
271
+ mcp-instana --transport streamable-http
272
+
273
+ # Start with debug logging
274
+ mcp-instana --transport streamable-http --debug
275
+
276
+ # Start with a specific log level
277
+ mcp-instana --transport streamable-http --log-level WARNING
278
+
279
+ # Start with specific tool categories only
280
+ mcp-instana --transport streamable-http --tools infra,events
281
+
282
+ # Combine options (specific log level, custom tools)
283
+ mcp-instana --transport streamable-http --log-level DEBUG --tools app,events
284
+ ```
285
+
286
+ #### Using Development Installation
287
+
288
+ ```bash
289
+ # Start with all tools enabled (default)
290
+ uv run src/core/server.py --transport streamable-http
291
+
292
+ # Start with debug logging
293
+ uv run src/core/server.py --transport streamable-http --debug
294
+
295
+ # Start with a specific log level
296
+ uv run src/core/server.py --transport streamable-http --log-level WARNING
297
+
298
+ # Start with specific tool and prompts categories only
299
+ uv run src/core/server.py --transport streamable-http --tools infra,events
300
+
301
+ # Combine options (specific log level, custom tools and prompts)
302
+ uv run src/core/server.py --transport streamable-http --log-level DEBUG --tools app,events
303
+ ```
304
+
305
+ **Key Features of Streamable HTTP Mode:**
306
+ - Uses HTTP headers for authentication (no environment variables needed)
307
+ - Supports different credentials per request
308
+ - Better suited for shared environments
309
+ - Default port: 8080
310
+ - Endpoint: `http://0.0.0.0:8080/mcp/`
311
+
312
+ ### Starting in Stdio Mode
313
+
314
+ **Stdio mode** uses standard input/output for communication and requires environment variables for authentication.
315
+
316
+ #### Using CLI (PyPI Installation)
317
+
318
+ ```bash
319
+ # Set environment variables first
320
+ export INSTANA_BASE_URL="https://your-instana-instance.instana.io"
321
+ export INSTANA_API_TOKEN="your_instana_api_token"
322
+
323
+ # Start the server (stdio is the default if no transport specified)
324
+ mcp-instana
325
+
326
+ # Or explicitly specify stdio mode
327
+ mcp-instana --transport stdio
328
+ ```
329
+
330
+ #### Using Development Installation
331
+
332
+ ```bash
333
+ # Set environment variables first
334
+ export INSTANA_BASE_URL="https://your-instana-instance.instana.io"
335
+ export INSTANA_API_TOKEN="your_instana_api_token"
336
+
337
+ # Start the server (stdio is the default if no transport specified)
338
+ uv run src/core/server.py
339
+
340
+ # Or explicitly specify stdio mode
341
+ uv run src/core/server.py --transport stdio
342
+ ```
343
+
344
+ **Key Features of Stdio Mode:**
345
+ - Uses environment variables for authentication
346
+ - Direct communication via stdin/stdout
347
+ - Required for certain MCP client configurations
348
+
349
+ ### Tool Categories
350
+
351
+ You can optimize server performance by enabling only the tools and prompts categories you need:
352
+
353
+ #### Using CLI (PyPI Installation)
354
+
355
+ ```bash
356
+ # List all available categories
357
+ mcp-instana --list-tools
358
+
359
+ # Enable specific categories
360
+ mcp-instana --transport streamable-http --tools infra,app
361
+ mcp-instana --transport streamable-http --tools events
362
+ ```
363
+
364
+ #### Using Development Installation
365
+
366
+ ```bash
367
+ # List all available categories
368
+ uv run src/core/server.py --list-tools
369
+
370
+ # Enable specific categories
371
+ uv run src/core/server.py --transport streamable-http --tools infra,app
372
+ uv run src/core/server.py --transport streamable-http --tools events
373
+ ```
374
+
375
+ **Available Categories:**
376
+ - **`infra`**: Infrastructure monitoring tools and prompts (resources, catalog, topology, analyze, metrics)
377
+ - **`app`**: Application performance tools and prompts (resources, metrics, alerts, catalog, topology, analyze, settings, global alerts)
378
+ - **`events`**: Event monitoring tools and prompts (Kubernetes events, agent monitoring)
379
+ - **`automation`**: Automation-related tools and prompts (action catalog, action history)
380
+ - **`website`**: Website monitoring tools and prompts (metrics, catalog, analyze, configuration)
381
+
382
+ ### Verifying Server Status
383
+
384
+ Once started, you can verify the server is running:
385
+
386
+ **For Streamable HTTP mode:**
387
+ ```bash
388
+ # Check server health
389
+ curl http://0.0.0.0:8080/mcp/
390
+
391
+ # Or with custom port
392
+ curl http://0.0.0.0:9000/mcp/
393
+ ```
394
+
395
+ **For Stdio mode:**
396
+ The server will start and wait for stdin input from MCP clients.
397
+
398
+ ### Common Startup Issues
399
+
400
+ **Certificate Issues:**
401
+ If you encounter SSL certificate errors, ensure your Python environment has access to system certificates:
402
+ ```bash
403
+ # macOS - Install certificates for Python
404
+ /Applications/Python\ 3.13/Install\ Certificates.command
405
+ ```
406
+
407
+ **Port Already in Use:**
408
+ If port 8080 is already in use, specify a different port:
409
+ ```bash
410
+ uv run src/core/server.py --transport streamable-http --port 9000
411
+ ```
412
+
413
+ **Missing Dependencies:**
414
+ Ensure all dependencies are installed:
415
+ ```bash
416
+ uv sync
417
+ ```
418
+
419
+ ## Setup and Usage
420
+
421
+ ### Claude Desktop
422
+
423
+ Claude Desktop supports both Streamable HTTP and Stdio modes for MCP integration.
424
+
425
+ Configure Claude Desktop by editing the configuration file:
426
+
427
+ **File Locations:**
428
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
429
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
430
+
431
+ #### Streamable HTTP Mode
432
+
433
+ The Streamable HTTP mode provides a REST API interface for MCP communication using JSON-RPC over HTTP.
434
+
435
+ **Step 1: Start the MCP Server in Streamable HTTP Mode**
436
+
437
+ Before configuring Claude Desktop, you need to start the MCP server in Streamable HTTP mode. Please refer to the [Starting the Local MCP Server](#starting-the-local-mcp-server) section for detailed instructions.
438
+
439
+ **Step 2: Configure Claude Desktop**
440
+
441
+ Configure Claude Desktop to pass Instana credentials via headers:
442
+
443
+ ```json:claude_desktop_config.json
444
+ {
445
+ "mcpServers": {
446
+ "Instana MCP Server": {
447
+ "command": "npx",
448
+ "args": [
449
+ "mcp-remote", "http://0.0.0.0:8080/mcp/",
450
+ "--allow-http",
451
+ "--header", "instana-base-url: https://your-instana-instance.instana.io",
452
+ "--header", "instana-api-token: your_instana_api_token"
453
+ ]
454
+ }
455
+ }
456
+ }
457
+ ```
458
+
459
+ **Note:** To use npx, we recommend first installing NVM (Node Version Manager), then using it to install Node.js.
460
+ Installation instructions are available at: https://nodejs.org/en/download
461
+
462
+ **Step 3: Test the Connection**
463
+
464
+ Restart Claude Desktop. You should now see Instana MCP Server in the Claude Desktop interface as shown below:
465
+
466
+ ![](./images/claudeTools.png)
467
+
468
+ You can now run queries in Claude Desktop:
469
+
470
+ ```
471
+ get me all endpoints from Instana
472
+ ```
473
+ ![](./images/claudeResponse.png)
474
+
475
+ #### Stdio Mode
476
+
477
+ **Configuration using CLI (PyPI Installation - Recommended):**
478
+
479
+ ```json
480
+ {
481
+ "mcpServers": {
482
+ "Instana MCP Server": {
483
+ "command": "mcp-instana",
484
+ "args": ["--transport", "stdio"],
485
+ "env": {
486
+ "INSTANA_BASE_URL": "https://your-instana-instance.instana.io",
487
+ "INSTANA_API_TOKEN": "your_instana_api_token"
488
+ }
489
+ }
490
+ }
491
+ }
492
+ ```
493
+
494
+ **Note:** If you encounter "command not found" errors, use the full path to mcp-instana. Find it with `which mcp-instana` and use that path instead.
495
+
496
+ **Configuration using Development Installation:**
497
+
498
+ ```json
499
+ {
500
+ "mcpServers": {
501
+ "Instana MCP Server": {
502
+ "command": "uv",
503
+ "args": [
504
+ "--directory",
505
+ "<path-to-mcp-instana-folder>",
506
+ "run",
507
+ "src/core/server.py"
508
+ ],
509
+ "env": {
510
+ "INSTANA_BASE_URL": "https://your-instana-instance.instana.io",
511
+ "INSTANA_API_TOKEN": "your_instana_api_token"
512
+ }
513
+ }
514
+ }
515
+ }
516
+ ```
517
+
518
+ ### GitHub Copilot
519
+
520
+ GitHub Copilot supports MCP integration through VS Code configuration.
521
+ For GitHub Copilot integration with VS Code, refer to this [setup guide](https://code.visualstudio.com/docs/copilot/setup).
522
+
523
+ #### Streamable HTTP Mode
524
+
525
+ **Step 1: Start the MCP Server in Streamable HTTP Mode**
526
+
527
+ Before configuring VS Code, you need to start the MCP server in Streamable HTTP mode. Please refer to the [Starting the Local MCP Server](#starting-the-local-mcp-server) section for detailed instructions.
528
+
529
+ **Step 2: Configure VS Code**
530
+
531
+ Refer to [Use MCP servers in VS Code](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) for detailed configuration.
532
+
533
+ You can directly create or update `.vscode/mcp.json` with the following configuration:
534
+
535
+ ```json:.vscode/mcp.json
536
+ {
537
+ "servers": {
538
+ "Instana MCP Server": {
539
+ "command": "npx",
540
+ "args": [
541
+ "mcp-remote", "http://0.0.0.0:8080/mcp/",
542
+ "--allow-http",
543
+ "--header", "instana-base-url: https://your-instana-instance.instana.io",
544
+ "--header", "instana-api-token: your_instana_api_token"
545
+ ],
546
+ "env": {
547
+ "PATH": "/usr/local/bin:/bin:/usr/bin",
548
+ "SHELL": "/bin/sh"
549
+ }
550
+ }
551
+ }
552
+ }
553
+ ```
554
+
555
+ **Note:** Replace the following values with your actual configuration:
556
+ - `instana-base-url`: Your Instana instance URL
557
+ - `instana-api-token`: Your Instana API token
558
+ - `command`: Update the npx path to match your system's Node.js installation (e.g., `/path/to/your/node/bin/npx`)
559
+ - Environment variables: Adjust PATH and other environment variables as needed for your system
560
+
561
+
562
+ #### Stdio Mode
563
+
564
+ **Step 1: Create VS Code MCP Configuration**
565
+
566
+ **Using CLI (PyPI Installation - Recommended):**
567
+
568
+ Create `.vscode/mcp.json` in your project root:
569
+
570
+ ```json:.vscode/mcp.json
571
+ {
572
+ "servers": {
573
+ "Instana MCP Server": {
574
+ "command": "mcp-instana",
575
+ "args": ["--transport", "stdio"],
576
+ "env": {
577
+ "INSTANA_BASE_URL": "https://your-instana-instance.instana.io",
578
+ "INSTANA_API_TOKEN": "your_instana_api_token"
579
+ }
580
+ }
581
+ }
582
+ }
583
+ ```
584
+
585
+ **Using Development Installation:**
586
+
587
+ Create `.vscode/mcp.json` in your project root:
588
+
589
+ ```json:.vscode/mcp.json
590
+ {
591
+ "servers": {
592
+ "Instana MCP Server": {
593
+ "command": "uv",
594
+ "args": [
595
+ "--directory",
596
+ "/absolute/path/to/your/project/mcp-instana",
597
+ "run",
598
+ "src/core/server.py"
599
+ ],
600
+ "env": {
601
+ "INSTANA_BASE_URL": "https://your-instana-instance.instana.io",
602
+ "INSTANA_API_TOKEN": "your_instana_api_token"
603
+ }
604
+ }
605
+ }
606
+ }
607
+ ```
608
+
609
+ **Note:** Replace the following values with your actual configuration:
610
+ - For CLI installation: Ensure `mcp-instana` is in your PATH
611
+ - For development installation:
612
+ - `command`: Update the uv path to match your system's uv installation (e.g., `/path/to/your/uv/bin/uv` or `/usr/local/bin/uv`)
613
+ - `--directory`: Update with the absolute path to your mcp-instana project directory
614
+ - `INSTANA_BASE_URL`: Your Instana instance URL
615
+ - `INSTANA_API_TOKEN`: Your Instana API token
616
+
617
+ **Step 2: Manage Server in VS Code**
618
+
619
+ 1. **Open `.vscode/mcp.json`** - you'll see server management controls at the top
620
+ 2. **Click `Start`** next to `Instana MCP Server` to start the server
621
+ 3. Running status along with the number of tools indicates the server is running
622
+
623
+ **Step 3: Test Integration**
624
+
625
+ Switch to Agent Mode in GitHub Copilot and reload tools.
626
+ Here is an example of a GitHub Copilot response:
627
+
628
+ ![GitHub Copilot Response](./images/copilotResponse.png)
629
+
630
+ ## Supported Features
631
+
632
+ - [ ] Application
633
+ - [ ] Application Metrics
634
+ - [ ] Application Metrics
635
+ - [ ] Endpoint Metrics
636
+ - [ ] Service Metrics
637
+ - [ ] Data Metrics
638
+ - [x] Application Resources
639
+ - [x] Get Applications Endpoints
640
+ - [x] Get Applications
641
+ - [x] Get Services
642
+ - [x] Get Application Services
643
+ - [x] Application Alert Configuration
644
+ - [x] Get All Smart Alert Configurations
645
+ - [x] Get Smart Alert Configuration
646
+ - [x] Get Smart Alert Config Versions
647
+ - [ ] Create Smart Alert Configuration
648
+ - [ ] Update Smart Alert Configuration
649
+ - [x] Delete Smart Alert Configuration
650
+ - [ ] Recalculate Smart Alert Config Baseline
651
+ - [x] Enable Application Alert Config
652
+ - [x] Disable Smart Alert Config
653
+ - [x] Restore Smart Alert Config
654
+ - [ ] Infrastructure
655
+ - [ ] Infrastructure Analyze
656
+ - [x] Get Available Metrics
657
+ - [ ] Get infrastructure entities
658
+ - [ ] Get grouped entities with aggregated metrics
659
+ - [x] Get available plugins/entity types
660
+ - [x] Infrastructure Catalog
661
+ - [x] Get Payload Keys By plugin ID
662
+ - [x] Get Infrastructure Catalog Metrics
663
+ - [x] Get Infrastructure Catalog Plugins
664
+ - [x] Get Infrastructure Catalog Plugins with Custom Metrics
665
+ - [x] Get Infrastructure Catalog Search Fields
666
+ - [x] Get Infrastructure Catalog Search Fields with Custom Metrics
667
+ - [x] Get Tag Catalog
668
+ - [x] Get Tag Catalog ALL
669
+ - [ ] Infrastructure Resources
670
+ - [x] Get Monitoring State
671
+ - [ ] Get plugin Payload
672
+ - [x] Search Snapshots
673
+ - [x] Get Snapshot Details for single Snapshot ID
674
+ - [x] Get Details for Multiple Snapshot IDs
675
+ - [x] Software Versions
676
+ - [x] Infrastructure Topology
677
+ - [x] Get Hosts for Snapshot
678
+ - [x] Get Topology
679
+ - [x] Events
680
+ - [x] Events
681
+ - [x] Get Event
682
+ - [x] Get Events by IDs
683
+ - [x] Get Agent Monitoring Events
684
+ - [x] Get Kubernetes Info Events
685
+ - [x] Get Issues
686
+ - [x] Get Incidents
687
+ - [x] Get Changes
688
+
689
+ ## Available Tools
690
+
691
+ | Tool | Category | Description |
692
+ |---------------------------------------------------------------|--------------------------------|------------------------------------------------------- |
693
+ | `get_application_metrics` | Application Metrics | Get ApplicationMetrics |
694
+ | `get_endpoints_metrics` | Application Metrics | Get Endpoint metrics |
695
+ | `get_services_metrics` | Application Metrics | Get Service metrics |
696
+ | `get_application_data_metrics_v2` | Application Metrics | Get Application Data Metrics |
697
+ | `get_applications` | Application Resources | Get applications |
698
+ | `get_application_services` | Application Resources | Get applications/services |
699
+ | `get_application_endpoints` | Application Resources | Get endpoints |
700
+ | `get_services` | Application Resources | Get services |
701
+ | `get_monitoring_state` | Infrastructure Resources | Monitored host count |
702
+ | `get_plugin_payload` | Infrastructure Resources | Get a payload for a snapshot |
703
+ | `get_snapshots` | Infrastructure Resources | Search snapshots |
704
+ | `post_snapshots` | Infrastructure Resources | Get snapshot details for multiple snapshots |
705
+ | `get_snapshot` | Infrastructure Resources | Get snapshot details |
706
+ | `software_versions` | Infrastructure Resources | Get installed software |
707
+ | `get_available_payload_keys_by_plugin_id` | Infrastructure Catalog | Get Payload Keys By plugin ID |
708
+ | `get_infrastructure_catalog_metrics` | Infrastructure Catalog | Get Infrastructure Catalog Metrics |
709
+ | `get_infrastructure_catalog_plugins` | Infrastructure Catalog | Get Infrastructure Catalog Plugins |
710
+ | `get_infrastructure_catalog_plugins_with_custom_metrics` | Infrastructure Catalog | Get Infrastructure Catalog Plugins with Custom Metrics |
711
+ | `get_infrastructure_catalog_search_fields` | Infrastructure Catalog | Get Infrastructure Catalog Search Fields |
712
+ | `get_tag_catalog` | Infrastructure Catalog | Get Tag Catalog |
713
+ | `get_tag_catalog_all` | Infrastructure Catalog | Get Tag Catalog ALL |
714
+ | `get_related_hosts` | Infrastructure Topology | Get Related Hosts |
715
+ | `get_topology` | Infrastructure Topology | Get Topology |
716
+ | `get_available_metrics` | Infrastructure Analyze | Get Available Metrics |
717
+ | `get_entities` | Infrastructure Analyze | Get infrastructure entities |
718
+ | `get_aggregated_entity_groups` | Infrastructure Analyze | Get grouped entities with aggregated metrics |
719
+ | `get_available_plugins` | Infrastructure Analyze | Get available entity types |
720
+ | `get_application_alert_configs` | Application Alert Configuration| Get All Smart Alert Configurations |
721
+ | `find_application_alert_config` | Application Alert Configuration| Get Smart Alert Configuration |
722
+ | `find_application_alert_config_versions` | Application Alert Configuration| Get Smart Alert Config Versions |
723
+ | `create_application_alert_config` | Application Alert Configuration| Create Smart Alert Configuration |
724
+ | `update_application_alert_config` | Application Alert Configuration| Update Smart Alert Configuration |
725
+ | `delete_application_alert_config` | Application Alert Configuration| Delete Smart Alert Configuration |
726
+ | `update_application_historic_baseline` | Application Alert Configuration| Recalculate Smart Alert Config Baseline |
727
+ | `enable_application_alert_config` | Application Alert Configuration| Enable Application Alert Config |
728
+ | `disable_application_alert_config` | Application Alert Configuration| Disable Smart Alert Config |
729
+ | `restore_application_alert_config` | Application Alert Configuration| Restore Smart Alert Config |
730
+ | `get_event` | Events | Get Specific Event by ID |
731
+ | `get_kubernetes_info_events` | Events | Get Kubernetes Info Events |
732
+ | `get_agent_monitoring_events` | Events | Get Agent Monitoring Events |
733
+ | `get_issues` | Events | Get Issues |
734
+ | `get_incidents` | Events | Get Incidents |
735
+ | `get_changes` | Events | Get Changes |
736
+ | `get_events_by_ids` | Events | Get Events by IDs |
737
+
738
+
739
+ ## Tool Filtering
740
+
741
+ The MCP server supports selective tool loading to optimize performance and reduce resource usage. You can enable only the tool categories you need for your specific use case.
742
+
743
+ ### Available Tool Categories
744
+
745
+ - **`infra`**: Infrastructure monitoring tools
746
+ - Infrastructure Resources: Host monitoring, snapshot management, software inventory
747
+ - Infrastructure Catalog: Plugin metadata, metrics definitions, tag management
748
+ - Infrastructure Topology: Host relationships and system topology visualization
749
+ - Infrastructure Analyze: Entity metrics, aggregation, and plugin discovery
750
+ - Infrastructure Metrics: Performance data collection
751
+
752
+ - **`app`**: Application performance tools
753
+ - Application Resources: Service and endpoint discovery
754
+ - Application Metrics: Performance measurement across application components
755
+ - Application Alert Configuration: Smart alert management
756
+ - Application Catalog: Metadata and definitions
757
+ - Application Topology: Service dependency mapping
758
+ - Application Analyze: Application performance analysis
759
+ - Application Settings: Configuration management
760
+ - Application Global Alert: Global alert management
761
+
762
+ - **`events`**: Event monitoring tools
763
+ - Events: Kubernetes events, agent monitoring, incidents, issues, changes and system event tracking
764
+
765
+ - **`automation`**: Automation-related tools
766
+ - Action Catalog: Automation action discovery and management
767
+ - Action History: Tracking and managing automation action history
768
+
769
+ - **`website`**: Website monitoring tools
770
+ - Website Metrics: Performance measurement for websites
771
+ - Website Catalog: Website metadata and definitions
772
+ - Website Analyze: Website performance analysis
773
+ - Website Configuration: Website configuration management
774
+
775
+ ### Usage Examples
776
+
777
+ #### Using CLI (PyPI Installation)
778
+
779
+ ```bash
780
+ # Enable only infrastructure and events tools
781
+ mcp-instana --tools infra,events --transport streamable-http
782
+
783
+ # Enable only application tools
784
+ mcp-instana --tools app --transport streamable-http
785
+
786
+ # Enable automation and website tools
787
+ mcp-instana --tools automation,website --transport streamable-http
788
+
789
+ # Enable all tools (default behavior)
790
+ mcp-instana --transport streamable-http
791
+
792
+ # List all available tool categories and their tools
793
+ mcp-instana --list-tools
794
+ ```
795
+
796
+ #### Using Development Installation
797
+
798
+ ```bash
799
+ # Enable only infrastructure and events tools
800
+ uv run src/core/server.py --tools infra,events --transport streamable-http
801
+
802
+ # Enable only application tools
803
+ uv run src/core/server.py --tools app --transport streamable-http
804
+
805
+ # Enable automation and website tools
806
+ uv run src/core/server.py --tools automation,website --transport streamable-http
807
+
808
+ # Enable all tools (default behavior)
809
+ uv run src/core/server.py --transport streamable-http
810
+
811
+ # List all available tool categories and their tools
812
+ uv run src/core/server.py --list-tools
813
+ ```
814
+
815
+ ### Benefits of Tool Filtering
816
+
817
+ - **Performance**: Reduced startup time and memory usage
818
+ - **Security**: Limit exposure to only necessary APIs
819
+ - **Clarity**: Focus on specific use cases (e.g., only infrastructure monitoring)
820
+ - **Resource Efficiency**: Lower CPU and network usage
821
+
822
+ ## Example Prompts
823
+
824
+ Here are some example prompts (with their corresponding results) that you can use to get started with the Instana Observability Platform API:
825
+
826
+ - **Query 1**
827
+ ```
828
+ We want to understand what search criteria are available in Instana so that
829
+ we can find the correct search tags for specific entities and
830
+ build complex queries to filter entities in Instana. Can you help with this?
831
+ ```
832
+
833
+ - **Result 1**
834
+ ```
835
+ Here is the list of search criteria available in Instana:
836
+
837
+ entity.jvm.dropwizard.timer
838
+ entity.otel
839
+ host.name
840
+ entity.dropwizard.meter
841
+ entity.springboot.name
842
+ entity.kubernetes.node.name
843
+ entity.tuxedoapp.tuxedoService.name
844
+ entity.ace.integrationServer.name
845
+ entity.containerd.containerIdentity.tuxedo.domain.tuxconfig
846
+ entity.host.mac
847
+ ```
848
+
849
+ - **Query 2**
850
+ ```
851
+ Our application deployments seem to be failing intermittently.
852
+ Can you fetch recent Kubernetes info events from Instana for the last 1 day
853
+ to help identify what might be causing these deployment issues?
854
+ ```
855
+
856
+ - **Result 2**
857
+ ![Kubernetes Events](./images/kubernetesEvents.png)
858
+
859
+ - **Query 3**
860
+ ```
861
+ We are seeing errors in agent logs and experiencing issues with agent behavior.
862
+ Can you fetch recent agent monitoring events from Instana
863
+ to help figure out what might be causing these issues?
864
+ ```
865
+
866
+ - **Result 3**
867
+ ```
868
+ The recent agent monitoring events from Instana indicate that there are several issues with the agent behavior, including:
869
+
870
+ JVM attach generic issues: There are 36 events related to JVM attach generic issues, affecting multiple entities such as Process (/etc/java-8-64bit-jdk/jdk8u402-b06/bin/java), Process (/etc/java-16-64bit-jdk/jdk-16.0.2+7/bin/java), and others.
871
+ Python sensor not installed: There are 7 events related to Python sensor not installed issues, affecting entities such as Process (/usr/bin/python3), Process (/usr/libexec/platform-python), and others.
872
+ PostgreSQL authentication failed: There are 2 events related to PostgreSQL authentication failed issues, affecting entities such as PostgreSQL DB (PostgreSQL) and PostgreSQL DB (PostgreSQL @5432).
873
+ PostgreSQL connection failed: There is 1 event related to PostgreSQL connection failed issues, affecting the entity PostgreSQL DB (PostgreSQL @5432).
874
+ Spring Boot actuator not configured: There is 1 event related to Spring Boot actuator not configured issues, affecting the entity Spring Boot App (sqs-demo-application 0.0.1).
875
+ These issues may be causing the errors in the agent logs and affecting the agent behavior. It is recommended to investigate and resolve these issues to ensure proper agent functionality.
876
+ ```
877
+
878
+ - **Query 4**
879
+ ```
880
+ We're setting up comprehensive application performance monitoring across our entire infrastructure.
881
+ Can you retrieve all the applications that Instana has discovered? I need to see which applications are available
882
+ so I can configure monitoring dashboards, set up alerts, and establish performance baselines for each service in our environment.
883
+ ```
884
+
885
+ - **Result 4**
886
+ ```
887
+ The discovered applications are:
888
+
889
+ Ovcharov
890
+ AWS Resources
891
+ Cedric OTel
892
+ Cedric Sein Otel
893
+ Col
894
+ Damian - Sample Go App
895
+ Fofo
896
+ INSTANA-ECOSYSTEM-SAP-CF
897
+ Kate
898
+ ```
899
+
900
+ - **Query 5**
901
+ ```
902
+ We're investigating an issue for the snapshot id "qjNuS6pmtYkxCBKwqsfxvHylisU" and
903
+ want to see which hosts might be affected. Can you get the hosts for this snapshot id?
904
+ ```
905
+
906
+ - **Result 5**
907
+ ```
908
+ The hosts related to the snapshot with ID "qjNuS6pmtYkxCBKwqsfxvHylisU" are:
909
+
910
+ XDrSHZ5iq0BV_bPxQ6FFGsbxqv4
911
+ There is 1 host related to this snapshot.
912
+ ```
913
+
914
+ - **Query 6**
915
+ ```
916
+ We want to get specific metrics for Amazon MQ in Instana. Can you show all possible tags
917
+ I can use for the plugin awsMq?
918
+ ```
919
+
920
+ - **Result 6**
921
+ ```
922
+ The following tags are available for the plugin "awsMq":
923
+
924
+ aws.accountId
925
+ aws.arn
926
+ aws.mq.brokerName
927
+ aws.mq.deploymentMode
928
+ aws.mq.engineVersion
929
+ aws.mq.instanceType
930
+ dfq.selftype
931
+ dfq.type
932
+ label
933
+ metricId
934
+ type
935
+ zone
936
+ These tags can be used to filter and group metrics for Amazon MQ in Instana.
937
+ ```
938
+
939
+ - **Query 7**
940
+ ```
941
+ We want to troubleshoot issues with custom metric collection, hence need details of the
942
+ plugins which are configured with custom metrics in Instana. Can you help us get the details?
943
+ ```
944
+
945
+ - **Result 7**
946
+ ```
947
+ JVM and OpenTelemetry SDK. The JVM plugin is identified by the label "JVM" and the plugin ID "jvmRuntimePlatform".
948
+ The OpenTelemetry SDK plugin is identified by the label "OpenTelemetry SDK" and the plugin ID "openTelemetry".
949
+ ```
950
+
951
+ - **Query 8**
952
+ ```
953
+ We want to see what kind of systems Instana is tracking. We want to explore the monitoring
954
+ capabilities of our Instana installation. Please give me the list of monitored entity types.
955
+ ```
956
+
957
+ - **Result 8**
958
+ ```
959
+ The list includes various plugins such as businessActivity, azureManagedHSM, kafkaConnectWorker, and many more.
960
+ The total number of available plugins is 395, but only the first 50 are shown in the output.
961
+ ```
962
+
963
+ - **Query 9**
964
+ ```
965
+ We're having performance issues with our db2Database. What payload keys are available for the
966
+ db2Database plugin so I can access detailed monitoring data?
967
+ ```
968
+
969
+ - **Result 9**
970
+ ```
971
+ The available payload keys for the db2Database plugin are:
972
+
973
+ tableSpaceNamesSense
974
+ topqueries
975
+ diaglogentries
976
+ dbConfig
977
+ dbmConfig
978
+ lockWaits
979
+ runstats
980
+ dbutilities
981
+ toptotalstmts
982
+ idlogdiskwait
983
+ idhadrstats
984
+ reorgtablesize
985
+ ```
986
+
987
+ - **Query 10**
988
+ ```
989
+ We have SLAs for our cryptographic services. What Azure Managed HSM metrics can help
990
+ monitor service levels using the azureManagedHSM plugin?
991
+ ```
992
+
993
+ - **Result 10**
994
+ ```
995
+ The azureManagedHSM plugin provides three metrics that can help monitor service levels for cryptographic services:
996
+ 1. Total Service Api Hits: This metric measures the total number of API hits for the service.
997
+ 2. Overall Service Api Latency: This metric measures the overall latency of service API requests.
998
+ 3. Overall Service Availability: This metric measures the availability of the service.
999
+ ```
1000
+
1001
+ ## Docker Deployment
1002
+
1003
+ The MCP Instana server can be deployed using Docker for production environments. The Docker setup is optimized for security, performance, and minimal resource usage.
1004
+
1005
+ ### Docker Architecture
1006
+
1007
+ The project uses a **two-file dependency management strategy**:
1008
+
1009
+ #### **pyproject.toml** (Development)
1010
+ - **Purpose**: Full development environment with all tools
1011
+ - **Dependencies**: 20 essential + 8 development dependencies (pytest, ruff, coverage, etc.)
1012
+ - **Usage**: Local development, testing, and CI/CD
1013
+ - **Size**: Larger but includes all development tools
1014
+
1015
+ #### **pyproject-runtime.toml** (Production)
1016
+ - **Purpose**: Minimal production runtime dependencies only
1017
+ - **Dependencies**: 20 essential dependencies only
1018
+ - **Usage**: Docker production builds
1019
+ - **Size**: Optimized for minimal image size and security
1020
+
1021
+ ### Building the Docker Image
1022
+
1023
+ #### **Prerequisites**
1024
+ - Docker installed and running
1025
+ - Access to the project source code
1026
+
1027
+ #### **Build Command**
1028
+ ```bash
1029
+ # Build the optimized production image
1030
+ docker build -t mcp-instana .
1031
+
1032
+ # Build with a specific tag
1033
+ docker build -t mcp-instana:v1.0.0 .
1034
+ ```
1035
+
1036
+ #### **What the Build Does**
1037
+ 1. **Multi-stage build** for optimal size and security
1038
+ 2. **Builder stage**: Installs only runtime dependencies from `pyproject-runtime.toml`
1039
+ 3. **Runtime stage**: Creates minimal production image with non-root user
1040
+ 4. **Security**: No hardcoded secrets, proper user permissions
1041
+ 5. **Optimization**: Only essential dependencies (20 vs 95+ in development)
1042
+
1043
+ ### Running the Docker Container
1044
+
1045
+ #### **Basic Usage**
1046
+ ```bash
1047
+ # Run with environment variables (recommended)
1048
+ docker run -p 8080:8080 \
1049
+ -e INSTANA_API_TOKEN=your_instana_token \
1050
+ -e INSTANA_BASE_URL=https://your-instana-instance.instana.io \
1051
+ mcp-instana
1052
+
1053
+ # Run with custom port
1054
+ docker run -p 8081:8080 \
1055
+ -e INSTANA_API_TOKEN=your_instana_token \
1056
+ -e INSTANA_BASE_URL=https://your-instana-instance.instana.io \
1057
+ mcp-instana
1058
+ ```
1059
+
1060
+ #### **Environment Variables**
1061
+ The container requires the following environment variables:
1062
+
1063
+ | Variable | Description | Example |
1064
+ |----------|-------------|---------|
1065
+ | `INSTANA_API_TOKEN` | Your Instana API token | `your_instana_token` |
1066
+ | `INSTANA_BASE_URL` | Your Instana instance URL | `https://your-instana-instance.instana.io` |
1067
+ | `PORT` | Server port (optional, defaults to 8080) | `8080` |
1068
+
1069
+ #### **Docker Compose Example**
1070
+ ```yaml
1071
+ version: '3.8'
1072
+ services:
1073
+ mcp-instana:
1074
+ build: .
1075
+ ports:
1076
+ - "8080:8080"
1077
+ environment:
1078
+ - INSTANA_API_TOKEN=${INSTANA_API_TOKEN}
1079
+ - INSTANA_BASE_URL=${INSTANA_BASE_URL}
1080
+ restart: unless-stopped
1081
+ healthcheck:
1082
+ test: ["CMD", "python", "-c", "import requests; requests.get('http://127.0.0.1:8080/health', timeout=5)"]
1083
+ interval: 30s
1084
+ timeout: 10s
1085
+ retries: 3
1086
+ start_period: 40s
1087
+ ```
1088
+
1089
+ ### Docker Security Features
1090
+
1091
+ #### **Security Best Practices Implemented**
1092
+ - ✅ **Non-root user**: Container runs as `mcpuser` (not root)
1093
+ - ✅ **No hardcoded secrets**: All credentials passed via environment variables
1094
+ - ✅ **Minimal dependencies**: Only 20 essential runtime dependencies
1095
+ - ✅ **Multi-stage build**: Build tools don't make it to final image
1096
+ - ✅ **Health checks**: Built-in container health monitoring
1097
+ - ✅ **Optimized base image**: Uses `python:3.11-slim`
1098
+
1099
+ #### **Image Size Optimization**
1100
+ - **Original approach**: 95+ dependencies → ~1-2GB+ image
1101
+ - **Optimized approach**: 20 dependencies → ~266MB image
1102
+ - **Size reduction**: ~70-80% smaller images
1103
+ - **Benefits**: Faster deployments, lower storage costs, reduced attack surface
1104
+
1105
+ ### Testing the Docker Container
1106
+
1107
+ #### **Health Check**
1108
+ ```bash
1109
+ # Check if container is healthy
1110
+ docker ps
1111
+
1112
+ # Test the MCP endpoint
1113
+ curl http://localhost:8080/mcp/
1114
+ ```
1115
+
1116
+ #### **MCP Inspector Testing**
1117
+ ```bash
1118
+ # Test with MCP Inspector
1119
+ npx @modelcontextprotocol/inspector http://localhost:8080/mcp/
1120
+ ```
1121
+
1122
+ #### **Logs and Debugging**
1123
+ ```bash
1124
+ # View container logs
1125
+ docker logs <container_id>
1126
+
1127
+ # Follow logs in real-time
1128
+ docker logs -f <container_id>
1129
+
1130
+ # Execute commands in running container
1131
+ docker exec -it <container_id> /bin/bash
1132
+ ```
1133
+
1134
+ ### Production Deployment
1135
+
1136
+ #### **Recommended Production Setup**
1137
+ 1. **Use environment variables** for all secrets
1138
+ 2. **Set up proper logging** and monitoring
1139
+ 3. **Configure health checks** for container orchestration
1140
+ 4. **Use container orchestration** (Kubernetes, Docker Swarm, etc.)
1141
+ 5. **Implement proper backup** and disaster recovery
1142
+
1143
+ #### **Kubernetes Example**
1144
+ ```yaml
1145
+ apiVersion: apps/v1
1146
+ kind: Deployment
1147
+ metadata:
1148
+ name: mcp-instana
1149
+ spec:
1150
+ replicas: 2
1151
+ selector:
1152
+ matchLabels:
1153
+ app: mcp-instana
1154
+ template:
1155
+ metadata:
1156
+ labels:
1157
+ app: mcp-instana
1158
+ spec:
1159
+ containers:
1160
+ - name: mcp-instana
1161
+ image: mcp-instana:latest
1162
+ ports:
1163
+ - containerPort: 8080
1164
+ env:
1165
+ - name: INSTANA_API_TOKEN
1166
+ valueFrom:
1167
+ secretKeyRef:
1168
+ name: instana-secrets
1169
+ key: api-token
1170
+ - name: INSTANA_BASE_URL
1171
+ value: "https://your-instana-instance.instana.io"
1172
+ livenessProbe:
1173
+ httpGet:
1174
+ path: /health
1175
+ port: 8080
1176
+ initialDelaySeconds: 30
1177
+ periodSeconds: 10
1178
+ readinessProbe:
1179
+ httpGet:
1180
+ path: /health
1181
+ port: 8080
1182
+ initialDelaySeconds: 5
1183
+ periodSeconds: 5
1184
+ ```
1185
+
1186
+ ## Troubleshooting
1187
+
1188
+ ### **Docker Issues**
1189
+
1190
+ #### **Container Won't Start**
1191
+ ```bash
1192
+ # Check container logs
1193
+ docker logs <container_id>
1194
+
1195
+ # Common issues:
1196
+ # 1. Missing environment variables
1197
+ # 2. Port already in use
1198
+ # 3. Invalid Instana credentials
1199
+ ```
1200
+
1201
+ #### **Connection Issues**
1202
+ ```bash
1203
+ # Test container connectivity
1204
+ docker exec -it <container_id> curl http://127.0.0.1:8080/health
1205
+
1206
+ # Check port mapping
1207
+ docker port <container_id>
1208
+ ```
1209
+
1210
+ #### **Performance Issues**
1211
+ ```bash
1212
+ # Check container resource usage
1213
+ docker stats <container_id>
1214
+
1215
+ # Monitor container health
1216
+ docker inspect <container_id> | grep -A 10 Health
1217
+ ```
1218
+
1219
+ ### **General Issues**
1220
+
1221
+ - **GitHub Copilot**
1222
+ - If you encounter issues with GitHub Copilot, try starting/stopping/restarting the server in the `mcp.json` file and keep only one server running at a time.
1223
+
1224
+ - **Certificate Issues**
1225
+ - If you encounter certificate issues, such as `[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate`:
1226
+ - Check that you can reach the Instana API endpoint using `curl` or `wget` with SSL verification.
1227
+ - If that works, your Python environment may not be able to verify the certificate and might not have access to the same certificates as your shell or system. Ensure your Python environment uses system certificates (macOS). You can do this by installing certificates to Python:
1228
+ `//Applications/Python\ 3.13/Install\ Certificates.command`
1229
+ - If you cannot reach the endpoint with SSL verification, try without it. If that works, check your system's CA certificates and ensure they are up-to-date.