harborrag-mcp-server 2.0.0a1__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 (35) hide show
  1. harborrag_mcp_server-2.0.0a1/.gitignore +252 -0
  2. harborrag_mcp_server-2.0.0a1/LICENSE +201 -0
  3. harborrag_mcp_server-2.0.0a1/PKG-INFO +180 -0
  4. harborrag_mcp_server-2.0.0a1/README.md +164 -0
  5. harborrag_mcp_server-2.0.0a1/pyproject.toml +28 -0
  6. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/__init__.py +3 -0
  7. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/__main__.py +205 -0
  8. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/audit.py +348 -0
  9. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/configuration/__init__.py +21 -0
  10. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/configuration/models.py +89 -0
  11. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/configuration/store.py +314 -0
  12. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/configuration/validation.py +119 -0
  13. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/defaults/mcp.yaml +48 -0
  14. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/policy.py +58 -0
  15. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/server/__init__.py +145 -0
  16. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/server/base.py +23 -0
  17. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/server/http.py +320 -0
  18. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/server/http_auth.py +122 -0
  19. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/server/http_responses.py +45 -0
  20. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/server/server.py +133 -0
  21. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/server/static/status.html +251 -0
  22. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/tools/__init__.py +16 -0
  23. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/tools/base.py +28 -0
  24. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/tools/graph_search.py +231 -0
  25. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/tools/retrieval_inputs.py +102 -0
  26. harborrag_mcp_server-2.0.0a1/src/harborrag_mcp_server/tools/vector_search.py +140 -0
  27. harborrag_mcp_server-2.0.0a1/tests/conftest.py +22 -0
  28. harborrag_mcp_server-2.0.0a1/tests/test_audit_security.py +72 -0
  29. harborrag_mcp_server-2.0.0a1/tests/test_configuration.py +228 -0
  30. harborrag_mcp_server-2.0.0a1/tests/test_graph_search_tools.py +273 -0
  31. harborrag_mcp_server-2.0.0a1/tests/test_http_server.py +343 -0
  32. harborrag_mcp_server-2.0.0a1/tests/test_mcp_server.py +331 -0
  33. harborrag_mcp_server-2.0.0a1/tests/test_packaged_configuration.py +18 -0
  34. harborrag_mcp_server-2.0.0a1/tests/test_qdrant_vector_search.py +268 -0
  35. harborrag_mcp_server-2.0.0a1/tests/test_vector_search_tool.py +147 -0
