docugen-mcp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,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
141
+ the 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 2026 Fibtec Limited
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,151 @@
1
+ Metadata-Version: 2.4
2
+ Name: docugen-mcp
3
+ Version: 0.1.0
4
+ Summary: Read-only MCP server for Fibtec's DocuGen: credit, session status and delivery facts as Claude Code tools
5
+ Author: Fibtec Limited
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://docugen.fibtec.co.uk
8
+ Project-URL: Repository, https://github.com/fibtecltd/fibtec-docugen-plugin
9
+ Project-URL: Bug Tracker, https://github.com/fibtecltd/fibtec-docugen-plugin/issues
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Requires-Python: >=3.11
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: mcp<3,>=2.1.0
18
+ Requires-Dist: anyio>=4.0
19
+ Requires-Dist: httpx>=0.27.0
20
+ Requires-Dist: docugen-client<0.2,>=0.1.0
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest>=8.0; extra == "dev"
23
+ Requires-Dist: ruff>=0.15.0; extra == "dev"
24
+ Dynamic: license-file
25
+
26
+ # DocuGen for Claude Code (`docugen-mcp`)
27
+
28
+ [Fibtec DocuGen](https://docugen.fibtec.co.uk) reads a repository and delivers verified documentation:
29
+ API references, architecture overviews, onboarding guides and diagrams. This plugin lets Claude Code
30
+ answer three questions about your organisation's DocuGen account without leaving the terminal: *is my
31
+ setup working and what is my credit*, *where is my session*, and *what did it deliver*.
32
+
33
+ **It is read-only.** It cannot upload your code, start a session, spend credit, delete anything or
34
+ download the documents. **DocuGen is in pilot and access is by request**: ask here,
35
+ <https://fibtec.co.uk/#contact>. Without access the tools say so, in one sentence.
36
+
37
+ This is the plugin for customers. The repository also holds `plugins/docugen-box`, the plugin the
38
+ documenting agent runs under inside DocuGen's own sandbox; it is not listed in the marketplace and
39
+ is not for you.
40
+
41
+ ## Tools
42
+
43
+ | Tool | Does | Key scope |
44
+ |---|---|---|
45
+ | `docugen_billing` | The organisation's credit balance and whether pricing is on. Use it first: it shows that the key works. | `read` |
46
+ | `docugen_status` | One session's status and facts (give its id), or the ten newest sessions. | `read` |
47
+ | `docugen_delivery` | The facts of a finished session's delivery: status, documents and PDFs delivered, size, whether it is complete, when it expires. **Never the download link** (it is read from the session, so the key needs no more than `read`). | `read` |
48
+
49
+ Results are short text of facts: ids, statuses, counts, sizes, dates and prices. Never document
50
+ content, and never a message from DocuGen's servers: every failure is one fixed sentence.
51
+
52
+ The documents themselves are fetched in the DocuGen portal, or with the `docugen fetch` command of
53
+ the [`docugen-client`](https://github.com/fibtecltd/fibtec-docugen/tree/main/docugen-client) package
54
+ (the download link is a bearer credential, so this plugin does not hand it to the model). Starting a
55
+ session from Claude Code is not in this first release.
56
+
57
+ ## Requirements
58
+
59
+ - Claude Code, and [uv](https://docs.astral.sh/uv/) on your `PATH`: the plugin starts its server with
60
+ `uvx`, which downloads it from PyPI on first use. A "command not found" style failure is almost
61
+ certainly a missing uv. No uv? `pip install docugen-mcp` and change the plugin's `mcpServers`
62
+ command to `docugen-mcp` (with no `args`).
63
+ - A DocuGen organisation that has been enabled for the pilot, and an API key.
64
+
65
+ ## Install
66
+
67
+ ```
68
+ /plugin marketplace add fibtecltd/fibtec-docugen-plugin
69
+ /plugin install docugen@fibtec-docugen
70
+ ```
71
+
72
+ On Claude Code 2.1.275 or later, one step: `/plugin install docugen --marketplace fibtecltd/fibtec-docugen-plugin`.
73
+
74
+ Claude Code asks for your DocuGen API key during the install. It is stored as a sensitive plugin
75
+ setting and passed to this plugin's server as an environment variable. No tool takes a key as an
76
+ argument and none returns it.
77
+
78
+ ## Your key
79
+
80
+ An owner of your organisation makes it on the **API keys page** of the DocuGen portal
81
+ (<https://docugen.fibtec.co.uk>). The portal shows it once. Give it **the scope `read` and no other**: it
82
+ cannot spend credit and it cannot download a document, so a leaked key can read facts and nothing
83
+ more. It looks like `dgk_<id>_<secret>`. Revoke it on the same page whenever you like; a revoked key
84
+ is refused on its next call.
85
+
86
+ ## Use
87
+
88
+ Ask in plain words. For example:
89
+
90
+ - "Check my DocuGen setup." (`docugen_billing`)
91
+ - "What state are my DocuGen sessions in?" (`docugen_status`)
92
+ - "Did session 3f2b8c1e-… finish, and was it complete?" (`docugen_status`, then `docugen_delivery`)
93
+
94
+ ## If it does not work
95
+
96
+ | What Claude says | What it means |
97
+ |---|---|
98
+ | "DocuGen is in pilot: access is by request." | Your organisation is not enabled yet. Ask at <https://fibtec.co.uk/#contact>. Nothing is wrong with the plugin. |
99
+ | "No DocuGen API key is set." | Enter the key in the plugin's settings. |
100
+ | "DocuGen refused the API key." | DocuGen gives one answer for every cause: unknown, revoked or expired key, the scope `read` that every tool needs, or too many calls. Check the key on the portal's API keys page. |
101
+ | "Pricing is not on for this organisation yet." | Normal in the pilot: there is no credit to show. |
102
+ | "DocuGen has no such session…" | The id is wrong, belongs to someone else, or its result has expired (results are kept for seven days). |
103
+ | "DocuGen could not be reached." | A network failure on your side. |
104
+
105
+ ## What it runs, sends and stores
106
+
107
+ - **Runs:** `uvx docugen-mcp==0.1.0`, a Python process on your machine that Claude Code starts and
108
+ stops. The version is pinned exactly.
109
+ - **Sends:** to `https://api.docugen.fibtec.co.uk/v1` and nowhere else (redirects are not followed):
110
+ your key as a bearer token, and a session id when you ask about one. Never source code, file
111
+ names, paths or anything else from your machine. DocuGen sees the label `docugen-client` as the
112
+ program.
113
+ - **Stores:** nothing. No file, cache or log is written. Claude Code keeps the key in its own
114
+ credential store for plugin settings.
115
+ - **Returns to Claude:** only the facts listed above, each checked against the shape DocuGen's API
116
+ defines before it is shown; anything that does not fit is left out.
117
+ - **What DocuGen does with data** is in its [privacy policy](https://docugen.fibtec.co.uk/privacy.html)
118
+ and [terms](https://docugen.fibtec.co.uk/terms.html).
119
+
120
+ ## For developers
121
+
122
+ `DOCUGEN_BASE_URL` overrides the address, for tests: it must be `https` (or `http` on localhost),
123
+ with no user name, password, query or fragment. The plugin never sets it.
124
+
125
+ ```bash
126
+ python3 -m venv .venv && . .venv/bin/activate
127
+ pip install "pytest>=8" ruff
128
+ pip install -e . # pulls mcp, anyio, httpx and docugen-client from PyPI
129
+ pytest tests # the real server over stdio, against a stand-in key API
130
+ ruff check .
131
+ ```
132
+
133
+ ### Releasing
134
+
135
+ `docugen-mcp` is published to PyPI by `.github/workflows/docugen-mcp-publish.yml` when a
136
+ `docugen-mcp-v*` tag is pushed (Trusted Publishing; the PyPI project, with this repository,
137
+ workflow and the `pypi` environment registered as its publisher, is a one-time step that is the
138
+ owner's). The plugin starts the server with an exact pin, so a release changes three things
139
+ together: `version` in `pyproject.toml`, `version` in `.claude-plugin/plugin.json`, and the pin in
140
+ `mcpServers.docugen.args`. The workflow fails before building if the tag, those two versions and the
141
+ pin disagree.
142
+
143
+ **A release needs `docugen-client` 0.1.x on PyPI** (0.1.0 was published on 2026-12-05), because
144
+ `docugen-mcp` depends on `docugen-client>=0.1.0,<0.2`: a `docugen-mcp` published without it could
145
+ not be installed, and PyPI never lets a version be uploaded again. The workflow checks that a
146
+ matching `docugen-client` is on PyPI before it builds. Tag the merge commit as soon as it lands:
147
+ until the tag's workflow has run, the pin names a version PyPI does not have.
148
+
149
+ ## Licence
150
+
151
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,126 @@
1
+ # DocuGen for Claude Code (`docugen-mcp`)
2
+
3
+ [Fibtec DocuGen](https://docugen.fibtec.co.uk) reads a repository and delivers verified documentation:
4
+ API references, architecture overviews, onboarding guides and diagrams. This plugin lets Claude Code
5
+ answer three questions about your organisation's DocuGen account without leaving the terminal: *is my
6
+ setup working and what is my credit*, *where is my session*, and *what did it deliver*.
7
+
8
+ **It is read-only.** It cannot upload your code, start a session, spend credit, delete anything or
9
+ download the documents. **DocuGen is in pilot and access is by request**: ask here,
10
+ <https://fibtec.co.uk/#contact>. Without access the tools say so, in one sentence.
11
+
12
+ This is the plugin for customers. The repository also holds `plugins/docugen-box`, the plugin the
13
+ documenting agent runs under inside DocuGen's own sandbox; it is not listed in the marketplace and
14
+ is not for you.
15
+
16
+ ## Tools
17
+
18
+ | Tool | Does | Key scope |
19
+ |---|---|---|
20
+ | `docugen_billing` | The organisation's credit balance and whether pricing is on. Use it first: it shows that the key works. | `read` |
21
+ | `docugen_status` | One session's status and facts (give its id), or the ten newest sessions. | `read` |
22
+ | `docugen_delivery` | The facts of a finished session's delivery: status, documents and PDFs delivered, size, whether it is complete, when it expires. **Never the download link** (it is read from the session, so the key needs no more than `read`). | `read` |
23
+
24
+ Results are short text of facts: ids, statuses, counts, sizes, dates and prices. Never document
25
+ content, and never a message from DocuGen's servers: every failure is one fixed sentence.
26
+
27
+ The documents themselves are fetched in the DocuGen portal, or with the `docugen fetch` command of
28
+ the [`docugen-client`](https://github.com/fibtecltd/fibtec-docugen/tree/main/docugen-client) package
29
+ (the download link is a bearer credential, so this plugin does not hand it to the model). Starting a
30
+ session from Claude Code is not in this first release.
31
+
32
+ ## Requirements
33
+
34
+ - Claude Code, and [uv](https://docs.astral.sh/uv/) on your `PATH`: the plugin starts its server with
35
+ `uvx`, which downloads it from PyPI on first use. A "command not found" style failure is almost
36
+ certainly a missing uv. No uv? `pip install docugen-mcp` and change the plugin's `mcpServers`
37
+ command to `docugen-mcp` (with no `args`).
38
+ - A DocuGen organisation that has been enabled for the pilot, and an API key.
39
+
40
+ ## Install
41
+
42
+ ```
43
+ /plugin marketplace add fibtecltd/fibtec-docugen-plugin
44
+ /plugin install docugen@fibtec-docugen
45
+ ```
46
+
47
+ On Claude Code 2.1.275 or later, one step: `/plugin install docugen --marketplace fibtecltd/fibtec-docugen-plugin`.
48
+
49
+ Claude Code asks for your DocuGen API key during the install. It is stored as a sensitive plugin
50
+ setting and passed to this plugin's server as an environment variable. No tool takes a key as an
51
+ argument and none returns it.
52
+
53
+ ## Your key
54
+
55
+ An owner of your organisation makes it on the **API keys page** of the DocuGen portal
56
+ (<https://docugen.fibtec.co.uk>). The portal shows it once. Give it **the scope `read` and no other**: it
57
+ cannot spend credit and it cannot download a document, so a leaked key can read facts and nothing
58
+ more. It looks like `dgk_<id>_<secret>`. Revoke it on the same page whenever you like; a revoked key
59
+ is refused on its next call.
60
+
61
+ ## Use
62
+
63
+ Ask in plain words. For example:
64
+
65
+ - "Check my DocuGen setup." (`docugen_billing`)
66
+ - "What state are my DocuGen sessions in?" (`docugen_status`)
67
+ - "Did session 3f2b8c1e-… finish, and was it complete?" (`docugen_status`, then `docugen_delivery`)
68
+
69
+ ## If it does not work
70
+
71
+ | What Claude says | What it means |
72
+ |---|---|
73
+ | "DocuGen is in pilot: access is by request." | Your organisation is not enabled yet. Ask at <https://fibtec.co.uk/#contact>. Nothing is wrong with the plugin. |
74
+ | "No DocuGen API key is set." | Enter the key in the plugin's settings. |
75
+ | "DocuGen refused the API key." | DocuGen gives one answer for every cause: unknown, revoked or expired key, the scope `read` that every tool needs, or too many calls. Check the key on the portal's API keys page. |
76
+ | "Pricing is not on for this organisation yet." | Normal in the pilot: there is no credit to show. |
77
+ | "DocuGen has no such session…" | The id is wrong, belongs to someone else, or its result has expired (results are kept for seven days). |
78
+ | "DocuGen could not be reached." | A network failure on your side. |
79
+
80
+ ## What it runs, sends and stores
81
+
82
+ - **Runs:** `uvx docugen-mcp==0.1.0`, a Python process on your machine that Claude Code starts and
83
+ stops. The version is pinned exactly.
84
+ - **Sends:** to `https://api.docugen.fibtec.co.uk/v1` and nowhere else (redirects are not followed):
85
+ your key as a bearer token, and a session id when you ask about one. Never source code, file
86
+ names, paths or anything else from your machine. DocuGen sees the label `docugen-client` as the
87
+ program.
88
+ - **Stores:** nothing. No file, cache or log is written. Claude Code keeps the key in its own
89
+ credential store for plugin settings.
90
+ - **Returns to Claude:** only the facts listed above, each checked against the shape DocuGen's API
91
+ defines before it is shown; anything that does not fit is left out.
92
+ - **What DocuGen does with data** is in its [privacy policy](https://docugen.fibtec.co.uk/privacy.html)
93
+ and [terms](https://docugen.fibtec.co.uk/terms.html).
94
+
95
+ ## For developers
96
+
97
+ `DOCUGEN_BASE_URL` overrides the address, for tests: it must be `https` (or `http` on localhost),
98
+ with no user name, password, query or fragment. The plugin never sets it.
99
+
100
+ ```bash
101
+ python3 -m venv .venv && . .venv/bin/activate
102
+ pip install "pytest>=8" ruff
103
+ pip install -e . # pulls mcp, anyio, httpx and docugen-client from PyPI
104
+ pytest tests # the real server over stdio, against a stand-in key API
105
+ ruff check .
106
+ ```
107
+
108
+ ### Releasing
109
+
110
+ `docugen-mcp` is published to PyPI by `.github/workflows/docugen-mcp-publish.yml` when a
111
+ `docugen-mcp-v*` tag is pushed (Trusted Publishing; the PyPI project, with this repository,
112
+ workflow and the `pypi` environment registered as its publisher, is a one-time step that is the
113
+ owner's). The plugin starts the server with an exact pin, so a release changes three things
114
+ together: `version` in `pyproject.toml`, `version` in `.claude-plugin/plugin.json`, and the pin in
115
+ `mcpServers.docugen.args`. The workflow fails before building if the tag, those two versions and the
116
+ pin disagree.
117
+
118
+ **A release needs `docugen-client` 0.1.x on PyPI** (0.1.0 was published on 2026-12-05), because
119
+ `docugen-mcp` depends on `docugen-client>=0.1.0,<0.2`: a `docugen-mcp` published without it could
120
+ not be installed, and PyPI never lets a version be uploaded again. The workflow checks that a
121
+ matching `docugen-client` is on PyPI before it builds. Tag the merge commit as soon as it lands:
122
+ until the tag's workflow has run, the pin names a version PyPI does not have.
123
+
124
+ ## Licence
125
+
126
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,8 @@
1
+ """docugen-mcp: a read-only MCP server for Fibtec's DocuGen."""
2
+
3
+ from importlib import metadata
4
+
5
+ try:
6
+ __version__ = metadata.version("docugen-mcp")
7
+ except metadata.PackageNotFoundError: # a source tree that was never installed
8
+ __version__ = "dev"
@@ -0,0 +1,5 @@
1
+ """`python -m docugen_mcp` starts the server, as the `docugen-mcp` command does."""
2
+
3
+ from docugen_mcp.main import main
4
+
5
+ main()
@@ -0,0 +1,107 @@
1
+ """docugen_mcp.config -- where the key and the address come from, and nowhere else.
2
+
3
+ Reasoning:
4
+ - **The key comes from one place: the environment variable DOCUGEN_API_KEY**, which the plugin's
5
+ manifest fills from a `userConfig` option marked sensitive (`${user_config.docugen_api_key}`).
6
+ There is no flag, no file and no tool argument that takes a key, so the model is never asked
7
+ for one and never holds one (docs/fibtec-docugen-plugin-design-spec.md section 4a: a command run
8
+ through Bash does not see a userConfig value, a stdio server in the plugin does).
9
+ - The key is never returned, logged or printed. `Settings` hides it from `repr`, and the sentences
10
+ below, which are the only text this module ever produces, are fixed words that name no value.
11
+ - The key API's address is a constant (the owner's choice: nothing for a customer to set). It
12
+ ends in `/v1` because the contract's server is `https://api.docugen.fibtec.co.uk/v1` and the
13
+ client appends `/billing`, `/sessions` and the rest to it: without the stage the gateway answers
14
+ every call with its own bare 403. `DOCUGEN_BASE_URL` overrides it for tests; it must be https
15
+ (http only for localhost), with no user name, password, query or fragment, because the key is
16
+ sent to whatever address is here. A value that is not usable is refused, never replaced
17
+ silently, and never echoed.
18
+ - A missing key is not a start-up failure: the server starts and lists its tools, and a tool call
19
+ says what to do, so that the model can tell the person instead of the plugin looking broken.
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ import os
25
+ from collections.abc import Mapping
26
+ from dataclasses import dataclass, field
27
+ from urllib.parse import urlsplit
28
+
29
+ DEFAULT_BASE_URL = "https://api.docugen.fibtec.co.uk/v1"
30
+ KEY_VARIABLE = "DOCUGEN_API_KEY"
31
+ BASE_URL_VARIABLE = "DOCUGEN_BASE_URL"
32
+ LOCAL_HOSTS = frozenset({"localhost", "127.0.0.1", "::1"})
33
+
34
+ PORTAL = "https://docugen.fibtec.co.uk"
35
+ CONTACT = "https://fibtec.co.uk/#contact"
36
+
37
+ MISSING_KEY = (
38
+ "No DocuGen API key is set. Open the DocuGen plugin's settings and enter one (it starts "
39
+ "with dgk_). An organisation owner makes it on the API keys page of the DocuGen portal "
40
+ f"({PORTAL}) with the scope read only, which cannot spend credit or download anything. "
41
+ f"Access to DocuGen is by request during the pilot: {CONTACT}"
42
+ )
43
+ BAD_KEY = (
44
+ "The DocuGen API key that is set is not a DocuGen key (a DocuGen key starts with dgk_ and "
45
+ "has no spaces). Check it in the DocuGen plugin's settings."
46
+ )
47
+ BAD_BASE_URL = (
48
+ f"{BASE_URL_VARIABLE} is set to an address this server will not use: it must be an https "
49
+ "address (http only for localhost) with no user name, password, query or fragment. Unset "
50
+ "it to use DocuGen's own address."
51
+ )
52
+
53
+
54
+ def clean(value: str | None) -> str | None:
55
+ """`value` stripped, or None when it is empty or an unsubstituted `${user_config...}`
56
+ placeholder, which Claude Code can leave behind for an option that was never set."""
57
+ if value is None:
58
+ return None
59
+ value = value.strip()
60
+ if not value or value.startswith("${"):
61
+ return None
62
+ return value
63
+
64
+
65
+ def key_is_usable(key: str) -> bool:
66
+ return key.startswith("dgk_") and key.isascii() and key.isprintable() and " " not in key
67
+
68
+
69
+ def base_url_is_usable(url: str) -> bool:
70
+ try:
71
+ parts = urlsplit(url)
72
+ _ = parts.port # raises ValueError for a port that is not a number
73
+ except ValueError:
74
+ return False
75
+ if not parts.hostname or parts.scheme not in ("http", "https"):
76
+ return False
77
+ if parts.username or parts.password or parts.query or parts.fragment:
78
+ return False
79
+ return parts.scheme == "https" or parts.hostname in LOCAL_HOSTS
80
+
81
+
82
+ @dataclass(frozen=True)
83
+ class Settings:
84
+ """What the server was started with. `repr` shows no key."""
85
+
86
+ api_key: str | None = field(default=None, repr=False)
87
+ base_url: str | None = DEFAULT_BASE_URL
88
+
89
+ @classmethod
90
+ def from_env(cls, environ: Mapping[str, str] | None = None) -> Settings:
91
+ env = os.environ if environ is None else environ
92
+ override = clean(env.get(BASE_URL_VARIABLE))
93
+ if override is None:
94
+ base_url: str | None = DEFAULT_BASE_URL
95
+ else:
96
+ base_url = override.rstrip("/") if base_url_is_usable(override) else None
97
+ return cls(api_key=clean(env.get(KEY_VARIABLE)), base_url=base_url)
98
+
99
+ def problem(self) -> str | None:
100
+ """The fixed sentence that says what is wrong with the configuration, or None."""
101
+ if self.api_key is None:
102
+ return MISSING_KEY
103
+ if not key_is_usable(self.api_key):
104
+ return BAD_KEY
105
+ if self.base_url is None:
106
+ return BAD_BASE_URL
107
+ return None