algony-mymcp 2.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 (68) hide show
  1. algony_mymcp-2.0.0/.env.example +27 -0
  2. algony_mymcp-2.0.0/.pre-commit-config.yaml +16 -0
  3. algony_mymcp-2.0.0/CHANGELOG.md +110 -0
  4. algony_mymcp-2.0.0/LICENSE +190 -0
  5. algony_mymcp-2.0.0/PKG-INFO +347 -0
  6. algony_mymcp-2.0.0/README.md +305 -0
  7. algony_mymcp-2.0.0/deploy/UPGRADE_NOTES.md +16 -0
  8. algony_mymcp-2.0.0/deploy/grafana/README.md +103 -0
  9. algony_mymcp-2.0.0/deploy/grafana/mymcp-dashboard.json +702 -0
  10. algony_mymcp-2.0.0/deploy/install.sh +229 -0
  11. algony_mymcp-2.0.0/deploy/install_lib.sh +506 -0
  12. algony_mymcp-2.0.0/deploy/logrotate.mymcp-upgrade +9 -0
  13. algony_mymcp-2.0.0/deploy/mymcp.service +17 -0
  14. algony_mymcp-2.0.0/deploy/upgrade.sh +552 -0
  15. algony_mymcp-2.0.0/pyproject.toml +101 -0
  16. algony_mymcp-2.0.0/scripts/fetch-ripgrep.sh +30 -0
  17. algony_mymcp-2.0.0/scripts/install-offline.sh +44 -0
  18. algony_mymcp-2.0.0/setup.cfg +4 -0
  19. algony_mymcp-2.0.0/src/algony_mymcp.egg-info/PKG-INFO +347 -0
  20. algony_mymcp-2.0.0/src/algony_mymcp.egg-info/SOURCES.txt +66 -0
  21. algony_mymcp-2.0.0/src/algony_mymcp.egg-info/dependency_links.txt +1 -0
  22. algony_mymcp-2.0.0/src/algony_mymcp.egg-info/entry_points.txt +2 -0
  23. algony_mymcp-2.0.0/src/algony_mymcp.egg-info/requires.txt +20 -0
  24. algony_mymcp-2.0.0/src/algony_mymcp.egg-info/top_level.txt +1 -0
  25. algony_mymcp-2.0.0/src/mymcp/__init__.py +13 -0
  26. algony_mymcp-2.0.0/src/mymcp/__main__.py +8 -0
  27. algony_mymcp-2.0.0/src/mymcp/_version.py +24 -0
  28. algony_mymcp-2.0.0/src/mymcp/audit.py +77 -0
  29. algony_mymcp-2.0.0/src/mymcp/auth.py +162 -0
  30. algony_mymcp-2.0.0/src/mymcp/cli.py +488 -0
  31. algony_mymcp-2.0.0/src/mymcp/config.py +133 -0
  32. algony_mymcp-2.0.0/src/mymcp/deploy/__init__.py +1 -0
  33. algony_mymcp-2.0.0/src/mymcp/deploy/migrate.py +36 -0
  34. algony_mymcp-2.0.0/src/mymcp/deploy/service.py +114 -0
  35. algony_mymcp-2.0.0/src/mymcp/deploy/setup.py +76 -0
  36. algony_mymcp-2.0.0/src/mymcp/deploy/templates/mymcp.service.in +14 -0
  37. algony_mymcp-2.0.0/src/mymcp/mcp_server.py +381 -0
  38. algony_mymcp-2.0.0/src/mymcp/metrics.py +24 -0
  39. algony_mymcp-2.0.0/src/mymcp/server.py +138 -0
  40. algony_mymcp-2.0.0/src/mymcp/tools/__init__.py +0 -0
  41. algony_mymcp-2.0.0/src/mymcp/tools/bash.py +133 -0
  42. algony_mymcp-2.0.0/src/mymcp/tools/files.py +336 -0
  43. algony_mymcp-2.0.0/tests/test_admin.py +160 -0
  44. algony_mymcp-2.0.0/tests/test_audit.py +156 -0
  45. algony_mymcp-2.0.0/tests/test_auth.py +201 -0
  46. algony_mymcp-2.0.0/tests/test_bash.py +72 -0
  47. algony_mymcp-2.0.0/tests/test_bash_signal_cleanup.py +52 -0
  48. algony_mymcp-2.0.0/tests/test_benchmark.py +190 -0
  49. algony_mymcp-2.0.0/tests/test_boundary.py +344 -0
  50. algony_mymcp-2.0.0/tests/test_clamping.py +224 -0
  51. algony_mymcp-2.0.0/tests/test_cli.py +52 -0
  52. algony_mymcp-2.0.0/tests/test_config_settings.py +76 -0
  53. algony_mymcp-2.0.0/tests/test_deploy_migrate.py +35 -0
  54. algony_mymcp-2.0.0/tests/test_deploy_service.py +51 -0
  55. algony_mymcp-2.0.0/tests/test_deploy_setup.py +97 -0
  56. algony_mymcp-2.0.0/tests/test_doctor.py +8 -0
  57. algony_mymcp-2.0.0/tests/test_files.py +570 -0
  58. algony_mymcp-2.0.0/tests/test_install_service_cli.py +117 -0
  59. algony_mymcp-2.0.0/tests/test_integration.py +334 -0
  60. algony_mymcp-2.0.0/tests/test_main.py +224 -0
  61. algony_mymcp-2.0.0/tests/test_mcp.py +410 -0
  62. algony_mymcp-2.0.0/tests/test_metrics.py +219 -0
  63. algony_mymcp-2.0.0/tests/test_permissions.py +44 -0
  64. algony_mymcp-2.0.0/tests/test_protected_paths.py +128 -0
  65. algony_mymcp-2.0.0/tests/test_security.py +390 -0
  66. algony_mymcp-2.0.0/tests/test_server_factory.py +39 -0
  67. algony_mymcp-2.0.0/tests/test_token_cli.py +90 -0
  68. algony_mymcp-2.0.0/tests/test_version.py +73 -0
