ct-bigpanda-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.
@@ -0,0 +1,8 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ dist/
5
+ build/
6
+ *.egg-info/
7
+ .pytest_cache/
8
+ .ruff_cache/
@@ -0,0 +1,65 @@
1
+ # Handoff: `ct-bigpanda-mcp-server` (parallel workstream — separate repo)
2
+
3
+ > **STATUS (built):** the server has been implemented at `/home/user/ct-bigpanda-mcp-server` (v0.1.0, read-only scope) — from-scratch wrapper over the BigPanda Incidents V2 / Environments REST API. Pure helpers are unit-tested offline; the FastMCP `listTools` surface is asserted without network. **NOT yet verified against a live BigPanda tenant**, and **NOT yet published to PyPI**. Remaining: (1) live-tenant verification of the four assumptions in README → "Live-tenant verification required"; (2) `twine upload` to PyPI (needs a PyPI token + a real User API Key for the live check).
4
+
5
+ **For:** the team owning the MCP-server / sandbox-package repo.
6
+ **Goal:** publish a PyPI package `ct-bigpanda-mcp-server` that CloudThinker's BigPanda connection launches via `uvx` inside the sandbox.
7
+
8
+ **NOT in scope:** No change to the OpenSandbox runtime, the `cloudthinker-sandbox` image, k8s manifests, or egress policy (prod runs allow-all egress; BigPanda is a public API; `uvx`/`uv` already baked into the sandbox image). This package is the only external dependency.
9
+
10
+ ## What CloudThinker will run
11
+
12
+ The backend catalog (`migrate_builtin_connection.py`, prefix `bigpanda`) launches it exactly like Prometheus:
13
+ ```python
14
+ config = {
15
+ "command": "uvx",
16
+ "args": ["--from", "ct-bigpanda-mcp-server@0.1.0", "ct-bigpanda-mcp-server"],
17
+ }
18
+ ```
19
+ `uvx` resolves the package from PyPI at connect time. So: **the package MUST be published to PyPI** before the connection can connect. (cco-2 already pins `@0.1.0` in the seed — keep the published version in sync, or bump both together.)
20
+
21
+ ## Why from-scratch (not a wrapper over upstream)
22
+
23
+ Unlike RabbitMQ (wraps `amq-mcp-server-rabbitmq`), **BigPanda has no upstream MCP server** (web search, June 2026). So this implements the three read tools directly against the REST API. Same CloudThinker connection model as the others: auto-connect from env vars, no runtime connect/login tool, stdio transport.
24
+
25
+ ## Required behavior (the CONTRACT — must match the backend catalog seed exactly)
26
+
27
+ 1. On startup, read these env vars:
28
+
29
+ | Env var | Required | Default | Purpose |
30
+ |---|---|---|---|
31
+ | `BIGPANDA_API_TOKEN` | yes | — | User API Key, sent `Authorization: Bearer <key>` |
32
+ | `BIGPANDA_REGION` | no | `us` | `us` → `api.bigpanda.io`, `eu` → `eu-api.bigpanda.io` |
33
+ | `BIGPANDA_ENVIRONMENT_ID` | no | — | default environment for the incident tools |
34
+ | `LOG_LEVEL` | no | `info` | logging level (also → `FASTMCP_LOG_LEVEL`) |
35
+
36
+ 2. Auto-connect from those env vars; the first tool call works with no bootstrap tool call. Probe `GET /environments` once at startup so a bad key / wrong region fails fast (the connection test then reports a real error).
37
+ 3. Expose exactly these three **read-only** tools (snake_case — they ARE the contract the executor skill imports). CloudThinker leaves the catalog `tools` list **empty**; runtime discovery owns the inventory.
38
+ - `list_environments()` → `GET /resources/v2.0/environments`
39
+ - `search_incidents({environment_id, query?, status?, limit})` → `GET .../environments/{id}/incidents` — `limit` is a STRING, capped at 100.
40
+ - `get_incident({environment_id, incident_id})` → `GET .../environments/{id}/incidents/{incident_id}`
41
+ 4. **Read-only.** No write path (no snooze/resolve/comment). That is a deliberate v1 scope boundary.
42
+ 5. stdio transport (default).
43
+ 6. Dependencies are pure-Python (`fastmcp`, `httpx`) — no native libs, sandbox image needs nothing extra.
44
+
45
+ ## Acceptance criteria
46
+
47
+ - `uvx --from ct-bigpanda-mcp-server@<VERSION> ct-bigpanda-mcp-server` starts over stdio with only the env vars above set, and `listTools` returns exactly `list_environments`, `search_incidents`, `get_incident`.
48
+ - Against a live tenant: `list_environments` returns real environments; `search_incidents` honors `limit` (bounded ≤100); `get_incident` returns an incident with its correlated alerts.
49
+ - `eu` region routes to `eu-api.bigpanda.io`; a region/key mismatch surfaces the 404→region hint, not a bare 401.
50
+ - Published to PyPI as `ct-bigpanda-mcp-server` with a pinned semver; report the version so the backend catalog `args` stays in sync.
51
+
52
+ ## Live-tenant verification checklist (do before publishing — see README)
53
+
54
+ 1. Per-endpoint response wrapping (`items` vs `incidents` vs bare array) — record the real shape; the client accepts all three but the docs should state the truth.
55
+ 2. The real `search_incidents` pagination param name (`page_size` assumed) + true max page size.
56
+ 3. `listTools` shows exactly the three tools, nothing else (`mcp-surface-phantom-tools`).
57
+ 4. Correlated-alerts field name inside an incident (`alerts` vs `entities`) — align `executor/.../incident-detail.ts` extraction.
58
+
59
+ ## Local checks already run
60
+
61
+ ```bash
62
+ cd /home/user/ct-bigpanda-mcp-server
63
+ uv run pytest -q # pure-helper unit tests (offline)
64
+ uv run python -m ... # listTools smoke (asserts the 3 tool names, no network)
65
+ ```
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,70 @@
1
+ Metadata-Version: 2.4
2
+ Name: ct-bigpanda-mcp-server
3
+ Version: 0.1.0
4
+ Summary: CloudThinker read-only MCP server for BigPanda AIOps: reads BIGPANDA_* env at startup, auto-connects to the BigPanda REST API (region-scoped), and serves environment/incident read tools over stdio.
5
+ Project-URL: Homepage, https://github.com/cloudthinker/ct-bigpanda-mcp-server
6
+ Author: CloudThinker
7
+ License: Apache-2.0
8
+ License-File: LICENSE
9
+ Keywords: aiops,bigpanda,cloudthinker,incidents,llm,mcp
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Python: >=3.10
18
+ Requires-Dist: fastmcp<3,>=2.0
19
+ Requires-Dist: httpx>=0.27
20
+ Description-Content-Type: text/markdown
21
+
22
+ # ct-bigpanda-mcp-server
23
+
24
+ A read-only CloudThinker MCP server for [BigPanda](https://www.bigpanda.io/) AIOps. BigPanda has no upstream MCP server, so this wraps the BigPanda **Incidents V2 / Environments REST API** directly and exposes it over **stdio**, auto-authenticated from environment variables — dropping into CloudThinker's env-injection connection model (same shape as `ct-prometheus-mcp-server` / `ct-rabbitmq-mcp-server`).
25
+
26
+ ## What it does
27
+
28
+ - Reads `BIGPANDA_*` env vars at startup and pins the REST client to a region.
29
+ - Probes `GET /environments` once at startup to fail fast on a bad key / wrong region.
30
+ - Serves three **read-only** tools over stdio. No write path exists.
31
+
32
+ ## Run
33
+
34
+ ```bash
35
+ uvx --from ct-bigpanda-mcp-server@0.1.0 ct-bigpanda-mcp-server
36
+ ```
37
+
38
+ ## Environment
39
+
40
+ | Var | Required | Default | Purpose |
41
+ |---|---|---|---|
42
+ | `BIGPANDA_API_TOKEN` | yes | — | BigPanda **User API Key**, sent as `Authorization: Bearer <key>` |
43
+ | `BIGPANDA_REGION` | no | `us` | `us` → `api.bigpanda.io`, `eu` → `eu-api.bigpanda.io` |
44
+ | `BIGPANDA_ENVIRONMENT_ID` | no | — | default environment for `search_incidents` / `get_incident` |
45
+ | `LOG_LEVEL` | no | `info` | logging level (also mapped to `FASTMCP_LOG_LEVEL`) |
46
+
47
+ The token must be a **User API Key** (Incidents V2 auth), not a login password. Keys are **region-scoped**: a US key against the EU host (or vice-versa) returns **404, not 401** — check `BIGPANDA_REGION` first if you see 404s.
48
+
49
+ ## Tools (read-only)
50
+
51
+ | Tool | Args (all strings) | REST call | Returns |
52
+ |---|---|---|---|
53
+ | `list_environments` | — | `GET /resources/v2.0/environments` | `{environments, total}` |
54
+ | `search_incidents` | `environment_id`, `query?`, `status?`, `limit?` | `GET .../environments/{id}/incidents?query=&page_size=` | `{incidents, returned, total, has_more, query}` |
55
+ | `get_incident` | `environment_id`, `incident_id` | `GET .../environments/{id}/incidents/{incident_id}` | the incident with correlated alerts inline |
56
+
57
+ `limit` is a **string** and is capped server-side at 100; results are also truncated client-side so output stays bounded even if the API ignores `page_size`. `status` is a convenience filter lifted into BPQL as `status = "<status>"`; pass a full `query` for richer BPQL.
58
+
59
+ ## ⚠️ Live-tenant verification required before pinning the contract
60
+
61
+ Authored from the public API reference; the following could **not** be confirmed offline and MUST be checked against a live BigPanda tenant before the documented contract is trusted (connections-kit lessons `return-shapes-wrap-vs-raw`, `mcp-surface-phantom-tools`, `tool-args-pagination-cap`):
62
+
63
+ 1. The exact response wrapping per endpoint (`items` vs `incidents` vs bare array). The client accepts all three defensively, but the real shape should be recorded.
64
+ 2. The real `search_incidents` pagination parameter name (`page_size` assumed) and its true max page size.
65
+ 3. That `listTools` shows exactly these three tool names and nothing else.
66
+ 4. The correlated-alerts field name inside an incident (`alerts` vs `entities`).
67
+
68
+ ## License
69
+
70
+ Apache-2.0.
@@ -0,0 +1,49 @@
1
+ # ct-bigpanda-mcp-server
2
+
3
+ A read-only CloudThinker MCP server for [BigPanda](https://www.bigpanda.io/) AIOps. BigPanda has no upstream MCP server, so this wraps the BigPanda **Incidents V2 / Environments REST API** directly and exposes it over **stdio**, auto-authenticated from environment variables — dropping into CloudThinker's env-injection connection model (same shape as `ct-prometheus-mcp-server` / `ct-rabbitmq-mcp-server`).
4
+
5
+ ## What it does
6
+
7
+ - Reads `BIGPANDA_*` env vars at startup and pins the REST client to a region.
8
+ - Probes `GET /environments` once at startup to fail fast on a bad key / wrong region.
9
+ - Serves three **read-only** tools over stdio. No write path exists.
10
+
11
+ ## Run
12
+
13
+ ```bash
14
+ uvx --from ct-bigpanda-mcp-server@0.1.0 ct-bigpanda-mcp-server
15
+ ```
16
+
17
+ ## Environment
18
+
19
+ | Var | Required | Default | Purpose |
20
+ |---|---|---|---|
21
+ | `BIGPANDA_API_TOKEN` | yes | — | BigPanda **User API Key**, sent as `Authorization: Bearer <key>` |
22
+ | `BIGPANDA_REGION` | no | `us` | `us` → `api.bigpanda.io`, `eu` → `eu-api.bigpanda.io` |
23
+ | `BIGPANDA_ENVIRONMENT_ID` | no | — | default environment for `search_incidents` / `get_incident` |
24
+ | `LOG_LEVEL` | no | `info` | logging level (also mapped to `FASTMCP_LOG_LEVEL`) |
25
+
26
+ The token must be a **User API Key** (Incidents V2 auth), not a login password. Keys are **region-scoped**: a US key against the EU host (or vice-versa) returns **404, not 401** — check `BIGPANDA_REGION` first if you see 404s.
27
+
28
+ ## Tools (read-only)
29
+
30
+ | Tool | Args (all strings) | REST call | Returns |
31
+ |---|---|---|---|
32
+ | `list_environments` | — | `GET /resources/v2.0/environments` | `{environments, total}` |
33
+ | `search_incidents` | `environment_id`, `query?`, `status?`, `limit?` | `GET .../environments/{id}/incidents?query=&page_size=` | `{incidents, returned, total, has_more, query}` |
34
+ | `get_incident` | `environment_id`, `incident_id` | `GET .../environments/{id}/incidents/{incident_id}` | the incident with correlated alerts inline |
35
+
36
+ `limit` is a **string** and is capped server-side at 100; results are also truncated client-side so output stays bounded even if the API ignores `page_size`. `status` is a convenience filter lifted into BPQL as `status = "<status>"`; pass a full `query` for richer BPQL.
37
+
38
+ ## ⚠️ Live-tenant verification required before pinning the contract
39
+
40
+ Authored from the public API reference; the following could **not** be confirmed offline and MUST be checked against a live BigPanda tenant before the documented contract is trusted (connections-kit lessons `return-shapes-wrap-vs-raw`, `mcp-surface-phantom-tools`, `tool-args-pagination-cap`):
41
+
42
+ 1. The exact response wrapping per endpoint (`items` vs `incidents` vs bare array). The client accepts all three defensively, but the real shape should be recorded.
43
+ 2. The real `search_incidents` pagination parameter name (`page_size` assumed) and its true max page size.
44
+ 3. That `listTools` shows exactly these three tool names and nothing else.
45
+ 4. The correlated-alerts field name inside an incident (`alerts` vs `entities`).
46
+
47
+ ## License
48
+
49
+ Apache-2.0.
@@ -0,0 +1,37 @@
1
+ [project]
2
+ name = "ct-bigpanda-mcp-server"
3
+ version = "0.1.0"
4
+ description = "CloudThinker read-only MCP server for BigPanda AIOps: reads BIGPANDA_* env at startup, auto-connects to the BigPanda REST API (region-scoped), and serves environment/incident read tools over stdio."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = { text = "Apache-2.0" }
8
+ authors = [{ name = "CloudThinker" }]
9
+ keywords = ["bigpanda", "aiops", "incidents", "mcp", "llm", "cloudthinker"]
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Intended Audience :: Developers",
13
+ "License :: OSI Approved :: Apache Software License",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ ]
19
+ # BigPanda has no upstream MCP server, so this is a from-scratch wrapper over the
20
+ # REST API (Incidents V2). Only two runtime deps: the MCP framework + an HTTP client.
21
+ dependencies = [
22
+ "fastmcp>=2.0,<3",
23
+ "httpx>=0.27",
24
+ ]
25
+
26
+ [project.scripts]
27
+ ct-bigpanda-mcp-server = "ct_bigpanda_mcp_server.__main__:main"
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/cloudthinker/ct-bigpanda-mcp-server"
31
+
32
+ [build-system]
33
+ requires = ["hatchling"]
34
+ build-backend = "hatchling.build"
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["src/ct_bigpanda_mcp_server"]
@@ -0,0 +1,3 @@
1
+ """CloudThinker BigPanda MCP server (read-only)."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,61 @@
1
+ """Entry point — read env, construct the client, fail fast, serve over stdio.
2
+
3
+ Env contract (must match the CloudThinker backend catalog seed for `bigpanda`):
4
+
5
+ | Env var | Required | Default | Purpose |
6
+ |-------------------------|----------|---------|----------------------------------|
7
+ | BIGPANDA_API_TOKEN | yes | — | User API Key (Bearer) |
8
+ | BIGPANDA_REGION | no | us | us | eu -> REST base host |
9
+ | BIGPANDA_ENVIRONMENT_ID | no | — | default environment for tools |
10
+ | LOG_LEVEL | no | info | logging level |
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import logging
16
+ import os
17
+ import sys
18
+
19
+ from .client import BigPandaClient, BigPandaError
20
+ from .server import build_server
21
+
22
+ log = logging.getLogger("ct-bigpanda-mcp-server")
23
+
24
+
25
+ def _require(name: str) -> str:
26
+ value = os.getenv(name, "").strip()
27
+ if not value:
28
+ sys.stderr.write(f"ct-bigpanda-mcp-server: required env var {name} is not set\n")
29
+ raise SystemExit(2)
30
+ return value
31
+
32
+
33
+ def main() -> None:
34
+ token = _require("BIGPANDA_API_TOKEN")
35
+ region = os.getenv("BIGPANDA_REGION", "us").strip() or "us"
36
+ default_env = os.getenv("BIGPANDA_ENVIRONMENT_ID", "").strip()
37
+
38
+ level = os.getenv("LOG_LEVEL", "info").strip().upper()
39
+ logging.basicConfig(level=getattr(logging, level, logging.INFO), stream=sys.stderr)
40
+ # FastMCP's own logger reads FASTMCP_LOG_LEVEL; mirror LOG_LEVEL into it.
41
+ os.environ.setdefault("FASTMCP_LOG_LEVEL", level)
42
+
43
+ try:
44
+ client = BigPandaClient(token, region=region, default_environment_id=default_env)
45
+ except ValueError as exc: # unknown region
46
+ sys.stderr.write(f"ct-bigpanda-mcp-server: {exc}\n")
47
+ raise SystemExit(2) from exc
48
+
49
+ # Fail fast: probe a cheap read so the connection test reports a real error
50
+ # (bad key / wrong region) instead of deferring it to the first tool call.
51
+ try:
52
+ client.list_environments()
53
+ except BigPandaError as exc:
54
+ sys.stderr.write(f"ct-bigpanda-mcp-server: startup connection check failed: {exc}\n")
55
+ raise SystemExit(1) from exc
56
+
57
+ build_server(client).run()
58
+
59
+
60
+ if __name__ == "__main__":
61
+ main()
@@ -0,0 +1,95 @@
1
+ """Pure helpers — stdlib only.
2
+
3
+ Kept free of ``httpx``/``fastmcp`` imports so the response-shape and argument
4
+ coercion logic can be unit-tested without the network stack installed. Every
5
+ function here is deterministic and side-effect free.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from typing import Any
11
+
12
+ # region -> REST base URL. BigPanda's API is region-scoped; a User API Key minted
13
+ # in one region returns 404 (not 401) against the other region's host.
14
+ _REGION_BASE = {
15
+ "us": "https://api.bigpanda.io",
16
+ "eu": "https://eu-api.bigpanda.io",
17
+ }
18
+ API_PREFIX = "/resources/v2.0"
19
+
20
+ # Hard server-side cap on how many incidents a single search returns, regardless
21
+ # of what the caller asks for. discovery-bounded-output / tool-args-pagination-cap:
22
+ # the output must stay bounded even if the upstream API ignores our page_size hint.
23
+ MAX_LIMIT = 100
24
+ DEFAULT_LIMIT = 20
25
+
26
+
27
+ def region_base_url(region: str) -> str:
28
+ """Map a region code to its REST base URL. Raises on an unknown region."""
29
+ base = _REGION_BASE.get((region or "").strip().lower())
30
+ if base is None:
31
+ valid = ", ".join(sorted(_REGION_BASE))
32
+ raise ValueError(f"unknown BIGPANDA_REGION {region!r}; expected one of: {valid}")
33
+ return base + API_PREFIX
34
+
35
+
36
+ def clamp_limit(raw: Any) -> int:
37
+ """Coerce a string/number limit to an int in [1, MAX_LIMIT].
38
+
39
+ Numeric tool args arrive as STRINGS (tool-args-string-not-int) because this
40
+ proxies an HTTP API. A missing/garbage value falls back to DEFAULT_LIMIT.
41
+ """
42
+ try:
43
+ value = int(str(raw).strip())
44
+ except (TypeError, ValueError):
45
+ return DEFAULT_LIMIT
46
+ if value < 1:
47
+ return DEFAULT_LIMIT
48
+ return min(value, MAX_LIMIT)
49
+
50
+
51
+ def as_list(data: Any, keys: tuple[str, ...]) -> list:
52
+ """Normalize a BigPanda list response to a plain list.
53
+
54
+ return-shapes-wrap-vs-raw: BigPanda is inconsistent about wrapping — some
55
+ endpoints return a bare JSON array, others wrap it under ``items`` /
56
+ ``incidents`` / ``environments``. Accept either rather than hard-coding one
57
+ shape that breaks on the other. The exact per-endpoint shape must still be
58
+ confirmed against a live tenant before the documented contract is trusted.
59
+ """
60
+ if isinstance(data, list):
61
+ return data
62
+ if isinstance(data, dict):
63
+ for key in keys:
64
+ value = data.get(key)
65
+ if isinstance(value, list):
66
+ return value
67
+ return []
68
+
69
+
70
+ def total_count(data: Any, fallback: int) -> int | None:
71
+ """Pull a total/count from a wrapped response; None if not advertised."""
72
+ if isinstance(data, dict):
73
+ for key in ("total", "count", "total_count"):
74
+ value = data.get(key)
75
+ if isinstance(value, int):
76
+ return value
77
+ return None
78
+
79
+
80
+ def build_query(query: str | None, status: str | None) -> str | None:
81
+ """Compose a BPQL query string from a raw query and/or a status filter.
82
+
83
+ If the caller passes an explicit ``query`` it wins as-is. Otherwise a bare
84
+ ``status`` is lifted into BPQL (``status = "<status>"``). Returns None when
85
+ neither is supplied (search all).
86
+ """
87
+ query = (query or "").strip()
88
+ status = (status or "").strip()
89
+ if query:
90
+ return query
91
+ if status:
92
+ # BPQL string literals are double-quoted; escape embedded quotes.
93
+ escaped = status.replace('"', '\\"')
94
+ return f'status = "{escaped}"'
95
+ return None