dr-panda-mcp 1.0.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 (124) hide show
  1. dr_panda_mcp-1.0.0/LICENSE +21 -0
  2. dr_panda_mcp-1.0.0/PKG-INFO +521 -0
  3. dr_panda_mcp-1.0.0/README.pypi.md +474 -0
  4. dr_panda_mcp-1.0.0/pyproject.toml +81 -0
  5. dr_panda_mcp-1.0.0/pyproject.toml.orig +74 -0
  6. dr_panda_mcp-1.0.0/src/dr_panda_mcp/__init__.py +103 -0
  7. dr_panda_mcp-1.0.0/src/dr_panda_mcp/__main__.py +5 -0
  8. dr_panda_mcp-1.0.0/src/dr_panda_mcp/admin.py +88 -0
  9. dr_panda_mcp-1.0.0/src/dr_panda_mcp/audit.py +81 -0
  10. dr_panda_mcp-1.0.0/src/dr_panda_mcp/auth.py +607 -0
  11. dr_panda_mcp-1.0.0/src/dr_panda_mcp/catalog.py +216 -0
  12. dr_panda_mcp-1.0.0/src/dr_panda_mcp/cli.py +34 -0
  13. dr_panda_mcp-1.0.0/src/dr_panda_mcp/client_install.py +147 -0
  14. dr_panda_mcp-1.0.0/src/dr_panda_mcp/config.py +123 -0
  15. dr_panda_mcp-1.0.0/src/dr_panda_mcp/connectors/__init__.py +43 -0
  16. dr_panda_mcp-1.0.0/src/dr_panda_mcp/connectors/base.py +286 -0
  17. dr_panda_mcp-1.0.0/src/dr_panda_mcp/connectors/classify.py +157 -0
  18. dr_panda_mcp-1.0.0/src/dr_panda_mcp/connectors/cls.py +236 -0
  19. dr_panda_mcp-1.0.0/src/dr_panda_mcp/connectors/es.py +246 -0
  20. dr_panda_mcp-1.0.0/src/dr_panda_mcp/connectors/gitlab.py +189 -0
  21. dr_panda_mcp-1.0.0/src/dr_panda_mcp/connectors/kafka.py +267 -0
  22. dr_panda_mcp-1.0.0/src/dr_panda_mcp/connectors/mongo.py +388 -0
  23. dr_panda_mcp-1.0.0/src/dr_panda_mcp/connectors/mysql.py +144 -0
  24. dr_panda_mcp-1.0.0/src/dr_panda_mcp/connectors/rabbit.py +102 -0
  25. dr_panda_mcp-1.0.0/src/dr_panda_mcp/connectors/redis.py +264 -0
  26. dr_panda_mcp-1.0.0/src/dr_panda_mcp/crypto.py +166 -0
  27. dr_panda_mcp-1.0.0/src/dr_panda_mcp/env.py +70 -0
  28. dr_panda_mcp-1.0.0/src/dr_panda_mcp/errors.py +193 -0
  29. dr_panda_mcp-1.0.0/src/dr_panda_mcp/guards/__init__.py +1 -0
  30. dr_panda_mcp-1.0.0/src/dr_panda_mcp/guards/cls.py +72 -0
  31. dr_panda_mcp-1.0.0/src/dr_panda_mcp/guards/es.py +156 -0
  32. dr_panda_mcp-1.0.0/src/dr_panda_mcp/guards/forbidden.py +163 -0
  33. dr_panda_mcp-1.0.0/src/dr_panda_mcp/guards/gitlab.py +19 -0
  34. dr_panda_mcp-1.0.0/src/dr_panda_mcp/guards/kafka.py +55 -0
  35. dr_panda_mcp-1.0.0/src/dr_panda_mcp/guards/mongo.py +105 -0
  36. dr_panda_mcp-1.0.0/src/dr_panda_mcp/guards/mysql.py +130 -0
  37. dr_panda_mcp-1.0.0/src/dr_panda_mcp/guards/protocol.py +49 -0
  38. dr_panda_mcp-1.0.0/src/dr_panda_mcp/guards/rabbit.py +27 -0
  39. dr_panda_mcp-1.0.0/src/dr_panda_mcp/guards/redis.py +99 -0
  40. dr_panda_mcp-1.0.0/src/dr_panda_mcp/install.py +95 -0
  41. dr_panda_mcp-1.0.0/src/dr_panda_mcp/log.py +254 -0
  42. dr_panda_mcp-1.0.0/src/dr_panda_mcp/masking.py +29 -0
  43. dr_panda_mcp-1.0.0/src/dr_panda_mcp/prompts.py +59 -0
  44. dr_panda_mcp-1.0.0/src/dr_panda_mcp/runtime.py +89 -0
  45. dr_panda_mcp-1.0.0/src/dr_panda_mcp/server.py +162 -0
  46. dr_panda_mcp-1.0.0/src/dr_panda_mcp/settings.py +349 -0
  47. dr_panda_mcp-1.0.0/src/dr_panda_mcp/setup.py +353 -0
  48. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/__init__.py +1 -0
  49. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/env.py +32 -0
  50. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/script.py.mako +25 -0
  51. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/versions/0001_initial.py +84 -0
  52. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/versions/0002_settings_metadata.py +240 -0
  53. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/versions/0003_backup_keep.py +70 -0
  54. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/versions/0004_users.py +83 -0
  55. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/versions/0005_mcp_token_metadata.py +29 -0
  56. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/versions/0006_mcp_tokens.py +58 -0
  57. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/versions/0007_environments.py +100 -0
  58. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/versions/0008_audit_environment.py +23 -0
  59. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/versions/0009_user_password_gate.py +31 -0
  60. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/versions/0010_audit_outcome.py +62 -0
  61. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/versions/0011_audit_error_detail.py +26 -0
  62. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/versions/0012_security_settings.py +157 -0
  63. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/alembic/versions/0013_capacity_settings.py +130 -0
  64. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/migrate.py +132 -0
  65. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/models.py +182 -0
  66. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/protocol.py +181 -0
  67. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/repository.py +780 -0
  68. dr_panda_mcp-1.0.0/src/dr_panda_mcp/store/url.py +131 -0
  69. dr_panda_mcp-1.0.0/src/dr_panda_mcp/tools/__init__.py +21 -0
  70. dr_panda_mcp-1.0.0/src/dr_panda_mcp/tools/base.py +480 -0
  71. dr_panda_mcp-1.0.0/src/dr_panda_mcp/tools/data.py +860 -0
  72. dr_panda_mcp-1.0.0/src/dr_panda_mcp/tools/logs.py +375 -0
  73. dr_panda_mcp-1.0.0/src/dr_panda_mcp/tools/messages.py +275 -0
  74. dr_panda_mcp-1.0.0/src/dr_panda_mcp/tools/system.py +179 -0
  75. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/__init__.py +1 -0
  76. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/assets.py +74 -0
  77. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/async_api.py +150 -0
  78. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/audit_page.py +352 -0
  79. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/auth_routes.py +142 -0
  80. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/clock.py +43 -0
  81. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/forms.py +785 -0
  82. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/i18n.py +168 -0
  83. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/labels.py +38 -0
  84. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/locales/en.json +718 -0
  85. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/locales/zh-Hans.json +1 -0
  86. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/overview.py +148 -0
  87. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/profile.py +283 -0
  88. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/render.py +141 -0
  89. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/routes.py +1429 -0
  90. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/security.py +357 -0
  91. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/static/app.css +3060 -0
  92. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/static/app.js +1016 -0
  93. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/static/copy-token.js +53 -0
  94. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/static/icon.png +0 -0
  95. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/_audit_params.html +44 -0
  96. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/_environment_drawer.html +51 -0
  97. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/_macros.html +87 -0
  98. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/admin_overview.html +108 -0
  99. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/audit.html +150 -0
  100. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/base.html +145 -0
  101. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/delete.html +33 -0
  102. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/environment_form.html +60 -0
  103. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/environments.html +81 -0
  104. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/error.html +13 -0
  105. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/form.html +203 -0
  106. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/index.html +280 -0
  107. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/login.html +30 -0
  108. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/me.html +180 -0
  109. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/overview.html +65 -0
  110. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/settings.html +211 -0
  111. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/settings_reset.html +41 -0
  112. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/setup_admin.html +25 -0
  113. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/setup_base.html +44 -0
  114. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/setup_complete.html +29 -0
  115. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/setup_database.html +52 -0
  116. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/targets_new.html +32 -0
  117. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/targets_readonly.html +146 -0
  118. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/token_created.html +14 -0
  119. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/token_delete.html +22 -0
  120. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/token_new.html +21 -0
  121. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/templates/users.html +117 -0
  122. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/theme.py +61 -0
  123. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/users_page.py +238 -0
  124. dr_panda_mcp-1.0.0/src/dr_panda_mcp/web/views.py +265 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 linyu19872008
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,521 @@
1
+ Metadata-Version: 2.4
2
+ Name: dr-panda-mcp
3
+ Version: 1.0.0
4
+ Summary: Read-only MCP service for production troubleshooting: register connections in a web console, call tools by target name
5
+ Keywords: mcp,read-only,troubleshooting,observability,fastmcp
6
+ Author: linyu19872008
7
+ Author-email: linyu19872008 <linyu19872008@gmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: System :: Systems Administration
16
+ Classifier: Topic :: Software Development :: Debuggers
17
+ Classifier: Operating System :: OS Independent
18
+ Requires-Dist: fastmcp>=4.1.4
19
+ Requires-Dist: sqlalchemy[asyncio]>=2.0.30
20
+ Requires-Dist: alembic>=1.13
21
+ Requires-Dist: jinja2>=3.1
22
+ Requires-Dist: uvicorn>=0.30
23
+ Requires-Dist: aiosqlite>=0.20
24
+ Requires-Dist: cryptography>=42.0
25
+ Requires-Dist: sqlglot>=25.0
26
+ Requires-Dist: httpx>=0.27
27
+ Requires-Dist: python-dotenv>=1.0
28
+ Requires-Dist: tencentcloud-sdk-python-cls>=3.0 ; extra == 'cls'
29
+ Requires-Dist: aiokafka>=0.10 ; extra == 'kafka'
30
+ Requires-Dist: motor>=3.4 ; extra == 'mongo'
31
+ Requires-Dist: asyncmy>=0.2.9 ; extra == 'mysql'
32
+ Requires-Dist: asyncpg>=0.29 ; extra == 'postgres'
33
+ Requires-Dist: redis>=5.0 ; extra == 'redis'
34
+ Requires-Python: >=3.11
35
+ Project-URL: Homepage, https://github.com/linyu19872008/DrPanda
36
+ Project-URL: Repository, https://github.com/linyu19872008/DrPanda
37
+ Project-URL: Issues, https://github.com/linyu19872008/DrPanda/issues
38
+ Project-URL: Documentation, https://github.com/linyu19872008/DrPanda/tree/main/docs
39
+ Project-URL: Changelog, https://github.com/linyu19872008/DrPanda/blob/main/CHANGELOG.md
40
+ Provides-Extra: cls
41
+ Provides-Extra: kafka
42
+ Provides-Extra: mongo
43
+ Provides-Extra: mysql
44
+ Provides-Extra: postgres
45
+ Provides-Extra: redis
46
+ Description-Content-Type: text/markdown
47
+
48
+ <!-- Generated from README.md by scripts/build_pypi_readme.py. Do not edit by hand. -->
49
+
50
+ <p align="center">
51
+ <img src="https://raw.githubusercontent.com/linyu19872008/DrPanda/main/docs/assets/logo.png" width="96" alt="DrPanda MCP">
52
+ </p>
53
+
54
+ <p align="center">
55
+ <a href="https://github.com/linyu19872008/DrPanda/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/linyu19872008/DrPanda/actions/workflows/ci.yml/badge.svg?branch=main"></a>
56
+ <!-- PyPI badge is enabled after the first PyPI release:
57
+ <a href="https://pypi.org/project/dr-panda-mcp/"><img alt="PyPI" src="https://img.shields.io/pypi/v/dr-panda-mcp"></a>
58
+ -->
59
+ <a href="https://github.com/linyu19872008/DrPanda/blob/main/LICENSE"><img alt="License: MIT" src="https://raw.githubusercontent.com/linyu19872008/DrPanda/main/docs/assets/badge-license.png" height="20"></a>
60
+ <a href="https://www.python.org/"><img alt="Python 3.11+" src="https://raw.githubusercontent.com/linyu19872008/DrPanda/main/docs/assets/badge-python.png" height="20"></a>
61
+ </p>
62
+
63
+ <p align="center"><strong>English</strong> · <a href="https://github.com/linyu19872008/DrPanda/blob/main/README.zh-CN.md">简体中文</a></p>
64
+
65
+ # DrPanda MCP
66
+
67
+ A **read-only MCP service** for production troubleshooting.
68
+
69
+ Register MySQL, MongoDB, Elasticsearch, Redis, GitLab, RabbitMQ, Kafka and CLS connections (addresses, credentials and allowed scope) in a web console. MCP clients such as Cursor, Codex and DeepSeek Harness call `/mcp` over Streamable HTTP; models can only use read-only tools by `target` name.
70
+
71
+ **The model never supplies hosts, accounts, or passwords itself.**
72
+
73
+ ![Web console in English](https://raw.githubusercontent.com/linyu19872008/DrPanda/main/docs/assets/screenshot-en.png)
74
+
75
+ ---
76
+
77
+ ## Why DrPanda MCP
78
+
79
+ Production troubleshooting often requires looking at logs, code, databases, caches and message queues at the same time. Giving production credentials directly to a model is risky; read-only proxies, ad-hoc screenshots and manual lookups are hard to reproduce and audit.
80
+
81
+ DrPanda MCP narrows "what can be queried" into three boundaries:
82
+
83
+ 1. **Connection boundary**: only targets registered in the web console are reachable;
84
+ 2. **Operation boundary**: only a read-only whitelist is executed; admin commands and high-cost queries are rejected before connecting;
85
+ 3. **Identity boundary**: web login and MCP bearer tokens are independent, and every call is audited under the real administrator.
86
+
87
+ ---
88
+
89
+ ## Status
90
+
91
+ M0–M7 are implemented and tested:
92
+
93
+ | Phase | Content | Status |
94
+ |---|---|---|
95
+ | M0–M2 | Foundations, config store, secret encryption, eight read-only guards | Done |
96
+ | M3 | Web console, MCP `/mcp` endpoint | Done |
97
+ | M4 | CLS logs, GitLab code (5 tools) | Done |
98
+ | M5 | MySQL / Mongo / ES / Redis (17 tools) | Done |
99
+ | M6 | RabbitMQ / Kafka (5 tools) | Done |
100
+ | M7 | First-run setup, login, multiple tokens, per-actor audit | Done |
101
+
102
+ - Tools: **28**
103
+ - Quality gate: GitHub Actions (pytest / ruff / docs link check); see the CI badge above
104
+ - Default listen: `127.0.0.1:8111`
105
+ - Default languages: English (UI, MCP, CLI, docs); Chinese docs live under `docs/zh-CN/`
106
+ - First-run setup supports SQLite / MySQL / PostgreSQL config stores
107
+ - Server-rendered web console; interactive features require JavaScript, while authentication and validation stay server-side
108
+
109
+ Real integration coverage:
110
+
111
+ - MySQL / MongoDB / Elasticsearch / Redis / RabbitMQ verified against real Docker upstreams;
112
+ - MySQL TLS/mTLS, target-level CA, ES multi-host failover and multiple Mongo auth modes are covered;
113
+ - Kafka, CLS and GitLab tools are implemented and unit-tested, but **not yet end-to-end verified against real upstreams**.
114
+
115
+ ---
116
+
117
+ ## Quick start
118
+
119
+ ### Requirements
120
+
121
+ - Python `>= 3.11`
122
+ - [uv](https://docs.astral.sh/uv/)
123
+ - SQLite is used by default; no extra database is required for the first run
124
+
125
+ From source (recommended for development):
126
+
127
+ ```bash
128
+ git clone https://github.com/linyu19872008/DrPanda.git
129
+ cd dr-panda-mcp
130
+ uv sync
131
+ cp .env.example .env # optional; defaults are used otherwise
132
+ uv run dr-panda-mcp # automatically loads ./.env from the current directory
133
+ ```
134
+
135
+ Or install as a command-line tool from PyPI (once the first release is published):
136
+
137
+ ```bash
138
+ uv tool install dr-panda-mcp
139
+ # Optional config-store drivers:
140
+ # uv tool install 'dr-panda-mcp[mysql]'
141
+ # uv tool install 'dr-panda-mcp[postgres]'
142
+ dr-panda-mcp
143
+ ```
144
+
145
+ A PyPI install uses `data/` in the current working directory; start it from a dedicated directory.
146
+
147
+ Open:
148
+
149
+ ```text
150
+ http://127.0.0.1:8111/
151
+ ```
152
+
153
+ On the first run, the setup wizard asks you to:
154
+
155
+ 1. set an administrator password (at least 8 characters);
156
+ 2. choose a config store: SQLite (recommended locally) / MySQL / PostgreSQL;
157
+ 3. test the connection (the finish button unlocks only after a successful test);
158
+ 4. finish setup and save the MCP token shown on the completion page.
159
+
160
+ When registering a target, a new target must pass a connection test before it can be saved. When editing, if host, account, secret, TLS and timeout are unchanged, scope and runtime limits can be saved directly. The server only re-probes after connection fields change; failures are never persisted.
161
+
162
+ Health check:
163
+
164
+ ```bash
165
+ curl -fsS http://127.0.0.1:8111/healthz
166
+ # {"ok":true,"version":"1.0.0","db":"ok"}
167
+ ```
168
+
169
+ ### Optional dependencies
170
+
171
+ `uv sync --extra <name>` trims the environment to "default dependencies + this one extra"; other installed clients are removed. Add `--inexact` when adding a single extra. Use `--all-extras` to install everything. Run these commands in the project directory used by `uv run dr-panda-mcp`.
172
+
173
+ When the console shows "client not installed", click **Install**. The service runs the command with `--inexact` in the current project and retests immediately; no restart is needed after a new client is installed.
174
+
175
+ ```bash
176
+ # Config stores
177
+ uv sync --extra mysql --inexact # asyncmy
178
+ uv sync --extra postgres --inexact # asyncpg
179
+
180
+ # Troubleshooting components (GitLab and RabbitMQ need no extra)
181
+ uv sync --extra mongo --inexact
182
+ uv sync --extra redis --inexact
183
+ uv sync --extra kafka --inexact
184
+ uv sync --extra cls --inexact
185
+
186
+ # Everything at once
187
+ uv sync --all-extras
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Files created by the first-run setup
193
+
194
+ After setup, `data/` contains:
195
+
196
+ | File | Purpose | If lost |
197
+ |---|---|---|
198
+ | `install.json` | encrypted config-store URL | restore from backup; the service cannot find the store automatically |
199
+ | `install.key` | decrypts `install.json` | installation state cannot be recovered |
200
+ | `session.key` | web session signing key | all web sessions become invalid; log in again |
201
+ | `secret.key` | encrypts target secrets | registered secrets cannot be recovered |
202
+ | `dr-panda.sqlite` | default SQLite config store | targets, audit and settings are lost |
203
+
204
+ - Installation files are created with `0600` permissions.
205
+ - **Back up `secret.key`, `install.json`, `install.key` and `session.key` together with the config store.**
206
+ - Never commit `data/` to Git.
207
+
208
+ ---
209
+
210
+ ## Client setup
211
+
212
+ Configure the MCP URL and a bearer token in every client:
213
+
214
+ ```json
215
+ {
216
+ "mcpServers": {
217
+ "drpanda": {
218
+ "url": "http://127.0.0.1:8111/mcp",
219
+ "headers": {
220
+ "Authorization": "Bearer <MCP token created on the My account page>"
221
+ }
222
+ }
223
+ }
224
+ }
225
+ ```
226
+
227
+ ### Cursor
228
+
229
+ Put the `mcpServers` block above into Cursor's MCP configuration file.
230
+
231
+ ### Codex
232
+
233
+ ```toml
234
+ [mcp_servers.drpanda]
235
+ url = "http://127.0.0.1:8111/mcp"
236
+
237
+ [mcp_servers.drpanda.headers]
238
+ Authorization = "Bearer <token>"
239
+ ```
240
+
241
+ ### DeepSeek Harness
242
+
243
+ Use `serverName = drpanda`; model-side tool names look like:
244
+
245
+ ```text
246
+ mcp__drpanda__mysql_query
247
+ mcp__drpanda__cls_search
248
+ mcp__drpanda__systems_status
249
+ ```
250
+
251
+ Notes:
252
+
253
+ - `/mcp` returns `401` without a valid bearer token;
254
+ - a web login session **cannot** replace an MCP token;
255
+ - only token hashes are stored; the full value is shown once at creation and cannot be recovered (delete and create a new one if lost);
256
+ - if you change the port, update client URLs accordingly.
257
+
258
+ ---
259
+
260
+ ## Targets and tools
261
+
262
+ A target belongs to an environment. Environments have a display title and a key. The title can change; the key is immutable and must be passed when troubleshooting. Different environments may contain targets with the same name; within one environment, multiple targets of the same type are distinguished by name and never selected automatically.
263
+
264
+ With a single environment, tools may omit `environment`; the migration creates `default` with the title `Default`. After adding more environments, every call must pass `environment`. Call `systems_status` without arguments to list environments, then pass the key to list targets in that environment. The web console switches targets by environment; disabled environments cannot be queried but their configuration is retained.
265
+
266
+ Tool calls only accept `environment` and `target` names — never hosts, accounts or passwords.
267
+
268
+ | Type | Tools |
269
+ |---|---|
270
+ | `mysql` | `mysql_tables`, `mysql_describe`, `mysql_query`, `mysql_explain`, `mysql_processlist` |
271
+ | `mongo` | `mongo_collections`, `mongo_find`, `mongo_aggregate`, `mongo_stats` |
272
+ | `elasticsearch` | `es_mapping`, `es_search`, `es_health`, `es_index_stats` |
273
+ | `redis` | `redis_get`, `redis_scan`, `redis_info`, `redis_slowlog` |
274
+ | `gitlab` | `gitlab_search_code`, `gitlab_get_file`, `gitlab_blame` |
275
+ | `cls` | `cls_search`, `cls_context` |
276
+ | `rabbitmq` | `rabbit_queues`, `rabbit_queue` |
277
+ | `kafka` | `kafka_lag`, `kafka_offsets`, `kafka_peek` |
278
+ | global | `systems_status` |
279
+
280
+ There is also an `investigate_error` prompt that organizes a troubleshooting path starting from an error symptom.
281
+
282
+ Target scope can only narrow the readable boundary:
283
+
284
+ - MySQL: databases / tables;
285
+ - MongoDB: databases / collections;
286
+ - Elasticsearch: indices;
287
+ - Redis: key prefixes / command scope;
288
+ - GitLab: projects / branches;
289
+ - RabbitMQ: vhosts / queues;
290
+ - Kafka: topics / partitions;
291
+ - CLS: log topics and time range.
292
+
293
+ Target names allow lowercase letters, digits and hyphens only, and are immutable. Secrets are stored encrypted and never echoed in lists.
294
+
295
+ ---
296
+
297
+ ## Security model
298
+
299
+ ### Absolutely read-only
300
+
301
+ - Every tool across the eight components (including the web console's connection test) is read-only;
302
+ - accounts with write permissions are never used for writes;
303
+ - beyond the read-only whitelist, absolute dangerous rules reject:
304
+ - admin/DDL/change commands;
305
+ - unbounded scans, large aggregations, deep pagination, script execution, etc.;
306
+ - dangerous checks run before connecting; the rejection code is `DANGEROUS_OPERATION`;
307
+ - every call is bounded by timeout, row, byte and per-target concurrency limits; truncation is always marked.
308
+
309
+ ### Authentication and request protection
310
+
311
+ - Web login: administrator password plus an HMAC-signed session cookie;
312
+ - Forms: CSRF double-submit validation;
313
+ - `/mcp`: independent bearer tokens, stored as SHA-256 hashes;
314
+ - Host/Origin validation rejects unexpected origins;
315
+ - listens on loopback by default; changing to `0.0.0.0` or a specific interface IP exposes it, so an HTTPS reverse proxy is recommended;
316
+ - config-store changes are audited under the real administrator.
317
+
318
+ ### Frontend
319
+
320
+ - Jinja2 server-side rendering;
321
+ - core flows work without JavaScript;
322
+ - only small self-hosted, dependency-free scripts:
323
+ - `app.js`: native `<dialog>` and form loading states;
324
+ - `copy-token.js`: copy tokens;
325
+ - no frontend framework, Node build chain or third-party CDN;
326
+ - without JavaScript, dedicated form/confirmation pages or manual copy hints are shown — no fake buttons.
327
+
328
+ See [Security](https://github.com/linyu19872008/DrPanda/blob/main/docs/security.md) and [Verification](https://github.com/linyu19872008/DrPanda/blob/main/docs/verification.md) for the full policy and boundaries.
329
+
330
+ ---
331
+
332
+ ## System settings
333
+
334
+ Sign in and open `/settings`. Settings live in the config store with range validation; only actually changed values are written to audit and `settings_history`.
335
+
336
+ | Key | Default | Range | Description |
337
+ |---|---:|---:|---|
338
+ | `default_target_timeout_s` | 15 s | 1–120 | default timeout for new targets |
339
+ | `default_target_max_rows` | 100 rows | 1–1000 | default row limit for new targets |
340
+ | `default_target_max_bytes` | 102400 B | 4096–1048576 | default byte limit for new targets |
341
+ | `target_max_concurrency` | 10 | 1–50 | per-target concurrency |
342
+ | `global_max_concurrent_calls` | 0 | 0–200 | process-wide concurrency (0 = unlimited) |
343
+ | `audit_retention_days` | 90 d | 1–3650 | audit retention |
344
+ | `audit_cleanup_interval_minutes` | 60 | 5–1440 | audit cleanup interval |
345
+ | `audit_cleanup_batch_size` | 1000 | 100–5000 | audit rows deleted per batch |
346
+ | `audit_cleanup_max_seconds` | 300 | 10–3600 | max seconds per cleanup round |
347
+ | `catalog_max_clients` | 32 | 4–128 | connector client cache limit |
348
+ | `catalog_idle_seconds` | 0 | 0–3600 | connector idle reclamation (0 = off) |
349
+ | `session_ttl_minutes` | 720 | 30–10080 | web session lifetime |
350
+ | `login_max_attempts` | 5 | 1–50 | failed logins allowed per source IP |
351
+ | `login_lockout_minutes` | 5 | 1–1440 | lockout duration after the limit |
352
+ | `mcp_token_max_per_user` | 5 | 1–50 | tokens kept per account |
353
+ | `mcp_token_ttl_days` | 0 | 0–3650 | token lifetime in days (0 = no expiry) |
354
+ | `backup_keep_count` | 20 | 1–100 | SQLite backups kept before migrations |
355
+
356
+ Settings can only adjust runtime policy; they **cannot relax read-only rules, dangerous-operation rules, secret handling or target scope**.
357
+
358
+ ---
359
+
360
+ ## Environment variables
361
+
362
+ | Variable | Default | Description |
363
+ |---|---|---|
364
+ | `DR_PANDA_HOST` | `127.0.0.1` | listen address |
365
+ | `DR_PANDA_PORT` | `8111` | port shared by the web console and `/mcp` |
366
+ | `DR_PANDA_DATABASE_URL` | unused | current version does not use it for the actual store: the setup wizard selects the store, then `data/install.json` wins; setting it only affects startup validation |
367
+ | `DR_PANDA_SECRET_KEY` | unset | base64-encoded 32-byte key; falls back to `data/secret.key` |
368
+ | `DR_PANDA_LOG_LEVEL` | `INFO` | log level |
369
+ | `DR_PANDA_PUBLIC_URL` | unset | display-only base URL for pages/copied MCP addresses; not used for security decisions |
370
+ | `DR_PANDA_COOKIE_SECURE` | `auto` | Cookie Secure policy: auto (request scheme) / always / never |
371
+ | `DR_PANDA_TRUSTED_HOSTS` | unset | `/mcp` Host allowlist (comma-separated); otherwise FastMCP defaults apply |
372
+
373
+ The repository ships [`.env.example`](https://github.com/linyu19872008/DrPanda/blob/main/.env.example) with all defaults commented out; no configuration is required to start locally.
374
+
375
+ The service **automatically loads `./.env` from the current working directory**; when the file is absent it falls back to environment variables and code defaults. To override defaults:
376
+
377
+ ```bash
378
+ cp .env.example .env
379
+ # edit .env as needed (.env is ignored by git — do not commit it)
380
+ uv run dr-panda-mcp
381
+ ```
382
+
383
+ Rules:
384
+
385
+ - precedence: **real environment variables > `.env` > code defaults** (systemd/Docker/CI variables always win);
386
+ - only the current directory's `.env` is read — no parent or home-directory lookup;
387
+ - overly open permissions (e.g. `0644`), a non-regular file, or malformed lines **abort startup**, so secrets are not silently readable and configuration does not silently fail;
388
+ - there is no "disable auto-load" switch; simply do not mount `.env` in Docker/systemd.
389
+
390
+ Changing the listen address/port/public URL requires a process restart. Do not configure the config store through environment variables (see above).
391
+
392
+ Remote deployment:
393
+
394
+ - prefer an HTTPS reverse proxy; `DR_PANDA_PUBLIC_URL` only affects the displayed/copied address, not security policy;
395
+ - do not expose the console directly to the public internet; the first installation must still be completed on loopback;
396
+ - set `DR_PANDA_TRUSTED_HOSTS` (e.g. `mcp.example.com`) if you want an explicit `/mcp` Host allowlist;
397
+ - the real TLS setup behind the proxy still needs environment-specific validation.
398
+
399
+ ---
400
+
401
+ ## Operations
402
+
403
+ ### Reset the administrator password
404
+
405
+ Run locally:
406
+
407
+ ```bash
408
+ uv run dr-panda-mcp-admin reset-password
409
+ ```
410
+
411
+ The reset increments `auth_version`, invalidating all existing web sessions; MCP tokens are unaffected.
412
+
413
+ ### SQLite backups
414
+
415
+ - automatic backups happen only when a pending Alembic migration exists;
416
+ - backups are written to `data/backup/`;
417
+ - retention is controlled by `backup_keep_count`;
418
+ - manual backups must include the config store and the four key/installation files.
419
+
420
+ ### Audit
421
+
422
+ - every tool call, target change and settings change is written to `audit`, including the environment;
423
+ - the web console's Audit page filters by time, action, environment and object; records cannot be deleted from the UI;
424
+ - audit retention defaults to 90 days and is checked hourly;
425
+ - cleanup only writes logs, never audit rows (to avoid self-amplification).
426
+
427
+ ---
428
+
429
+ ## Development and testing
430
+
431
+ ```bash
432
+ uv sync --all-extras --dev
433
+ uv run ruff check .
434
+ uv run pytest -q
435
+ uv run python scripts/smoke.py
436
+ uv run python scripts/check_docs_links.py
437
+ ```
438
+
439
+ - tests use temporary SQLite databases and temporary keys, never real production systems;
440
+ - Docker integration scripts live under `scripts/integration/`;
441
+ - exact test counts are intentionally not hard-coded here; use the CI badge and your local run.
442
+
443
+ ### Project layout
444
+
445
+ ```text
446
+ src/dr_panda_mcp/
447
+ __init__.py process entrypoint
448
+ cli.py console entrypoints (loads ./.env)
449
+ config.py environment variables and runtime config
450
+ setup.py first-run setup wizard
451
+ admin.py local admin maintenance commands
452
+ auth.py passwords, sessions, CSRF, MCP tokens
453
+ server.py FastMCP, /mcp and web app assembly
454
+ runtime.py engine, migrations, secrets, ConfigStore
455
+ settings.py system settings defaults/ranges/groups
456
+ connectors/ eight upstream connectors
457
+ guards/ read-only whitelist and dangerous-operation rules
458
+ tools/ MCP tool implementations and audit
459
+ prompts.py investigate_error
460
+ web/ routes/templates/static/rendering
461
+ store/ SQLAlchemy models, repository, Alembic migrations
462
+ tests/ unit, contract, web, tool and migration tests
463
+ docs/ English documentation (default)
464
+ docs/zh-CN/ Chinese design and verification documents
465
+ scripts/ smoke tests, integration scripts and docs link check
466
+ ```
467
+
468
+ ---
469
+
470
+ ## Verified and unverified
471
+
472
+ ### Verified
473
+
474
+ - SQLite / MySQL / PostgreSQL config-store setup;
475
+ - creating, copying, deleting and paginating multiple MCP tokens;
476
+ - login, session, CSRF, logout and password change;
477
+ - target create/update/delete, enable/disable, connection test (test must pass before saving), secret encryption;
478
+ - same-origin async interactions: inline test/toggle, save gates, settings/login/password/setup feedback, with non-JS fallbacks;
479
+ - system settings save, per-item/global reset and history;
480
+ - light/dark themes, English/Chinese, 1440/390 responsive layouts;
481
+ - MySQL / Mongo / ES / Redis / RabbitMQ against real Docker upstreams;
482
+ - read-only guards, dangerous-command rejection, timeout/row/byte limits.
483
+
484
+ ### Unverified / boundaries
485
+
486
+ - Kafka end-to-end against a real upstream (image unavailable);
487
+ - CLS and GitLab end-to-end with real credentials;
488
+ - real HTTPS/TLS setup behind a reverse proxy;
489
+ - multi-user RBAC, OAuth/OIDC, MFA;
490
+ - password recovery page (only a local CLI reset exists);
491
+ - automatic recovery when `install.json` / `install.key` / `secret.key` are lost.
492
+
493
+ Unverified capabilities are never treated as available just because other components pass.
494
+
495
+ ---
496
+
497
+ ## Documentation
498
+
499
+ English documentation:
500
+
501
+ - [docs/README.md](https://github.com/linyu19872008/DrPanda/blob/main/docs/README.md): English documentation index
502
+ - [docs/architecture.md](https://github.com/linyu19872008/DrPanda/blob/main/docs/architecture.md): components, request flow, data model and deployment
503
+ - [docs/security.md](https://github.com/linyu19872008/DrPanda/blob/main/docs/security.md): security model, authentication, secrets and remote access
504
+ - [docs/ui-design.md](https://github.com/linyu19872008/DrPanda/blob/main/docs/ui-design.md): web console design system and page behavior
505
+ - [docs/verification.md](https://github.com/linyu19872008/DrPanda/blob/main/docs/verification.md): testing strategy, verified and unverified capabilities
506
+
507
+ The Chinese README links the Chinese design and verification docs.
508
+
509
+ ---
510
+
511
+ ## Contributing, security and license
512
+
513
+ - [CONTRIBUTING.md](https://github.com/linyu19872008/DrPanda/blob/main/CONTRIBUTING.md): development setup, tests, pull-request rules and bilingual docs sync
514
+ - [SECURITY.md](https://github.com/linyu19872008/DrPanda/blob/main/SECURITY.md): how to report vulnerabilities and scope
515
+ - [CODE_OF_CONDUCT.md](https://github.com/linyu19872008/DrPanda/blob/main/CODE_OF_CONDUCT.md): community expectations
516
+ - [CHANGELOG.md](https://github.com/linyu19872008/DrPanda/blob/main/CHANGELOG.md): release history
517
+ - [LICENSE](https://github.com/linyu19872008/DrPanda/blob/main/LICENSE): MIT
518
+
519
+ English is the default for code, comments, error codes and repository governance files. The UI and product docs also support Chinese; issues and pull requests may be written in English or Chinese.
520
+
521
+ If this project helps you, a star is appreciated.