iflow-mcp_drdroidlab-grafana-mcp-server 0.1.0__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.
Files changed (32) hide show
  1. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/.gitignore +340 -0
  2. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/Dockerfile +33 -0
  3. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/LICENSE +21 -0
  4. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/MANIFEST.in +2 -0
  5. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/PKG-INFO +290 -0
  6. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/README.md +232 -0
  7. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/docker-compose.yml +20 -0
  8. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/glama.json +10 -0
  9. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/language.json +1 -0
  10. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/package_name +1 -0
  11. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/push_info.json +5 -0
  12. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/pyproject.toml +254 -0
  13. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/ruff.toml +60 -0
  14. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/src/__init__.py +0 -0
  15. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/src/grafana_mcp_server/__init__.py +0 -0
  16. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/src/grafana_mcp_server/config.yaml +19 -0
  17. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/src/grafana_mcp_server/mcp_server.py +643 -0
  18. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/src/grafana_mcp_server/processor/__init__.py +0 -0
  19. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/src/grafana_mcp_server/processor/grafana_processor.py +771 -0
  20. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/src/grafana_mcp_server/processor/processor.py +0 -0
  21. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/src/grafana_mcp_server/stdio_server.py +36 -0
  22. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/tests/__init__.py +0 -0
  23. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/tests/clients/__init__.py +0 -0
  24. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/tests/clients/grafana.py +196 -0
  25. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/tests/clients/openai.py +100 -0
  26. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/tests/conftest.py +155 -0
  27. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/tests/tools/__init__.py +0 -0
  28. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/tests/tools/test_grafana_processor.py +456 -0
  29. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/tests/tools/test_mcp_server_tools.py +680 -0
  30. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/tests/tools/test_openai_client.py +314 -0
  31. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/tests/utils.py +235 -0
  32. iflow_mcp_drdroidlab_grafana_mcp_server-0.1.0/uv.lock +614 -0
