talyx-mcp 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. talyx_mcp-0.0.1/.github/workflows/ci.yaml +28 -0
  2. talyx_mcp-0.0.1/.gitignore +15 -0
  3. talyx_mcp-0.0.1/LICENSE +202 -0
  4. talyx_mcp-0.0.1/PKG-INFO +157 -0
  5. talyx_mcp-0.0.1/README.md +142 -0
  6. talyx_mcp-0.0.1/README.zh-TW.md +133 -0
  7. talyx_mcp-0.0.1/alerts/mcp-rules.yaml +116 -0
  8. talyx_mcp-0.0.1/dashboards/mcp-overview.json +173 -0
  9. talyx_mcp-0.0.1/deploy/compose/Dockerfile.demo +20 -0
  10. talyx_mcp-0.0.1/deploy/compose/alertmanager.yml +12 -0
  11. talyx_mcp-0.0.1/deploy/compose/demo.yaml +59 -0
  12. talyx_mcp-0.0.1/deploy/compose/driver.py +55 -0
  13. talyx_mcp-0.0.1/deploy/compose/grafana/provisioning/dashboards/provider.yml +10 -0
  14. talyx_mcp-0.0.1/deploy/compose/grafana/provisioning/datasources/datasource.yml +9 -0
  15. talyx_mcp-0.0.1/deploy/compose/prometheus.yml +16 -0
  16. talyx_mcp-0.0.1/deploy/docker/Dockerfile +15 -0
  17. talyx_mcp-0.0.1/docs/architecture.md +82 -0
  18. talyx_mcp-0.0.1/docs/architecture.zh-TW.md +59 -0
  19. talyx_mcp-0.0.1/docs/metrics.md +111 -0
  20. talyx_mcp-0.0.1/docs/metrics.zh-TW.md +104 -0
  21. talyx_mcp-0.0.1/pyproject.toml +47 -0
  22. talyx_mcp-0.0.1/src/talyx/__init__.py +1 -0
  23. talyx_mcp-0.0.1/src/talyx/cli.py +97 -0
  24. talyx_mcp-0.0.1/src/talyx/config.py +39 -0
  25. talyx_mcp-0.0.1/src/talyx/metrics/__init__.py +0 -0
  26. talyx_mcp-0.0.1/src/talyx/metrics/registry.py +227 -0
  27. talyx_mcp-0.0.1/src/talyx/metrics/server.py +28 -0
  28. talyx_mcp-0.0.1/src/talyx/mock/__init__.py +2 -0
  29. talyx_mcp-0.0.1/src/talyx/mock/driver.py +134 -0
  30. talyx_mcp-0.0.1/src/talyx/mock/server.py +116 -0
  31. talyx_mcp-0.0.1/src/talyx/proxy/__init__.py +0 -0
  32. talyx_mcp-0.0.1/src/talyx/proxy/jsonrpc.py +379 -0
  33. talyx_mcp-0.0.1/src/talyx/proxy/stdio.py +187 -0
  34. talyx_mcp-0.0.1/src/talyx/telemetry.py +45 -0
  35. talyx_mcp-0.0.1/tests/e2e/.gitkeep +0 -0
  36. talyx_mcp-0.0.1/tests/e2e/test_cycle_e2e.py +121 -0
  37. talyx_mcp-0.0.1/tests/e2e/test_metrics_e2e.py +87 -0
  38. talyx_mcp-0.0.1/tests/e2e/test_pty_large_message.py +69 -0
  39. talyx_mcp-0.0.1/tests/e2e/test_redirected_output.py +58 -0
  40. talyx_mcp-0.0.1/tests/e2e/test_stdio_proxy.py +69 -0
  41. talyx_mcp-0.0.1/tests/unit/test_cli.py +52 -0
  42. talyx_mcp-0.0.1/tests/unit/test_cycles.py +287 -0
  43. talyx_mcp-0.0.1/tests/unit/test_jsonrpc.py +169 -0
  44. talyx_mcp-0.0.1/tests/unit/test_metrics_server.py +42 -0
  45. talyx_mcp-0.0.1/tests/unit/test_mock_server.py +72 -0
  46. talyx_mcp-0.0.1/tests/unit/test_registry.py +120 -0
  47. talyx_mcp-0.0.1/tests/unit/test_smoke.py +7 -0
  48. talyx_mcp-0.0.1/tests/unit/test_telemetry.py +46 -0