@@ -0,0 +1,252 @@
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
+ *.lcov
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+ harborrag_control.db
65
+ harborrag_control.db-journal
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ .pybuilder/
79
+ target/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # pyenv
89
+ # For a library or package, you might want to ignore these files since the code is
90
+ # intended to run in multiple environments; otherwise, check them in:
91
+ # .python-version
92
+
93
+ # pipenv
94
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
96
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
97
+ # install all needed dependencies.
98
+ # Pipfile.lock
99
+
100
+ # UV
101
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
102
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
103
+ # commonly ignored for libraries.
104
+ # uv.lock
105
+
106
+ # poetry
107
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
108
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
109
+ # commonly ignored for libraries.
110
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
111
+ # poetry.lock
112
+ # poetry.toml
113
+
114
+ # pdm
115
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
116
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
117
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
118
+ # pdm.lock
119
+ # pdm.toml
120
+ .pdm-python
121
+ .pdm-build/
122
+
123
+ # pixi
124
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
125
+ # pixi.lock
126
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
127
+ # in the .venv directory. It is recommended not to include this directory in version control.
128
+ .pixi/*
129
+ !.pixi/config.toml
130
+
131
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
132
+ __pypackages__/
133
+
134
+ # Celery stuff
135
+ celerybeat-schedule*
136
+ celerybeat.pid
137
+
138
+ # Redis
139
+ *.rdb
140
+ *.aof
141
+ *.pid
142
+
143
+ # RabbitMQ
144
+ mnesia/
145
+ rabbitmq/
146
+ rabbitmq-data/
147
+
148
+ # ActiveMQ
149
+ activemq-data/
150
+
151
+ # SageMath parsed files
152
+ *.sage.py
153
+
154
+ # Environments
155
+ .env
156
+ .envrc
157
+ .venv
158
+ env
159
+ venv/
160
+ ENV/
161
+ env.bak/
162
+ venv.bak/
163
+
164
+ # HarborRAG local runtime state and ingested object data
165
+ /.harborrag/
166
+ /.local/
167
+ # ...and the same, wherever a package nests its own local runtime state.
168
+ **/.local/
169
+
170
+ # Spyder project settings
171
+ .spyderproject
172
+ .spyproject
173
+
174
+ # Rope project settings
175
+ .ropeproject
176
+
177
+ # mkdocs documentation
178
+ /site
179
+
180
+ # mypy
181
+ .mypy_cache/
182
+ .dmypy.json
183
+ dmypy.json
184
+
185
+ # Pyre type checker
186
+ .pyre/
187
+
188
+ # pytype static type analyzer
189
+ .pytype/
190
+
191
+ # Cython debug symbols
192
+ cython_debug/
193
+
194
+ # PyCharm
195
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
196
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
197
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
198
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
199
+ # .idea/
200
+
201
+ # Abstra
202
+ # Abstra is an AI-powered process automation framework.
203
+ # Ignore directories containing user credentials, local state, and settings.
204
+ # Learn more at https://abstra.io/docs
205
+ .abstra/
206
+
207
+ # Visual Studio Code
208
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
209
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
210
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
211
+ # you could uncomment the following to ignore the entire vscode folder
212
+ .vscode/
213
+ # Temporary file for partial code execution
214
+ tempCodeRunnerFile.py
215
+
216
+ # Ruff stuff:
217
+ .ruff_cache/
218
+
219
+ # PyPI configuration file
220
+ .pypirc
221
+
222
+ # Marimo
223
+ marimo/_static/
224
+ marimo/_lsp/
225
+ __marimo__/
226
+
227
+ # Streamlit
228
+ .streamlit/secrets.toml
229
+
230
+ .claude/**
231
+ .agents/
232
+
233
+ examples/
234
+
235
+ # OS / editor noise
236
+ .DS_Store
237
+ .~lock.*#
238
+
239
+ # Generated API contract artifact (exported by make openapi)
240
+ openapi.json
241
+ clients/typescript/src/schema.d.ts
242
+ clients/typescript/dist/
243
+ clients/typescript/node_modules/
244
+
245
+ # Internal architecture working notes (kept out of the repo per team decision)
246
+ docs/developers/architecture/http_backend/
247
+
248
+ # Docling image output (config/parsers.yaml pdf-docling.image_output_dir)
249
+ /data/docling-images/
250
+
251
+ # Local macOS-compatible copy of dev.sh (bash 3.2 / BSD sed tweaks)
252
+ scripts/deployment/dev-mac.sh
@@ -0,0 +1,201 @@
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 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 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 those 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
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,180 @@
1
+ Metadata-Version: 2.5
2
+ Name: harborrag-mcp-server
3
+ Version: 2.0.0a1
4
+ Summary: MCP facade and audited tools for HarborRAG.
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.12
8
+ Requires-Dist: harborrag-core==2.0.0a1
9
+ Requires-Dist: harborrag-runtime==2.0.0a1
10
+ Requires-Dist: jsonschema<5,>=4.26
11
+ Requires-Dist: pydantic<3,>=2.12
12
+ Requires-Dist: pyyaml<7,>=6.0.2
13
+ Provides-Extra: mcp
14
+ Requires-Dist: fastmcp<4,>=3.4; extra == 'mcp'
15
+ Description-Content-Type: text/markdown
16
+
17
+ # harborrag-mcp-server
18
+
19
+ Owns the FastMCP transport, pre-execution policy, and durable audit boundary.
20
+
21
+ ## Folder ownership
22
+
23
+ ```text
24
+ __main__.py stdio / HTTP launcher and flag parsing
25
+ tools/base.py McpToolSpec and the BaseMcpTool contract
26
+ tools/retrieval_inputs.py shared tenant and retrieval argument schemas
27
+ tools/vector_search.py vector_search
28
+ tools/graph_search.py graph_triplet_search, graph_path_search, graph_subgraph_search
29
+ server/base.py server protocol
30
+ server/server.py tool registry, policy enforcement, dispatch
31
+ server/http.py loopback Streamable HTTP transport and status UI
32
+ server/http_auth.py owner-only bearer and tenant authorization
33
+ server/static/status.html status page and Tool Playground
34
+ configuration/ config/mcp.yaml loading, validation, env overrides
35
+ policy.py compiled safety ceilings
36
+ audit.py JSONL audit writer
37
+ defaults/mcp.yaml packaged fallback configuration
38
+ ```
39
+
40
+ ## Team deliverables
41
+
42
+ - The shipped transport exposes four retrieval tools: `vector_search`,
43
+ `graph_triplet_search`, `graph_path_search`, and `graph_subgraph_search`.
44
+ Chat and agent are not MCP tools; they are served only through the HarborRAG
45
+ REST API's `/v1/chat/completions` and `/v1/agent/completions` endpoints.
46
+ - Every attempt and outcome is durably audited with a principal identifier and
47
+ arguments digest; raw arguments and tokens are never recorded.
48
+ - Declared input schemas plus argument, result-count, and serialized-output
49
+ budgets are enforced.
50
+ - Ingestion-capability tools fail closed until explicitly enabled.
51
+ - Transport creation fails closed without authentication unless the caller
52
+ explicitly selects local unauthenticated stdio.
53
+ - Service-level tools must never expose raw database/provider access or place
54
+ retrieved document text in descriptions.
55
+
56
+ Install dependencies before running the launcher. The stdio and HTTP transports
57
+ both configure the durable conversation memory, which runs control-plane
58
+ database migrations via Alembic/asyncpg on startup; the retrieval tools call
59
+ embedding providers through LiteLLM, read/write documents through the S3/MinIO
60
+ object store, and query the Qdrant and FalkorDB backends. The `mcp` extra
61
+ alone is not enough:
62
+
63
+ ```bash
64
+ uv sync --package harborrag-mcp-server --extra mcp \
65
+ --package harborrag-adapters --extra control-plane --extra postgres \
66
+ --extra llm --extra s3 --extra qdrant --extra falkordb
67
+ ```
68
+
69
+ Run the standard stdio transport:
70
+
71
+ ```bash
72
+ scripts/deployment/mcp.sh
73
+ ```
74
+
75
+ Build the equivalent non-root container and verify its advertised registry:
76
+
77
+ ```bash
78
+ docker build -f deploy/docker/Dockerfile.mcp -t harborrag-mcp .
79
+ docker run --rm harborrag-mcp --check
80
+ ```
81
+
82
+ For a real stdio MCP session, run the image with an attached stdin, the
83
+ database/model environment files, and connectivity to the configured data
84
+ services. The image entrypoint is `python -m harborrag_mcp_server`, so MCP
85
+ arguments such as `--check` or `--transport http` are forwarded directly.
86
+
87
+ The launcher loads the protected database, model, API, and MCP environment files,
88
+ constructs the shared `HarborRAG` runtime, and communicates over stdin/stdout.
89
+ It is a child process launched by an MCP client, not an interactive terminal or
90
+ HTTP service. Run `scripts/deployment/mcp.sh --check` yourself to perform a real
91
+ MCP handshake and print the four advertised tool names without connecting to
92
+ providers.
93
+
94
+ Run an authenticated local Streamable HTTP endpoint and status page:
95
+
96
+ ```bash
97
+ scripts/deployment/dev.sh bootstrap
98
+ scripts/deployment/mcp.sh --http
99
+ ```
100
+
101
+ The browser status page is `http://127.0.0.1:8010/`, health is available at
102
+ `http://127.0.0.1:8010/healthz`, and MCP clients connect to
103
+ `http://127.0.0.1:8010/mcp` with the token in an `Authorization: Bearer`
104
+ header. Override the loopback host, port, or path with `--host`, `--port`, and
105
+ `--path`; this local static-token mode intentionally rejects non-loopback
106
+ hosts. The bootstrap command generates the token in the Git-ignored
107
+ `env/.env.mcp` file with mode `0600`; override that path with `MCP_ENV_FILE`.
108
+
109
+ ## Tool Playground
110
+
111
+ Open the browser page, enter the bearer token, provide a tenant ID, and select
112
+ **Load tools**. The page builds an argument form from the effective JSON schema
113
+ and executes the selected tool with **Run tool**. Tenant-specific enablement,
114
+ defaults and limits are applied before execution, and each attempt is audited.
115
+
116
+ Chat and agent are not part of this catalog; use the HarborRAG REST API's
117
+ `/v1/chat/completions` and `/v1/agent/completions` endpoints instead.
118
+
119
+ The owner-only browser API is:
120
+
121
+ - `GET /api/tools?tenant_id=<tenant>` for the effective catalog;
122
+ - `POST /api/tools/call` with `{"name": "...", "arguments": {...}}` to run a tool.
123
+
124
+ The API is a local administrative convenience, not a second unprotected tool
125
+ transport. It requires the same owner bearer token as configuration editing.
126
+
127
+ ## Tool configuration
128
+
129
+ The versioned configuration lives at `config/mcp.yaml` by default. Set
130
+ `HARBORRAG_MCP_CONFIG_PATH` or pass `--config` after `--http` to select another
131
+ file. The configuration controls:
132
+
133
+ - global policy budgets;
134
+ - globally enabled tools;
135
+ - optional argument defaults and numeric upper limits;
136
+ - per-tenant enabled state, defaults, and limits.
137
+
138
+ Required fields and `tenant_id` can never receive defaults, unknown tools and
139
+ fields are rejected, and configured limits cannot exceed each tool's compiled
140
+ safety ceiling. Tenant IDs are canonicalized before policy lookup and execution,
141
+ and configuration tenant keys may not contain surrounding whitespace. These environment variables override the file without being
142
+ persisted back into it:
143
+
144
+ - `HARBORRAG_MCP_MAX_RESULTS`
145
+ - `HARBORRAG_MCP_MAX_ARGUMENT_BYTES`
146
+ - `HARBORRAG_MCP_MAX_OUTPUT_BYTES`
147
+ - `HARBORRAG_MCP_DISABLED_TOOLS` (comma-separated tool names)
148
+
149
+ In HTTP mode, enter the bearer token in the status page and use **Load**,
150
+ **Save**, or **Reload YAML**. The owner-only API is `GET/PUT /api/config` and
151
+ `POST /api/config/reload`. Saves use revision checks and atomic replacement;
152
+ audit records contain only revision hashes, never configuration values.
153
+
154
+ Defaults, limits, budgets, and tenant overrides are enforced immediately.
155
+ Changes to global advertised tool schemas or enabled tools set
156
+ `restart_required=true`; restart the MCP process so connected clients receive
157
+ the new advertised catalog.
158
+
159
+ Network transports must be constructed with a FastMCP authentication provider.
160
+ MCP tool calls require an authenticated token carrying `role=owner` and an
161
+ explicit `tenants` claim containing the requested tenant. Global owners must
162
+ carry the deliberate wildcard claim `tenants=["*"]`.
163
+ The explicit local override is for stdio only and opens no listener.
164
+
165
+
166
+ ## Package tests
167
+
168
+ Tests for this package live in:
169
+
170
+ ```text
171
+ packages/harborrag-mcp-server/tests/
172
+ ```
173
+
174
+ Run from the repository root:
175
+
176
+ ```bash
177
+ pytest packages/harborrag-mcp-server/tests
178
+ ```
179
+
180
+ Keep new tests in this folder when adding or changing behavior owned by this package.