@@ -0,0 +1,27 @@
1
+ # --- Core ---
2
+ MCP_HOST=0.0.0.0
3
+ MCP_PORT=8765
4
+ MCP_TOKEN_FILE=./tokens.json
5
+ MCP_ADMIN_TOKEN=adm_change_me
6
+
7
+ # --- Protected paths ---
8
+ MCP_APP_DIR=/opt/mymcp
9
+ # MCP_PROTECTED_PATHS=/extra/path1,/extra/path2
10
+
11
+ # --- Audit logging ---
12
+ # MCP_AUDIT_ENABLED=true
13
+ # MCP_AUDIT_LOG_DIR=/var/log/mymcp
14
+ # MCP_AUDIT_MAX_BYTES=10485760
15
+ # MCP_AUDIT_BACKUP_COUNT=5
16
+
17
+ # --- Tool limits (uncomment to override defaults) ---
18
+ # MCP_BASH_MAX_OUTPUT_BYTES=102400
19
+ # MCP_BASH_MAX_OUTPUT_BYTES_HARD=1048576
20
+ # MCP_READ_FILE_DEFAULT_LIMIT=2000
21
+ # MCP_READ_FILE_MAX_LIMIT=50000
22
+ # MCP_READ_FILE_MAX_LINE_BYTES=32768
23
+ # MCP_WRITE_FILE_MAX_BYTES=10485760
24
+ # MCP_EDIT_STRING_MAX_BYTES=1048576
25
+ # MCP_GLOB_MAX_RESULTS=1000
26
+ # MCP_GREP_DEFAULT_MAX_RESULTS=500
27
+ # MCP_GREP_MAX_RESULTS=5000
@@ -0,0 +1,16 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.6.0
4
+ hooks:
5
+ - id: ruff
6
+ args: [--fix]
7
+ - id: ruff-format
8
+ - repo: https://github.com/pre-commit/mirrors-mypy
9
+ rev: v1.11.0
10
+ hooks:
11
+ - id: mypy
12
+ files: ^src/mymcp/
13
+ additional_dependencies:
14
+ - pydantic>=2
15
+ - pydantic-settings>=2
16
+ - types-setuptools
@@ -0,0 +1,110 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [2.0.0] - 2026-04-28
11
+
12
+ ### Breaking changes
13
+ - Environment variables: `MCP_*` → `MYMCP_*` (no compat). Migrate with `mymcp migrate-from-legacy`.
14
+ - Install layout: code via `pipx`; config moved from `/opt/mymcp/` to `/etc/mymcp/`.
15
+ - Install method: `pipx install algony-mymcp` replaces `git clone + deploy/install.sh`. (PyPI distribution name is `algony-mymcp`; CLI command and import path are still `mymcp`.)
16
+ - `MCP_APP_DIR` is removed. Protected paths now derive from the audit log dir + `MYMCP_PROTECTED_PATHS` only.
17
+
18
+ ### Added
19
+ - `mymcp` CLI with subcommands: `serve`, `install-service`, `uninstall-service`,
20
+ `token list/add/revoke/rotate-admin/rotate-metrics/disable-metrics`,
21
+ `migrate-from-legacy`, `doctor`, `version`.
22
+ - `pipx install algony-mymcp` workflow with `setuptools-scm`-derived versions.
23
+ - pydantic-settings-based config with typed defaults.
24
+ - Bash subprocess SIGTERM cleanup: in-flight bash children get TERM/KILL with
25
+ configurable grace via `MYMCP_SHUTDOWN_GRACE_SEC`.
26
+ - Offline bundle (`mymcp-X.Y.Z-offline-bundle.tar.gz`) attached to GitHub Releases
27
+ for air-gapped installs.
28
+ - ruff + mypy + pre-commit configuration; CI matrix on Python 3.11/3.12/3.13.
29
+ - Tag-triggered release workflow: build wheel + offline bundle, publish to PyPI
30
+ via OIDC Trusted Publisher, attach artifacts to GitHub Release.
31
+
32
+ ### Changed
33
+ - `main.py` split into `src/mymcp/server.py` (FastAPI factory, no import
34
+ side-effects) and `src/mymcp/cli.py` (argparse + logging + signal handlers).
35
+ - Logging is configured at CLI entry, not module import. Supports `--log-level`
36
+ and `--log-format text|json`.
37
+
38
+ ### Removed
39
+ - `VERSION`, `requirements.txt`, `requirements-dev.txt` (replaced by `pyproject.toml`).
40
+ - The flat-layout source files at the repo root.
41
+
42
+ ### Deprecated
43
+ - `deploy/install.sh` and `deploy/upgrade.sh` remain in-repo through the 2.0.x
44
+ series for 1.x users; new installs should use the `mymcp` CLI.
45
+
46
+ ## [1.1.1] - 2026-04-20
47
+
48
+ ### Fixed
49
+ - `upgrade.sh`: detached runner now survives legacy (rsync-mode) install
50
+ conversion. Two bugs were silently causing the post-conversion service
51
+ restart to never run, leaving the old in-memory process alive even
52
+ though the disk had advanced to the target version.
53
+ ([#3](https://github.com/algony-tony/mymcp/pull/3))
54
+ - The self-copy to `/tmp` only copied `upgrade.sh`, not `install_lib.sh`,
55
+ so the detached child died on its `source` line before parsing args.
56
+ Both files are now copied into a per-invocation `mktemp -d` directory.
57
+ - Legacy conversion in the parent pre-advanced the disk to the target,
58
+ so the detached runner re-detected `CURRENT == TARGET` and exited at
59
+ the same-version guard without running stop/install/start. The
60
+ parent now propagates `--force` through `DETACH_ARGS` after a legacy
61
+ conversion.
62
+
63
+ ### Changed
64
+ - Release source archives now exclude dev-only paths (`tests/`, `docs/`,
65
+ `.github/`, `CLAUDE.md`, `pytest.ini`, `requirements-dev.txt`) via
66
+ `.gitattributes` `export-ignore`. The auto-generated "Source code
67
+ (tar.gz)" asset shrank from ~146 KB to ~32 KB. Forks/contributors
68
+ still get the full repo via `git clone`.
69
+ ([#4](https://github.com/algony-tony/mymcp/pull/4))
70
+
71
+ ## [1.1.0] - 2026-04-19
72
+
73
+ ### Added
74
+ - `deploy/upgrade.sh`: end-to-end upgrade orchestration with pre-flight checks,
75
+ `--dry-run`, `--rollback`, `--wheels-dir` offline install, and `--foreground`
76
+ / background detach modes.
77
+ - Four-tier cascading rollback: git reset, backup restore, emergency snapshot,
78
+ and manual recovery instructions written to `.upgrade-state`.
79
+ - Upgrade lock via `flock` with stale-lock cleanup; atomic `.upgrade-state`
80
+ writes for safe concurrent observation.
81
+ - `install.sh` now populates `APP_DIR` via `git clone` when a working tree is
82
+ available, falling back to `rsync` for tarball installs. Legacy rsync-based
83
+ installs are auto-converted to git-managed on first upgrade.
84
+ - Pre-flight diff of `UPGRADE_NOTES.md` between current and target refs, plus
85
+ log rotation for `/var/log/mymcp/upgrade.log`.
86
+ - Process-ancestry detection: upgrades invoked under the running mymcp server
87
+ detach into the background via `systemd-run` (with `setsid` fallback) so the
88
+ caller disconnects cleanly.
89
+ - CI: `deploy-test` workflow running bats unit tests and Docker integration
90
+ scenarios (fresh upgrade, legacy convert, rollback, offline wheels) across
91
+ Debian and Rocky images.
92
+
93
+ ### Changed
94
+ - `install.sh` no longer copies the entire source tree; git clone is the
95
+ primary path and the install metadata records `"mode":"git"` vs `"rsync"`.
96
+ - Upgrade refuses `--foreground` when invoked from inside the running mymcp
97
+ process tree on a legacy install that needs git conversion (prevents the
98
+ upgrade from killing its own parent mid-conversion).
99
+
100
+ ### Fixed
101
+ - Pre-conversion guard in `upgrade.sh` correctly rejects `--foreground` before
102
+ any filesystem changes are made.
103
+
104
+ ## [1.0.0] - 2026-04-16
105
+
106
+ Initial tagged release. See git history for details.
107
+
108
+ [Unreleased]: https://github.com/algony-tony/mymcp/compare/v1.1.0...HEAD
109
+ [1.1.0]: https://github.com/algony-tony/mymcp/compare/v1.0.0...v1.1.0
110
+ [1.0.0]: https://github.com/algony-tony/mymcp/releases/tag/v1.0.0
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 algony-tony
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.