altr-mcp 0.2.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 (75) hide show
  1. altr_mcp-0.2.0/.env.example +14 -0
  2. altr_mcp-0.2.0/.flake8 +3 -0
  3. altr_mcp-0.2.0/.github/workflows/ci.yml +29 -0
  4. altr_mcp-0.2.0/.github/workflows/publish.yml +20 -0
  5. altr_mcp-0.2.0/.gitignore +232 -0
  6. altr_mcp-0.2.0/.gitlab-ci.yml +19 -0
  7. altr_mcp-0.2.0/.python-version +1 -0
  8. altr_mcp-0.2.0/CHANGELOG.md +55 -0
  9. altr_mcp-0.2.0/LICENSE +21 -0
  10. altr_mcp-0.2.0/PKG-INFO +539 -0
  11. altr_mcp-0.2.0/README.md +509 -0
  12. altr_mcp-0.2.0/altr_mcp/__init__.py +25 -0
  13. altr_mcp-0.2.0/altr_mcp/instructions.md +84 -0
  14. altr_mcp-0.2.0/altr_mcp/middleware.py +56 -0
  15. altr_mcp-0.2.0/altr_mcp/models.py +115 -0
  16. altr_mcp-0.2.0/altr_mcp/server.py +66 -0
  17. altr_mcp-0.2.0/altr_mcp/settings.py +74 -0
  18. altr_mcp-0.2.0/altr_mcp/tools/__init__.py +29 -0
  19. altr_mcp-0.2.0/altr_mcp/tools/access_management.py +172 -0
  20. altr_mcp-0.2.0/altr_mcp/tools/access_request.py +156 -0
  21. altr_mcp-0.2.0/altr_mcp/tools/audit.py +325 -0
  22. altr_mcp-0.2.0/altr_mcp/tools/classification.py +336 -0
  23. altr_mcp-0.2.0/altr_mcp/tools/database.py +220 -0
  24. altr_mcp-0.2.0/altr_mcp/tools/policy.py +309 -0
  25. altr_mcp-0.2.0/altr_mcp/tools/sidecar_config.py +937 -0
  26. altr_mcp-0.2.0/altr_mcp/tools/tag.py +213 -0
  27. altr_mcp-0.2.0/altr_mcp/tools/telemetry.py +165 -0
  28. altr_mcp-0.2.0/altr_mcp/utils/__init__.py +12 -0
  29. altr_mcp-0.2.0/altr_mcp/utils/access_management.py +49 -0
  30. altr_mcp-0.2.0/altr_mcp/utils/access_request.py +55 -0
  31. altr_mcp-0.2.0/altr_mcp/utils/api.py +165 -0
  32. altr_mcp-0.2.0/altr_mcp/utils/audit.py +57 -0
  33. altr_mcp-0.2.0/altr_mcp/utils/classification.py +280 -0
  34. altr_mcp-0.2.0/altr_mcp/utils/database.py +55 -0
  35. altr_mcp-0.2.0/altr_mcp/utils/logging.py +163 -0
  36. altr_mcp-0.2.0/altr_mcp/utils/policy.py +254 -0
  37. altr_mcp-0.2.0/altr_mcp/utils/sidecar_config.py +286 -0
  38. altr_mcp-0.2.0/altr_mcp/utils/tag.py +187 -0
  39. altr_mcp-0.2.0/altr_mcp/utils/telemetry.py +71 -0
  40. altr_mcp-0.2.0/docs/access-management.md +79 -0
  41. altr_mcp-0.2.0/docs/access-requests.md +92 -0
  42. altr_mcp-0.2.0/docs/audits.md +120 -0
  43. altr_mcp-0.2.0/docs/classification.md +163 -0
  44. altr_mcp-0.2.0/docs/databases.md +105 -0
  45. altr_mcp-0.2.0/docs/error-handling.md +98 -0
  46. altr_mcp-0.2.0/docs/index.md +37 -0
  47. altr_mcp-0.2.0/docs/policies.md +132 -0
  48. altr_mcp-0.2.0/docs/sidecar-config.md +574 -0
  49. altr_mcp-0.2.0/docs/tags.md +112 -0
  50. altr_mcp-0.2.0/docs/telemetry.md +117 -0
  51. altr_mcp-0.2.0/mcp.json +13 -0
  52. altr_mcp-0.2.0/pyproject.toml +54 -0
  53. altr_mcp-0.2.0/server.json +42 -0
  54. altr_mcp-0.2.0/tests/__init__.py +0 -0
  55. altr_mcp-0.2.0/tests/conftest.py +18 -0
  56. altr_mcp-0.2.0/tests/integration/__init__.py +0 -0
  57. altr_mcp-0.2.0/tests/integration/conftest.py +21 -0
  58. altr_mcp-0.2.0/tests/integration/test_access_management.py +199 -0
  59. altr_mcp-0.2.0/tests/integration/test_access_request.py +211 -0
  60. altr_mcp-0.2.0/tests/integration/test_audit.py +157 -0
  61. altr_mcp-0.2.0/tests/integration/test_classification.py +298 -0
  62. altr_mcp-0.2.0/tests/integration/test_database.py +213 -0
  63. altr_mcp-0.2.0/tests/integration/test_policy.py +230 -0
  64. altr_mcp-0.2.0/tests/integration/test_sidecar_config.py +354 -0
  65. altr_mcp-0.2.0/tests/integration/test_tag.py +177 -0
  66. altr_mcp-0.2.0/tests/integration/test_telemetry.py +218 -0
  67. altr_mcp-0.2.0/tests/unit/__init__.py +0 -0
  68. altr_mcp-0.2.0/tests/unit/test_annotations.py +171 -0
  69. altr_mcp-0.2.0/tests/unit/test_canary.py +33 -0
  70. altr_mcp-0.2.0/tests/unit/test_logging.py +109 -0
  71. altr_mcp-0.2.0/tests/unit/test_middleware.py +87 -0
  72. altr_mcp-0.2.0/tests/unit/test_models.py +70 -0
  73. altr_mcp-0.2.0/tests/unit/test_retry.py +105 -0
  74. altr_mcp-0.2.0/tests/unit/test_settings.py +40 -0
  75. altr_mcp-0.2.0/uv.lock +1587 -0