@@ -0,0 +1,28 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ lint-and-test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Set up Python
15
+ uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.11"
18
+
19
+ - name: Install dependencies
20
+ run: |
21
+ python -m pip install --upgrade pip
22
+ pip install -e . --group dev
23
+
24
+ - name: Lint (ruff)
25
+ run: ruff check .
26
+
27
+ - name: Test (pytest)
28
+ run: pytest
@@ -0,0 +1,15 @@
1
+ # Claude Code local settings
2
+ .claude
3
+ /CLAUDE.md
4
+
5
+ # Python
6
+ __pycache__/
7
+ *.pyc
8
+ .venv/
9
+ *.egg-info/
10
+ .pytest_cache/
11
+ .ruff_cache/
12
+ build/
13
+ dist/
14
+
15
+ docs/migration-2026-07-28.md
@@ -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,157 @@
1
+ Metadata-Version: 2.4
2
+ Name: talyx-mcp
3
+ Version: 0.0.1
4
+ Summary: Prometheus exporter and alerting proxy for MCP servers
5
+ Author: Tsung-Yao Chen
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.11
9
+ Requires-Dist: opentelemetry-exporter-prometheus>=0.65b0
10
+ Requires-Dist: opentelemetry-sdk>=1.44
11
+ Requires-Dist: prometheus-client>=0.20
12
+ Provides-Extra: otlp
13
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.44; extra == 'otlp'
14
+ Description-Content-Type: text/markdown
15
+
16
+ # Talyx
17
+
18
+ English | [繁體中文](README.zh-TW.md)
19
+
20
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
21
+ [![Python](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
22
+ [![MCP Spec](https://img.shields.io/badge/MCP-2026--07--28-green.svg)](https://modelcontextprotocol.io)
23
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
24
+
25
+ **Prometheus exporter and alerting for MCP servers.** When your MCP server breaks, your users just see a broken agent—you see exactly which server failed, how slow it got, and when. Wrap any stdio server, **zero code changes**.
26
+
27
+ Talyx is a **zero-code proxy**: it sits between your MCP client and server,
28
+ forwards the stdio JSON-RPC untouched, and exports Prometheus metrics about the
29
+ traffic. It ships with a Grafana dashboard and Alertmanager rules. It is
30
+ **stateless** — no database, Prometheus just scrapes `/metrics`.
31
+
32
+ ```mermaid
33
+ flowchart LR
34
+ client["MCP client"] <-->|stdio JSON-RPC| talyx["talyx<br/>(proxy + exporter)"]
35
+ talyx <-->|stdio JSON-RPC| server["your MCP server"]
36
+ talyx -->|/metrics :9464| prom["Prometheus"] --> grafana["Grafana"]
37
+ prom --> am["Alertmanager"]
38
+ ```
39
+
40
+ ## Table of Contents
41
+
42
+ - [Talyx](#talyx)
43
+ - [Table of Contents](#table-of-contents)
44
+ - [Quickstart (the demo)](#quickstart-the-demo)
45
+ - [Use it on your own server](#use-it-on-your-own-server)
46
+ - [Metrics](#metrics)
47
+ - [How it works](#how-it-works)
48
+ - [Roadmap](#roadmap)
49
+ - [License](#license)
50
+ - [Author](#author)
51
+
52
+ ## Quickstart (the demo)
53
+
54
+ Runs talyx + a sample MCP server + Prometheus + Alertmanager + Grafana, with
55
+ live traffic, in one command:
56
+
57
+ ```bash
58
+ git clone https://github.com/alan66603/talyx.git
59
+ cd talyx
60
+ docker compose -f deploy/compose/demo.yaml up --build
61
+ ```
62
+
63
+ Then open **http://localhost:3000** → dashboard **MCP Overview** (anonymous, no
64
+ login). You'll see request rate, error rate, p95 latency, and the flagship
65
+ **Multi Round-Trip** panels — elicitation loops, round-trips per request, and
66
+ **abandoned cycles** (agents silently stuck waiting on a confirmation) — updating
67
+ live. Prometheus is on `:9090`, Alertmanager on `:9093`.
68
+
69
+ ## Use it on your own server
70
+
71
+ Point your MCP client at `talyx` instead of the server, and pass the real
72
+ command after `--`:
73
+
74
+ ```jsonc
75
+ // before
76
+ { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-everything"] }
77
+
78
+ // after — same server, now observed
79
+ { "command": "talyx", "args": ["--", "npx", "-y", "@modelcontextprotocol/server-everything"] }
80
+ ```
81
+
82
+ Metrics are then at `http://localhost:9464/metrics`. Install with
83
+ `pip install .` (or use the image at `deploy/docker/Dockerfile`). Configure the
84
+ port with `TALYX_METRICS_PORT` / `TALYX_METRICS_HOST`. To also push metrics
85
+ over OTLP, set `TALYX_OTLP_ENDPOINT` and install the extra:
86
+ `pip install '.[otlp]'` (Prometheus `/metrics` stays on regardless).
87
+
88
+ > The flagship cycle metrics need a server that speaks MCP `2026-07-28`
89
+ > (`InputRequiredResult`). Wrapping an older server still gives you the core
90
+ > reliability metrics; to see the cycle panels, try the bundled mock server:
91
+ > `talyx -- python -m talyx.mock.server`.
92
+
93
+ ## Metrics
94
+
95
+ Aligned to the MCP `2026-07-28` (stateless) spec. Full reference:
96
+ [docs/metrics.md](docs/metrics.md).
97
+
98
+ **Core reliability**
99
+
100
+ | Metric | Type | Labels |
101
+ |---|---|---|
102
+ | `talyx_requests_total` | counter | `method`, `server`, `status` |
103
+ | `talyx_request_duration_seconds` | histogram | `method`, `server` |
104
+ | `talyx_errors_total` | counter | `method`, `server`, `error_code` |
105
+
106
+ **Multi Round-Trip cycles — the flagship.** In MCP's latest version, `2026-07-28` server can answer a
107
+ `tools/call` with an `InputRequiredResult` and the client re-sends with the
108
+ server's `requestState`; that elicitation loop is one *logical* request that
109
+ generic APM reads as two unrelated ones.
110
+
111
+ | Metric | Type | Labels |
112
+ |---|---|---|
113
+ | `talyx_input_required_total` | counter | `method`, `server`, `wait_type` |
114
+ | `talyx_round_trips_per_request` | histogram | `wait_type` |
115
+ | `talyx_round_trip_cycle_duration_seconds` | histogram | `wait_type` |
116
+ | `talyx_input_wait_duration_seconds` | histogram | `server`, `wait_type` |
117
+ | `talyx_abandoned_cycles_total` | counter | `server`, `wait_type` |
118
+ | `talyx_request_state_rejected_total` | counter | `server` |
119
+
120
+ Plus basic liveness (`talyx_server_up`, `talyx_inflight_requests_lost_total`) and
121
+ `talyx_proxy_overhead_seconds`.
122
+
123
+ **`talyx_abandoned_cycles_total`** counts cycles where the server sent an
124
+ `InputRequired` but got no follow-up. No error, no timeout, which can be overlooked. A single count means little (users pause or walk away), but a spike
125
+ above baseline usually signals a broken or confusing prompt, especially around
126
+ high-risk `InputRequiredResult` gates.
127
+
128
+ **Security:** Talyx records *no tool arguments* and no message bodies — only
129
+ method/tool names, outcomes, and timings. The one correlation key it needs (the
130
+ sealed `requestState` token) is **hashed in memory and never stored** See [docs/metrics.md](docs/metrics.md).
131
+
132
+ **Overhead:** talyx's own per-chunk processing is sub-millisecond
133
+ (`talyx_proxy_overhead_seconds`), so it doesn't meaningfully slow the server down.
134
+
135
+ ## How it works
136
+
137
+ The proxy forwards bytes in both directions untouched and observes the
138
+ JSON-RPC as a side-channel — if observation ever fails, forwarding is
139
+ unaffected. It's stateless by design, which is the core difference from
140
+ trace-based tools. See [docs/architecture.md](docs/architecture.md)
141
+ for the positioning table and the "why a proxy, not an SDK" rationale.
142
+
143
+ ## Roadmap
144
+
145
+ Optional OTLP **metrics** export already ships (`TALYX_OTLP_ENDPOINT`), and
146
+ the proxy forwards W3C `traceparent` untouched. Still ahead: OTLP **trace/span**
147
+ export (to your own Tempo/Jaeger), HTTP transport + OAuth, a Helm chart, and
148
+ optional body capture. Token usage isn't visible in MCP protocol traffic, so
149
+ Talyx does not claim token metrics.
150
+
151
+ ## License
152
+
153
+ Apache-2.0. See [LICENSE](LICENSE).
154
+
155
+ ## Author
156
+
157
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-0A66C2?logo=linkedin)](https://www.linkedin.com/in/tsung-yao-chen-75481718b)
@@ -0,0 +1,142 @@
1
+ # Talyx
2
+
3
+ English | [繁體中文](README.zh-TW.md)
4
+
5
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
6
+ [![Python](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
7
+ [![MCP Spec](https://img.shields.io/badge/MCP-2026--07--28-green.svg)](https://modelcontextprotocol.io)
8
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
9
+
10
+ **Prometheus exporter and alerting for MCP servers.** When your MCP server breaks, your users just see a broken agent—you see exactly which server failed, how slow it got, and when. Wrap any stdio server, **zero code changes**.
11
+
12
+ Talyx is a **zero-code proxy**: it sits between your MCP client and server,
13
+ forwards the stdio JSON-RPC untouched, and exports Prometheus metrics about the
14
+ traffic. It ships with a Grafana dashboard and Alertmanager rules. It is
15
+ **stateless** — no database, Prometheus just scrapes `/metrics`.
16
+
17
+ ```mermaid
18
+ flowchart LR
19
+ client["MCP client"] <-->|stdio JSON-RPC| talyx["talyx<br/>(proxy + exporter)"]
20
+ talyx <-->|stdio JSON-RPC| server["your MCP server"]
21
+ talyx -->|/metrics :9464| prom["Prometheus"] --> grafana["Grafana"]
22
+ prom --> am["Alertmanager"]
23
+ ```
24
+
25
+ ## Table of Contents
26
+
27
+ - [Talyx](#talyx)
28
+ - [Table of Contents](#table-of-contents)
29
+ - [Quickstart (the demo)](#quickstart-the-demo)
30
+ - [Use it on your own server](#use-it-on-your-own-server)
31
+ - [Metrics](#metrics)
32
+ - [How it works](#how-it-works)
33
+ - [Roadmap](#roadmap)
34
+ - [License](#license)
35
+ - [Author](#author)
36
+
37
+ ## Quickstart (the demo)
38
+
39
+ Runs talyx + a sample MCP server + Prometheus + Alertmanager + Grafana, with
40
+ live traffic, in one command:
41
+
42
+ ```bash
43
+ git clone https://github.com/alan66603/talyx.git
44
+ cd talyx
45
+ docker compose -f deploy/compose/demo.yaml up --build
46
+ ```
47
+
48
+ Then open **http://localhost:3000** → dashboard **MCP Overview** (anonymous, no
49
+ login). You'll see request rate, error rate, p95 latency, and the flagship
50
+ **Multi Round-Trip** panels — elicitation loops, round-trips per request, and
51
+ **abandoned cycles** (agents silently stuck waiting on a confirmation) — updating
52
+ live. Prometheus is on `:9090`, Alertmanager on `:9093`.
53
+
54
+ ## Use it on your own server
55
+
56
+ Point your MCP client at `talyx` instead of the server, and pass the real
57
+ command after `--`:
58
+
59
+ ```jsonc
60
+ // before
61
+ { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-everything"] }
62
+
63
+ // after — same server, now observed
64
+ { "command": "talyx", "args": ["--", "npx", "-y", "@modelcontextprotocol/server-everything"] }
65
+ ```
66
+
67
+ Metrics are then at `http://localhost:9464/metrics`. Install with
68
+ `pip install .` (or use the image at `deploy/docker/Dockerfile`). Configure the
69
+ port with `TALYX_METRICS_PORT` / `TALYX_METRICS_HOST`. To also push metrics
70
+ over OTLP, set `TALYX_OTLP_ENDPOINT` and install the extra:
71
+ `pip install '.[otlp]'` (Prometheus `/metrics` stays on regardless).
72
+
73
+ > The flagship cycle metrics need a server that speaks MCP `2026-07-28`
74
+ > (`InputRequiredResult`). Wrapping an older server still gives you the core
75
+ > reliability metrics; to see the cycle panels, try the bundled mock server:
76
+ > `talyx -- python -m talyx.mock.server`.
77
+
78
+ ## Metrics
79
+
80
+ Aligned to the MCP `2026-07-28` (stateless) spec. Full reference:
81
+ [docs/metrics.md](docs/metrics.md).
82
+
83
+ **Core reliability**
84
+
85
+ | Metric | Type | Labels |
86
+ |---|---|---|
87
+ | `talyx_requests_total` | counter | `method`, `server`, `status` |
88
+ | `talyx_request_duration_seconds` | histogram | `method`, `server` |
89
+ | `talyx_errors_total` | counter | `method`, `server`, `error_code` |
90
+
91
+ **Multi Round-Trip cycles — the flagship.** In MCP's latest version, `2026-07-28` server can answer a
92
+ `tools/call` with an `InputRequiredResult` and the client re-sends with the
93
+ server's `requestState`; that elicitation loop is one *logical* request that
94
+ generic APM reads as two unrelated ones.
95
+
96
+ | Metric | Type | Labels |
97
+ |---|---|---|
98
+ | `talyx_input_required_total` | counter | `method`, `server`, `wait_type` |
99
+ | `talyx_round_trips_per_request` | histogram | `wait_type` |
100
+ | `talyx_round_trip_cycle_duration_seconds` | histogram | `wait_type` |
101
+ | `talyx_input_wait_duration_seconds` | histogram | `server`, `wait_type` |
102
+ | `talyx_abandoned_cycles_total` | counter | `server`, `wait_type` |
103
+ | `talyx_request_state_rejected_total` | counter | `server` |
104
+
105
+ Plus basic liveness (`talyx_server_up`, `talyx_inflight_requests_lost_total`) and
106
+ `talyx_proxy_overhead_seconds`.
107
+
108
+ **`talyx_abandoned_cycles_total`** counts cycles where the server sent an
109
+ `InputRequired` but got no follow-up. No error, no timeout, which can be overlooked. A single count means little (users pause or walk away), but a spike
110
+ above baseline usually signals a broken or confusing prompt, especially around
111
+ high-risk `InputRequiredResult` gates.
112
+
113
+ **Security:** Talyx records *no tool arguments* and no message bodies — only
114
+ method/tool names, outcomes, and timings. The one correlation key it needs (the
115
+ sealed `requestState` token) is **hashed in memory and never stored** See [docs/metrics.md](docs/metrics.md).
116
+
117
+ **Overhead:** talyx's own per-chunk processing is sub-millisecond
118
+ (`talyx_proxy_overhead_seconds`), so it doesn't meaningfully slow the server down.
119
+
120
+ ## How it works
121
+
122
+ The proxy forwards bytes in both directions untouched and observes the
123
+ JSON-RPC as a side-channel — if observation ever fails, forwarding is
124
+ unaffected. It's stateless by design, which is the core difference from
125
+ trace-based tools. See [docs/architecture.md](docs/architecture.md)
126
+ for the positioning table and the "why a proxy, not an SDK" rationale.
127
+
128
+ ## Roadmap
129
+
130
+ Optional OTLP **metrics** export already ships (`TALYX_OTLP_ENDPOINT`), and
131
+ the proxy forwards W3C `traceparent` untouched. Still ahead: OTLP **trace/span**
132
+ export (to your own Tempo/Jaeger), HTTP transport + OAuth, a Helm chart, and
133
+ optional body capture. Token usage isn't visible in MCP protocol traffic, so
134
+ Talyx does not claim token metrics.
135
+
136
+ ## License
137
+
138
+ Apache-2.0. See [LICENSE](LICENSE).
139
+
140
+ ## Author
141
+
142
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-0A66C2?logo=linkedin)](https://www.linkedin.com/in/tsung-yao-chen-75481718b)
@@ -0,0 +1,133 @@
1
+ # Talyx
2
+
3
+ [English](README.md) | 繁體中文
4
+
5
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
6
+ [![Python](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
7
+ [![MCP Spec](https://img.shields.io/badge/MCP-2026--07--28-green.svg)](https://modelcontextprotocol.io)
8
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
9
+
10
+ **給 MCP server 用的 Prometheus 匯出器與告警工具。** 把它包在任何 stdio MCP server
11
+ 外面,**不必改一行程式碼**,就能在 server 壞掉或變慢的當下馬上知道,且讓你可以確切知道壞掉的地方。
12
+
13
+ Talyx 是一個 zero-code proxy:它坐在你的 MCP client 與 server 之間,原封不動地轉發
14
+ stdio JSON-RPC,並把流量的 Prometheus 指標匯出。內附一組 Grafana dashboard 與
15
+ Alertmanager 規則。它是 **stateless** 的——沒有資料庫,Prometheus 直接抓 `/metrics`。
16
+
17
+ ```mermaid
18
+ flowchart LR
19
+ client["MCP client"] <-->|stdio JSON-RPC| talyx["talyx<br/>(proxy + exporter)"]
20
+ talyx <-->|stdio JSON-RPC| server["your MCP server"]
21
+ talyx -->|/metrics :9464| prom["Prometheus"] --> grafana["Grafana"]
22
+ prom --> am["Alertmanager"]
23
+ ```
24
+
25
+ ## 目錄
26
+
27
+ - [Talyx](#talyx)
28
+ - [目錄](#目錄)
29
+ - [Quick Start](#quick-start)
30
+ - [如何用在你自己的 server](#如何用在你自己的-server)
31
+ - [指標](#指標)
32
+ - [運作方式](#運作方式)
33
+ - [Roadmap](#roadmap)
34
+ - [License](#license)
35
+ - [作者](#作者)
36
+
37
+ ## Quick Start
38
+
39
+ 一行指令跑起 talyx + 一個範例 MCP server + Prometheus + Alertmanager + Grafana,
40
+ 外加即時流量:
41
+
42
+ ```bash
43
+ git clone https://github.com/alan66603/talyx.git
44
+ cd talyx
45
+ docker compose -f deploy/compose/demo.yaml up --build
46
+ ```
47
+
48
+ 接著打開 **http://localhost:3000** → dashboard **MCP Overview**(匿名,免登入)。
49
+ 你會看到 request rate、error rate、p95 latency,以及招牌的 **Multi Round-Trip** 面板
50
+ ——elicitation 循環、每個請求的往返次數,還有 **abandoned cycles**(agent 靜默卡在
51
+ 等一個永遠不來的確認)——全部即時更新。Prometheus 在 `:9090`,Alertmanager 在 `:9093`。
52
+
53
+ ## 如何用在你自己的 server
54
+
55
+ 把你的 MCP client 指向 `talyx`(而不是 server),真正的指令放在 `--` 後面:
56
+
57
+ ```jsonc
58
+ // 改之前
59
+ { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-everything"] }
60
+
61
+ // 改之後——同一個 server,現在被觀測了
62
+ { "command": "talyx", "args": ["--", "npx", "-y", "@modelcontextprotocol/server-everything"] }
63
+ ```
64
+
65
+ 指標就會在 `http://localhost:9464/metrics`。用 `pip install .` 安裝(或用
66
+ `deploy/docker/Dockerfile` 的映像)。用 `TALYX_METRICS_PORT` / `TALYX_METRICS_HOST`
67
+ 設定埠號。若還想把指標推到 OTLP,設 `TALYX_OTLP_ENDPOINT` 並裝上額外相依:
68
+ `pip install '.[otlp]'`(Prometheus `/metrics` 一律照常開著)。
69
+
70
+ > 招牌的循環指標需要一個講 MCP `2026-07-28`(會回 `InputRequiredResult`)的 server。
71
+ > 包在舊 server 上仍能拿到核心可靠性指標;想看循環面板,可以用內附的 mock server:
72
+ > `talyx -- python -m talyx.mock.server`。
73
+
74
+ ## 指標
75
+
76
+ 對齊 MCP `2026-07-28`(stateless)規格。完整參考:[docs/metrics.zh-TW.md](docs/metrics.zh-TW.md)。
77
+
78
+ **核心可靠性**
79
+
80
+ | 指標 | 型別 | Labels |
81
+ |---|---|---|
82
+ | `talyx_requests_total` | counter | `method`、`server`、`status` |
83
+ | `talyx_request_duration_seconds` | histogram | `method`、`server` |
84
+ | `talyx_errors_total` | counter | `method`、`server`、`error_code` |
85
+
86
+ **Multi Round-Trip 循環** MCP `2026-07-28` 版本更新後,server 可以用
87
+ `InputRequiredResult` 回應 `tools/call`,client 再帶著 server 的 `requestState` 重送;
88
+ 這個 elicitation 循環是**一個**邏輯請求,但通用 APM 會把它讀成兩個不相干的請求。
89
+
90
+ | 指標 | 型別 | Labels |
91
+ |---|---|---|
92
+ | `talyx_input_required_total` | counter | `method`、`server`、`wait_type` |
93
+ | `talyx_round_trips_per_request` | histogram | `wait_type` |
94
+ | `talyx_round_trip_cycle_duration_seconds` | histogram | `wait_type` |
95
+ | `talyx_input_wait_duration_seconds` | histogram | `server`、`wait_type` |
96
+ | `talyx_abandoned_cycles_total` | counter | `server`、`wait_type` |
97
+ | `talyx_request_state_rejected_total` | counter | `server` |
98
+
99
+ 另有基礎 liveness(`talyx_server_up`、`talyx_inflight_requests_lost_total`)與
100
+ `talyx_proxy_overhead_seconds`。
101
+
102
+ **`talyx_abandoned_cycles_total`** 記錄 server 發出 `InputRequired` 卻沒等到
103
+ 回覆的循環。這在新版本不算 error 也沒有 timeout, 因此是容易被忽略的行爲。單次計數並無代表性(使用者可能
104
+ 只是離開),但比率異常升高可能表示提示壞了或令人困惑,在高風險的
105
+ `InputRequiredResult` 把關處值得參考。
106
+
107
+ **隱私與安全:** Talyx **不記錄任何 tool 參數**、不記錄訊息內容,只取 method/tool
108
+ 名稱、結果與時間。它唯一需要的關聯鍵(密封的 `requestState` token)**在記憶體內雜湊、
109
+ 絕不落地**。詳見 [docs/metrics.zh-TW.md](docs/metrics.zh-TW.md)。
110
+
111
+ **額外開銷:** talyx 自身每個 chunk 的處理是次毫秒等級(`talyx_proxy_overhead_seconds`),
112
+ 所以不會實質拖慢 server。
113
+
114
+ ## 運作方式
115
+
116
+ proxy 在兩個方向都原封轉發位元組,把 JSON-RPC 當旁路(side-channel)觀測——就算觀測
117
+ 失敗,轉發也不受影響。它天生 stateless,這是與 trace 類工具的核心
118
+ 差異。
119
+
120
+ ## Roadmap
121
+
122
+ 可選的 OTLP **metrics** 匯出已經有了(`TALYX_OTLP_ENDPOINT`),proxy 也會原封轉發
123
+ W3C `traceparent`。還在路上:OTLP **trace/span** 匯出(推到你自己的 Tempo/Jaeger)、
124
+ HTTP transport + OAuth、Helm chart,以及可選的 body capture。token 用量在 MCP 協定
125
+ 流量中看不到,所以 Talyx 刻意不宣稱 token 指標。
126
+
127
+ ## License
128
+
129
+ Apache-2.0。見 [LICENSE](LICENSE)。
130
+
131
+ ## 作者
132
+
133
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-0A66C2?logo=linkedin)](https://www.linkedin.com/in/tsung-yao-chen-75481718b)