@@ -0,0 +1,340 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be added to the global gitignore or merged into this project gitignore. For a PyCharm
158
+ # project, it is recommended to include the following files:
159
+ # .idea/
160
+ # *.iml
161
+ # *.ipr
162
+ # *.iws
163
+ .idea/
164
+ *.iml
165
+ *.ipr
166
+ *.iws
167
+
168
+ # VS Code
169
+ .vscode/
170
+
171
+ # macOS
172
+ .DS_Store
173
+ .AppleDouble
174
+ .LSOverride
175
+
176
+ # Icon must end with two \r
177
+ Icon
178
+
179
+ # Thumbnails
180
+ ._*
181
+
182
+ # Files that might appear in the root of a volume
183
+ .DocumentRevisions-V100
184
+ .fseventsd
185
+ .Spotlight-V100
186
+ .TemporaryItems
187
+ .Trashes
188
+ .VolumeIcon.icns
189
+ .com.apple.timemachine.donotpresent
190
+
191
+ # Directories potentially created on remote AFP share
192
+ .AppleDB
193
+ .AppleDesktop
194
+ Network Trash Folder
195
+ Temporary Items
196
+ .apdisk
197
+
198
+ # Windows
199
+ Thumbs.db
200
+ Thumbs.db:encryptable
201
+ ehthumbs.db
202
+ ehthumbs_vista.db
203
+
204
+ # Dump file
205
+ *.stackdump
206
+
207
+ # Folder config file
208
+ [Dd]esktop.ini
209
+
210
+ # Recycle Bin used on file shares
211
+ $RECYCLE.BIN/
212
+
213
+ # Windows Installer files
214
+ *.cab
215
+ *.msi
216
+ *.msix
217
+ *.msm
218
+ *.msp
219
+
220
+ # Windows shortcuts
221
+ *.lnk
222
+
223
+ # Linux
224
+ *~
225
+
226
+ # temporary files which can be created if a process still has a handle open of a deleted file
227
+ .fuse_hidden*
228
+
229
+ # KDE directory preferences
230
+ .directory
231
+
232
+ # Linux trash folder which might appear on any partition or disk
233
+ .Trash-*
234
+
235
+ # .nfs files are created when an open file is removed but is still being accessed
236
+ .nfs*
237
+
238
+ # Docker
239
+ .dockerignore
240
+
241
+ # Logs
242
+ *.log
243
+ logs/
244
+
245
+ # Runtime data
246
+ pids
247
+ *.pid
248
+ *.seed
249
+ *.pid.lock
250
+
251
+ # Coverage directory used by tools like istanbul
252
+ coverage/
253
+ *.lcov
254
+
255
+ # nyc test coverage
256
+ .nyc_output
257
+
258
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
259
+ .grunt
260
+
261
+ # Bower dependency directory (https://bower.io/)
262
+ bower_components
263
+
264
+ # node_modules
265
+ node_modules/
266
+
267
+ # Optional npm cache directory
268
+ .npm
269
+ .ruff_cache/
270
+
271
+ # Optional eslint cache
272
+ .eslintcache
273
+
274
+ # Optional stylelint cache
275
+ .stylelintcache
276
+
277
+ # Microbundle cache
278
+ .rpt2_cache/
279
+ .rts2_cache_cjs/
280
+ .rts2_cache_es/
281
+ .rts2_cache_umd/
282
+
283
+ # Optional REPL history
284
+ .node_repl_history
285
+
286
+ # Output of 'npm pack'
287
+ *.tgz
288
+
289
+ # Yarn Integrity file
290
+ .yarn-integrity
291
+
292
+ # dotenv environment variable files
293
+ .env.development.local
294
+ .env.test.local
295
+ .env.production.local
296
+ .env.local
297
+
298
+ # parcel-bundler cache (https://parceljs.org/)
299
+ .cache
300
+ .parcel-cache
301
+
302
+ # Next.js build output
303
+ .next
304
+ out
305
+
306
+ # Nuxt.js build / generate output
307
+ .nuxt
308
+ dist
309
+
310
+ # Gatsby files
311
+ .cache/
312
+ public
313
+
314
+ # Storybook build outputs
315
+ .out
316
+ .storybook-out
317
+ storybook-static
318
+
319
+ # Temporary folders
320
+ tmp/
321
+ temp/
322
+
323
+ # Editor directories and files
324
+ .vscode/*
325
+ !.vscode/extensions.json
326
+ .idea
327
+ *.suo
328
+ *.ntvs*
329
+ *.njsproj
330
+ *.sln
331
+ *.sw?
332
+
333
+ # Local environment files
334
+ .env.local
335
+ .env.development.local
336
+ .env.test.local
337
+ .env.production.local
338
+
339
+ # Lock files (keep uv.lock as it's used for dependency management)
340
+ # uv.lock
@@ -0,0 +1,33 @@
1
+ # Dockerfile
2
+ FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ curl \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ # Copy pyproject.toml for dependency installation
13
+ COPY pyproject.toml .
14
+
15
+ # Create a basic uv.lock file (since we don't have one yet)
16
+ RUN uv lock
17
+
18
+ # Install Python dependencies using uv
19
+ RUN uv sync
20
+
21
+ # Copy application code
22
+ COPY ./src ./src
23
+
24
+ # Create a non-root user for security
25
+ RUN useradd -m -u 1000 mcp && chown -R mcp:mcp /app
26
+ USER mcp
27
+
28
+ # Expose the port
29
+ EXPOSE 8000
30
+
31
+ # Set PYTHONPATH and run as a module
32
+ ENV PYTHONPATH=/app
33
+ ENTRYPOINT ["uv", "run", "-m", "src.grafana_mcp_server.mcp_server"]
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Doctor Droid
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ include README.md
2
+ include LICENSE
@@ -0,0 +1,290 @@
1
+ Metadata-Version: 2.4
2
+ Name: iflow-mcp_drdroidlab-grafana-mcp-server
3
+ Version: 0.1.0
4
+ Summary: MCP Server for Grafana API integration - enables AI assistants to query Grafana dashboards, datasources, and metrics
5
+ Project-URL: Homepage, https://github.com/yourusername/grafana-mcp-server
6
+ Project-URL: Documentation, https://github.com/yourusername/grafana-mcp-server#readme
7
+ Project-URL: Repository, https://github.com/yourusername/grafana-mcp-server
8
+ Project-URL: Issues, https://github.com/yourusername/grafana-mcp-server/issues
9
+ Author-email: Your Name <your.email@example.com>
10
+ License: MIT License
11
+
12
+ Copyright (c) 2025 Doctor Droid
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ License-File: LICENSE
32
+ Keywords: ai,claude,cursor,grafana,mcp,monitoring,observability
33
+ Classifier: Development Status :: 3 - Alpha
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: Intended Audience :: System Administrators
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
41
+ Classifier: Topic :: System :: Monitoring
42
+ Requires-Python: >=3.11
43
+ Requires-Dist: flaky
44
+ Requires-Dist: flask==3.0.0
45
+ Requires-Dist: pytest>=8.4.1
46
+ Requires-Dist: python-dateutil>=2.9.0.post0
47
+ Requires-Dist: pyyaml>=6.0.1
48
+ Requires-Dist: requests>=2.31.0
49
+ Requires-Dist: ruff>=0.12.3
50
+ Requires-Dist: typing-extensions
51
+ Provides-Extra: dev
52
+ Requires-Dist: black; extra == 'dev'
53
+ Requires-Dist: pytest-cov; extra == 'dev'
54
+ Requires-Dist: pytest-xdist; extra == 'dev'
55
+ Provides-Extra: prod
56
+ Requires-Dist: gunicorn; extra == 'prod'
57
+ Description-Content-Type: text/markdown
58
+
59
+ # Grafana MCP Server
60
+
61
+ ## Available Tools
62
+
63
+ The following tools are available via the MCP server:
64
+
65
+ - **test_connection**: Verify connectivity to your Grafana instance and configuration.
66
+ - **grafana_promql_query**: Execute PromQL queries against Grafana's Prometheus datasource. Fetches metrics data using PromQL expressions, optimizes time series responses to reduce token size.
67
+ - **grafana_loki_query**: Query Grafana Loki for log data. Fetches logs for a specified duration (e.g., '5m', '1h', '2d'), converts relative time to absolute timestamps.
68
+ - **grafana_get_dashboard_config**: Retrieves dashboard configuration details from the database. Queries the connectors_connectormetadatamodelstore table for dashboard metadata.
69
+ - **grafana_query_dashboard_panels**: Execute queries for specific dashboard panels. Can query up to 4 panels at once, supports template variables, optimizes metrics data.
70
+ - **grafana_fetch_label_values**: Fetch label values for dashboard variables from Prometheus datasource. Retrieves available values for specific labels (e.g., 'instance', 'job'). Supports optional metric filtering.
71
+ - **grafana_fetch_dashboard_variables**: Fetch all variables and their values from a Grafana dashboard. Retrieves dashboard template variables and their current values.
72
+ - **grafana_fetch_all_dashboards**: Fetch all dashboards from Grafana with basic information like title, UID, folder, tags, etc.
73
+ - **grafana_fetch_datasources**: Fetch all datasources from Grafana with their configuration details.
74
+ - **grafana_fetch_folders**: Fetch all folders from Grafana with their metadata and permissions.
75
+
76
+ ## 🚀 Usage & Requirements
77
+
78
+ ### 1. Get Your Grafana API Endpoint & Service Account Token
79
+
80
+ 1. Ensure you have a running Grafana instance (self-hosted or cloud).
81
+ 2. Generate a Service Account Token from your Grafana UI:
82
+ - Create Service Account: In your Grafana dashboard, navigate to Admin >> Users & Access >> Service Accounts >> Create a Service Account with Viewer permissions
83
+ - Generate Service Account Key: Within Service Account, create a new Service Account token.
84
+ - Copy the service account token (starts with `glsa_`)
85
+
86
+ ---
87
+
88
+ ## 2. Installation & Running Options
89
+
90
+ ### 2A. Install & Run with uv (Recommended for Local Development)
91
+
92
+ #### 2A.1. Install dependencies with uv
93
+
94
+ ```bash
95
+ uv venv .venv
96
+ source .venv/bin/activate
97
+ uv sync
98
+ ```
99
+
100
+ #### 2A.2. Run the server with uv
101
+
102
+ ```bash
103
+ uv run -m src.grafana_mcp_server.mcp_server
104
+ ```
105
+
106
+ - You can also use `uv` to run any other entrypoint scripts as needed.
107
+ - Make sure your `config.yaml` is in the same directory as `mcp_server.py` or set the required environment variables (see Configuration section).
108
+
109
+ ---
110
+
111
+ ### 2B. Run with Docker Compose (Recommended for Production/Containerized Environments)
112
+
113
+ 1. Edit `grafana-mcp-server/src/grafana_mcp_server/config.yaml` with your Grafana details (host, API key).
114
+ 2. Start the server:
115
+ ```bash
116
+ docker compose up -d
117
+ ```
118
+ - The server will run in HTTP (SSE) mode on port 8000 by default.
119
+ - You can override configuration with environment variables (see below).
120
+
121
+ ---
122
+
123
+ ## 3. Configuration
124
+
125
+ The server loads configuration in the following order of precedence:
126
+
127
+ 1. **Environment Variables** (recommended for Docker/CI):
128
+ - `GRAFANA_HOST`: Grafana instance URL (e.g. `https://your-grafana-instance.com`)
129
+ - `GRAFANA_API_KEY`: Grafana Service Account Token (required)
130
+ - `GRAFANA_SSL_VERIFY`: `true` or `false` (default: `true`)
131
+ - `MCP_SERVER_PORT`: Port to run the server on (default: `8000`)
132
+ - `MCP_SERVER_DEBUG`: `true` or `false` (default: `true`)
133
+ 2. **YAML file fallback** (`config.yaml`):
134
+ ```yaml
135
+ grafana:
136
+ host: "https://your-grafana-instance.com"
137
+ api_key: "your-grafana-api-key-here"
138
+ ssl_verify: "true"
139
+ server:
140
+ port: 8000
141
+ debug: true
142
+ ```
143
+
144
+ ---
145
+
146
+ ## 4. Integration with AI Assistants (e.g., Claude Desktop, Cursor)
147
+
148
+ You can integrate this MCP server with any tool that supports the MCP protocol. Here are the main options:
149
+
150
+ ### 4A. Using Docker (with environment variables)
151
+
152
+ ```json
153
+ {
154
+ "mcpServers": {
155
+ "grafana": {
156
+ "command": "docker",
157
+ "args": [
158
+ "run",
159
+ "--rm",
160
+ "-i",
161
+ "-e",
162
+ "GRAFANA_HOST",
163
+ "-e",
164
+ "GRAFANA_API_KEY",
165
+ "-e",
166
+ "GRAFANA_SSL_VERIFY",
167
+ "drdroidlab/grafana-mcp-server",
168
+ "-t",
169
+ "stdio"
170
+ ],
171
+ "env": {
172
+ "GRAFANA_HOST": "https://your-grafana-instance.com",
173
+ "GRAFANA_API_KEY": "your-grafana-api-key-here",
174
+ "GRAFANA_SSL_VERIFY": "true"
175
+ }
176
+ }
177
+ }
178
+ }
179
+ ```
180
+
181
+ - The `-t stdio` argument is supported for compatibility with Docker MCP clients (forces stdio handshake mode).
182
+ - Adjust the volume path or environment variables as needed for your deployment.
183
+
184
+ ### 4B. Connecting to an Already Running MCP Server (HTTP/SSE)
185
+
186
+ If you have an MCP server already running (e.g., on a remote host, cloud VM, or Kubernetes), you can connect your AI assistant or tool directly to its HTTP endpoint.
187
+
188
+ ```json
189
+ {
190
+ "mcpServers": {
191
+ "grafana": {
192
+ "url": "http://your-server-host:8000/mcp"
193
+ }
194
+ }
195
+ }
196
+ ```
197
+
198
+ - Replace `your-server-host` with the actual host where your MCP server is running.
199
+ - **For local setup, use `localhost` as the server host (i.e., `http://localhost:8000/mcp`).**
200
+ - **Use `http` for local or unsecured deployments, and `https` for production or secured deployments.**
201
+ - Make sure the server is accessible from your client machine (check firewall, security group, etc.).
202
+
203
+ ---
204
+
205
+ ## Health Check
206
+
207
+ ```bash
208
+ curl http://localhost:8000/health
209
+ ```
210
+
211
+ The server runs on port 8000 by default.
212
+
213
+ ---
214
+
215
+ ## 5. Project Structure
216
+
217
+ ```
218
+ grafana-mcp-server/
219
+ │ └── src/
220
+ │ └── grafana_mcp_server/
221
+ │ ├── __init__.py
222
+ │ ├── config.yaml # Configuration file
223
+ │ ├── mcp_server.py # Main MCP server implementation
224
+ │ ├── stdio_server.py # STDIO server for MCP
225
+ │ └── processor/
226
+ │ ├── __init__.py
227
+ │ ├── grafana_processor.py # Grafana API processor
228
+ │ └── processor.py # Base processor interface
229
+ ├── tests/
230
+ ├── Dockerfile
231
+ ├── docker-compose.yml
232
+ ├── pyproject.toml
233
+ └── README.md
234
+ ```
235
+
236
+ ---
237
+
238
+ ---
239
+
240
+ ## 6. Troubleshooting
241
+
242
+ ### Common Issues
243
+
244
+ 1. **Connection Failed**:
245
+
246
+ - Verify your Grafana instance is running and accessible
247
+ - Check your API key has proper permissions
248
+ - Ensure SSL verification settings match your setup
249
+
250
+ 2. **Authentication Errors**:
251
+
252
+ - Verify your API key is correct and not expired
253
+ - Check if your Grafana instance requires additional authentication
254
+
255
+ 3. **Query Failures**:
256
+ - Ensure datasource UIDs are correct
257
+ - Verify PromQL/Loki query syntax
258
+ - Check if the datasource is accessible with your API key
259
+
260
+ ### Debug Mode
261
+
262
+ Enable debug mode to get more detailed logs:
263
+
264
+ ```bash
265
+ export MCP_SERVER_DEBUG=true
266
+ ```
267
+
268
+ ---
269
+
270
+ ## 7. Contributing
271
+
272
+ 1. Fork the repository
273
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
274
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
275
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
276
+ 5. Open a Pull Request
277
+
278
+ ---
279
+
280
+ ## 8. License
281
+
282
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
283
+
284
+ ---
285
+
286
+ ## 9. Support
287
+
288
+ 1. Need help anywhere? Join our [discord channel](https://discord.gg/GTzfNMSm) and message on #mcp channel.
289
+ 2. Want a 1-click MCP Server? Join the same community and let us know.
290
+ 3. For issues and questions, please open an issue on GitHub or contact the maintainers.