@@ -0,0 +1,14 @@
1
+ # Required — server will not start without these
2
+ ORG_ID=your-org-id
3
+ MAPI_KEY=your-api-key
4
+ MAPI_SECRET=your-api-secret
5
+
6
+ # Optional — override base URLs (defaults to live production)
7
+ # ALTR_API_BASE_URL=https://api.live.altr.com
8
+ # ALTR_ALTRNET_BASE_URL=https://altrnet.live.altr.com
9
+ # ALTR_CLASSIFICATION_BASE_URL=https://{ORG_ID}.classification.live.altr.com
10
+ # ALTR_SC_CONTROL_BASE_URL=https://{ORG_ID}.sc-control.live.altr.com
11
+
12
+ # Optional — logging
13
+ # LOG_LEVEL=INFO
14
+ # LOG_FORMAT=console
altr_mcp-0.2.0/.flake8 ADDED
@@ -0,0 +1,3 @@
1
+ [flake8]
2
+ max-line-length = 100
3
+ exclude = .venv,altr-cli
@@ -0,0 +1,29 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, master]
6
+ pull_request:
7
+ branches: [main, master]
8
+
9
+ jobs:
10
+ lint:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: astral-sh/setup-uv@v5
15
+ - run: uv pip install flake8 --system
16
+ - run: flake8 altr_mcp/ tests/
17
+
18
+ test:
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ python-version: ["3.11", "3.12"]
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ - uses: astral-sh/setup-uv@v5
26
+ with:
27
+ python-version: ${{ matrix.python-version }}
28
+ - run: uv sync --extra dev
29
+ - run: uv run pytest tests/ -x
@@ -0,0 +1,20 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*.*.*"
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ environment: pypi
12
+ permissions:
13
+ id-token: write # required for OIDC trusted publishing
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: astral-sh/setup-uv@v5
17
+ - run: uv build
18
+ - uses: pypa/gh-action-pypi-publish@release/v1
19
+ with:
20
+ packages-dir: dist/
@@ -0,0 +1,232 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+
204
+ # Ruff stuff:
205
+ .ruff_cache/
206
+
207
+ # PyPI configuration file
208
+ .pypirc
209
+
210
+ # Marimo
211
+ marimo/_static/
212
+ marimo/_lsp/
213
+ __marimo__/
214
+
215
+ # Streamlit
216
+ .streamlit/secrets.toml
217
+
218
+
219
+ .DS_Store
220
+ .planning/
221
+ SUGGESTIONS.md
222
+
223
+ # mcporter CLI build artifacts
224
+ .*.bun-build*
225
+ altr-cli
226
+ altr-cli.ts
227
+
228
+ # Claude Code local settings
229
+ .claude/
230
+
231
+ # API documentation (local reference, not distributed)
232
+ .api-docs/
@@ -0,0 +1,19 @@
1
+ stages:
2
+ - lint
3
+ - test
4
+
5
+ lint:
6
+ stage: lint
7
+ image: python:3.12-slim
8
+ script:
9
+ - pip install flake8
10
+ - flake8 . --max-line-length=100 --exclude=.venv,altr-cli,build,dist,tmp
11
+
12
+ test:
13
+ stage: test
14
+ image: python:3.12-slim
15
+ before_script:
16
+ - pip install uv
17
+ script:
18
+ - uv sync --extra dev
19
+ - uv run pytest tests/ -x
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,55 @@
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
+ ## [0.2.0] - 2026-03-23
9
+
10
+ ### Added
11
+
12
+ - **Multi-transport support**: `MCP_TRANSPORT` env var selects `stdio` (default), `sse`, or `streamable-http` transport; `MCP_HOST` and `MCP_PORT` configure bind address and port for HTTP transports
13
+ - **Tool restriction middleware**: `RESTRICTED_TOOLS` env var accepts comma-separated tool names to hide from `tools/list` and block on `tools/call`
14
+ - **Structured JSON logging**: `LOG_FORMAT=json` emits structured JSON log lines via structlog; `LOG_FORMAT=console` (default) emits human-readable output
15
+ - **Correlation IDs**: every tool invocation generates a unique correlation ID (`func_name:hex8`) carried through all log entries for that invocation
16
+ - **HTTP retry with backoff**: transient API errors (429, 503) are retried up to 3 times with exponential backoff, jitter, and Retry-After header support via tenacity
17
+ - **Tool annotations**: get/list tools carry `readOnlyHint: true` and delete tools carry `destructiveHint: true` in MCP tool definitions
18
+ - **Pydantic input validation**: complex tool parameters (rule lists, policy configs, sidecar bindings, threshold objects) validated by Pydantic models before API calls
19
+ - **Integration test suite**: pytest-httpx based integration tests for all 9 tool domains with mocked HTTP responses
20
+
21
+ ### Changed
22
+
23
+ - **BREAKING — Structured responses**: all tools now return `{success, data, error}` dicts instead of formatted strings:
24
+ - tag tools (8): `get_tags`, `delete_tag`, `get_tag_values`, `get_tag_details_by_group_id`, `get_tag_details`, `update_tag`, `delete_tag_by_details`, `connect_tag`
25
+ - policy tools (8): `get_policies`, `get_rules`, `create_policy`, `add_rules`, `delete_policy`, `update_rule`, `delete_rule`, `get_roles`
26
+ - classification tools (10): `get_classifiers`, `create_classifier`, `delete_classifier`, `get_collections`, `create_collection`, `delete_collection`, `get_jobs`, `create_job`, `update_job_status`, `get_classification_report`
27
+ - database tools (2): `get_databases`, `get_database_id`
28
+ - access management tools (4): `create_snowflake_access_policy`, `create_oltp_access_policy`, `update_snowflake_access_policy`, `trigger_access_policy_check`
29
+ - access request tools (6): `create_access_request`, `get_access_requests`, `get_access_request`, `approve_access_request`, `deny_access_request`, `cancel_access_request`
30
+ - telemetry tools (9): `get_agent_instances`, `get_agent_instance`, `delete_agent_instance`, `get_agent_task_telemetry`, `get_sidecar_instances`, `get_sidecar_instance`, `delete_sidecar_instance`, `get_task_telemetry`, `delete_task_telemetry`
31
+ - audit tools (2): `search_audits`, `get_audit_results`
32
+ - sidecar config tools (32): `list_sc_agents`, `create_sc_agent`, `get_sc_agent`, `update_sc_agent`, `delete_sc_agent`, `list_sc_repos`, `create_sc_repo`, `get_sc_repo`, `update_sc_repo`, `delete_sc_repo`, `list_sc_repo_users`, `create_sc_repo_user`, `get_sc_repo_user`, `update_sc_repo_user`, `delete_sc_repo_user`, `list_sc_service_users`, `create_sc_service_user`, `get_sc_service_user`, `update_sc_service_user`, `delete_sc_service_user`, `list_sc_sidecars`, `create_sc_sidecar`, `get_sc_sidecar`, `update_sc_sidecar`, `delete_sc_sidecar`, `list_sc_sidecar_listeners`, `deregister_sc_sidecar_listener`, `list_sc_sidecar_bindings`, `list_sc_repo_bindings`, `get_sc_sidecar_binding`, `create_sc_sidecar_binding`, `delete_sc_sidecar_binding`
33
+ - **BREAKING — Error handling**: tool errors now set MCP `isError: true` flag and return `{success: false, data: null, error: "message"}` instead of plain error strings
34
+ - **BREAKING — Architecture**: tool handlers moved from monolithic `server.py` (2,600+ lines) to 9 domain modules in `altr_mcp/tools/`; `server.py` reduced to ~60 lines of server configuration and tool registration
35
+ - **BREAKING — FastMCP upgrade**: migrated from `mcp[cli]` bundled FastMCP to standalone `fastmcp>=2.0,<3.0`
36
+ - **Logging**: replaced ad-hoc print-based logging with structlog-based structured logging via `@log_tool` decorator
37
+ - **Instructions**: server instructions extracted from inline string to `altr_mcp/instructions.md`
38
+
39
+ ### Removed
40
+
41
+ - `mcp[cli]` dependency replaced by standalone `fastmcp>=2.0,<3.0`
42
+ - Inline tool handlers in `server.py` (moved to `altr_mcp/tools/` modules)
43
+ - Plain string tool responses (replaced by structured `{success, data, error}` dicts)
44
+
45
+ ## [0.1.0] - 2026-03-13
46
+
47
+ ### Added
48
+
49
+ - 83 MCP tools covering tags, masking policies, rules, classification, access management, sidecar config, telemetry, and audits
50
+ - Pydantic Settings singleton for validated configuration with fail-fast startup
51
+ - Structured logging to stderr with configurable LOG_LEVEL
52
+ - `@log_tool` decorator for universal invocation logging and error handling
53
+ - Pydantic validation models for `access_rate_thresholds` and `time_window_thresholds`
54
+ - Configurable base URLs for all ALTR API endpoints
55
+ - SecretStr masking for MAPI_KEY and MAPI_SECRET
altr_mcp-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ALTR
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.