glossary-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,39 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ pull_request:
7
+
8
+ # Least privilege: the test job only reads the repo.
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ matrix:
17
+ python-version: ["3.11", "3.12"]
18
+ env:
19
+ UV_PYTHON: ${{ matrix.python-version }}
20
+ steps:
21
+ # SHA-pinned, node24-runtime actions.
22
+ - name: Checkout
23
+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
24
+ with:
25
+ persist-credentials: false
26
+
27
+ - name: Install uv
28
+ uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
29
+ with:
30
+ enable-cache: true
31
+
32
+ - name: Install Python ${{ matrix.python-version }}
33
+ run: uv python install ${{ matrix.python-version }}
34
+
35
+ - name: Sync dependencies (frozen)
36
+ run: uv sync --frozen
37
+
38
+ - name: Run tests with branch coverage
39
+ run: uv run pytest
@@ -0,0 +1,35 @@
1
+ name: Release
2
+
3
+ # Publish to PyPI via Trusted Publishing (OIDC — no stored token) when a
4
+ # v* tag is pushed. Configure the trusted publisher on PyPI first (see the
5
+ # release notes): project glossary-mcp, owner dhh1128, repo
6
+ # glossary-mcp, workflow release.yml.
7
+ on:
8
+ push:
9
+ tags: ["v*"]
10
+
11
+ # Least privilege by default; the publish job additionally requests id-token.
12
+ permissions:
13
+ contents: read
14
+
15
+ jobs:
16
+ publish:
17
+ runs-on: ubuntu-latest
18
+ permissions:
19
+ contents: read
20
+ id-token: write # mint the OIDC token uv exchanges for a PyPI upload token
21
+ steps:
22
+ # SHA-pinned, node24-runtime actions (match CI).
23
+ - name: Checkout
24
+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
25
+ with:
26
+ persist-credentials: false
27
+
28
+ - name: Install uv
29
+ uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
30
+
31
+ - name: Build sdist and wheel
32
+ run: uv build
33
+
34
+ - name: Publish to PyPI (Trusted Publishing)
35
+ run: uv publish --trusted-publishing always
@@ -0,0 +1,31 @@
1
+ # ── Python ────────────────────────────────────────────────────────────────────
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ *.egg
7
+ *.egg-info/
8
+ dist/
9
+ build/
10
+ eggs/
11
+ develop-eggs/
12
+ wheels/
13
+ share/python-wheels/
14
+ MANIFEST
15
+
16
+ # Virtual environments
17
+ .venv/
18
+ venv/
19
+ env/
20
+ ENV/
21
+ .env
22
+
23
+ # Test / tooling caches
24
+ .pytest_cache/
25
+ .coverage
26
+ htmlcov/
27
+ .mypy_cache/
28
+ .ruff_cache/
29
+
30
+ # codebase-memory-mcp graph
31
+ .codebase-memory/
@@ -0,0 +1,40 @@
1
+ # Agent instructions — glossary-mcp
2
+
3
+ A general-purpose MCP server over the [conlangkit](https://github.com/dhh1128/conlangkit)
4
+ glossary format. It reads, searches, and **safely edits** a glossary file for any
5
+ project. conlangkit is the format authority (a normal PyPI dependency); glossary
6
+ handling lives in `conlangkit.glossary`, which this server wraps — do not
7
+ reimplement parsing. All conlangkit imports are funnelled through `glossary_io`.
8
+
9
+ ## Methodology
10
+
11
+ Non-trivial work runs under the `cc` craft methodology (`~/code/me/cc`, edition
12
+ 0.1) — this repo is a *consumer*, referencing it by path. Read
13
+ `~/code/me/cc/constitution.md` first; skim `ledger.md` for a pre-mortem.
14
+
15
+ ## Testing protocol (strict TDD)
16
+
17
+ 1. Write one or more failing tests capturing each requirement (happy path **and**
18
+ edge/unhappy paths) before implementing.
19
+ 2. Implement until all tests pass.
20
+ 3. Never commit unless all tests pass; coverage of code you touch must not
21
+ decrease. The **write path** (`add_term`/`update_term`, atomic save,
22
+ minimal-diff, escape round-trip) is the risky part — cover it hard.
23
+
24
+ ## Engineering standards
25
+
26
+ - Python 3.11+, **uv** (`uv sync`, `uv run pytest`); 100% branch-coverage gate.
27
+ - **DCO sign-off** (`-s`) on every commit. Commit locally; the maintainer pushes.
28
+ - CI actions pinned to **node24-runtime** versions (SHA-pinned `actions/checkout@v6`,
29
+ `astral-sh/setup-uv`); verify each tag's runtime before bumping.
30
+ - Writes go through conlangkit (`insert`/`update` + `save`): conlangkit owns sort
31
+ order (byte order) and re-emits the file. Keep the glossary in that canonical
32
+ order so writes stay minimal-diff. Saves are atomic (temp + `os.replace`); the
33
+ file is re-read before each write. Do not add line-level editing on top of conlangkit.
34
+
35
+ ## Format note
36
+
37
+ A literal `/` in a definition is stored backslash-escaped on disk (`\/`); the
38
+ server escapes/unescapes transparently so callers deal only in plain prose. Never
39
+ hand-write an unescaped literal slash into a definition cell — conlangkit reads a
40
+ bare `/` as the sense separator.
@@ -0,0 +1 @@
1
+ YOU MUST read and follow `AGENTS.md` at the repository root before making any change; `AGENTS.md` is the authoritative instruction file for this repository, and the current file is only a pointer for tools that look for tool-specific instruction files.
@@ -0,0 +1 @@
1
+ YOU MUST read and follow `AGENTS.md` at the repository root before making any change; `AGENTS.md` is the authoritative instruction file for this repository, and the current file is only a pointer for tools that look for tool-specific instruction files.
@@ -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,169 @@
1
+ Metadata-Version: 2.4
2
+ Name: glossary-mcp
3
+ Version: 0.1.0
4
+ Summary: General-purpose MCP server to read, search, and safely edit a conlangkit-format glossary
5
+ Project-URL: Homepage, https://github.com/dhh1128/glossary-mcp
6
+ Project-URL: Repository, https://github.com/dhh1128/glossary-mcp
7
+ Project-URL: Issues, https://github.com/dhh1128/glossary-mcp/issues
8
+ Author-email: Daniel Hardman <daniel.hardman@gmail.com>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: claude,conlangkit,glossary,mcp,terminology
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Libraries
17
+ Requires-Python: >=3.11
18
+ Requires-Dist: conlangkit>=0.1
19
+ Requires-Dist: mcp>=1.0
20
+ Requires-Dist: pydantic>=2.0
21
+ Description-Content-Type: text/markdown
22
+
23
+ # glossary-mcp
24
+
25
+ [![CI](https://github.com/dhh1128/glossary-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/dhh1128/glossary-mcp/actions/workflows/ci.yml)
26
+
27
+ A small, **general-purpose** MCP server that lets an AI **read, search, and safely
28
+ edit a glossary file** in the [conlangkit](https://github.com/dhh1128/conlangkit)
29
+ glossary format — for *any* glossary, not tied to any one project.
30
+
31
+ The glossary is a Markdown pipe-table with four columns:
32
+
33
+ ```
34
+ lemma | tags | definition | notes
35
+ ----- | ---- | ---------- | -----
36
+ core | tier | the constitutive tier-1 material of a party | never shared
37
+ ```
38
+
39
+ Writes go through conlangkit, which owns the file: it keeps entries sorted (by byte
40
+ order) and re-emits the glossary on save. On an already-sorted file that yields a
41
+ **minimal diff** — only the touched row moves. The file is re-read from disk before
42
+ each write (so a long-lived server picks up external hand-edits) and the write is
43
+ atomic (temp file + `os.replace`).
44
+
45
+ ## Prerequisites
46
+
47
+ - Python 3.11+
48
+ - [uv](https://docs.astral.sh/uv/)
49
+ - A glossary directory or file, pointed to by `GLOSSARY_PATH`
50
+
51
+ [conlangkit](https://github.com/dhh1128/conlangkit) (the glossary format library)
52
+ is a normal PyPI dependency, pulled in by `uv sync`.
53
+
54
+ ## Installation
55
+
56
+ ```bash
57
+ uv sync # creates .venv, installs glossary-mcp (editable) + conlangkit + dev deps
58
+ ```
59
+
60
+ ## Running tests
61
+
62
+ ```bash
63
+ uv run pytest # runs the suite with branch coverage (gate: 100%)
64
+ ```
65
+
66
+ The smoke tests run without `GLOSSARY_PATH`. Integration tests run against a
67
+ fixture glossary.
68
+
69
+ ## Running the server
70
+
71
+ ```bash
72
+ export GLOSSARY_PATH=/path/to/glossary # a directory containing glossary.md …
73
+ export GLOSSARY_PATH=/path/to/glossary.md # … or a direct path to the file
74
+ uv run glossary-mcp
75
+ ```
76
+
77
+ `GLOSSARY_PATH` may be a **directory** (the server looks for `glossary.md` inside
78
+ it) or a **file**. The server uses stdio transport. For a local checkout, set
79
+ `command` to a resolvable path, e.g. the project's
80
+ `/path/to/glossary-mcp/.venv/bin/glossary-mcp`:
81
+
82
+ ```json
83
+ {
84
+ "mcpServers": {
85
+ "glossary": {
86
+ "command": "glossary-mcp",
87
+ "env": {
88
+ "GLOSSARY_PATH": "/path/to/glossary"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ For consuming the **published** package from *another* repo without a local
96
+ checkout or absolute paths, use `uvx` — see the next section.
97
+
98
+ ## Consuming from another repo (portable `.mcp.json`)
99
+
100
+ `glossary-mcp` is published to [PyPI](https://pypi.org/project/glossary-mcp/),
101
+ so any other repo can wire it into its MCP configuration with **no local checkout,
102
+ no venv, and no absolute paths**. `uvx` fetches and caches the package (and its
103
+ `conlangkit` / `mcp` dependencies) on demand:
104
+
105
+ ```json
106
+ {
107
+ "mcpServers": {
108
+ "glossary": {
109
+ "type": "stdio",
110
+ "command": "uvx",
111
+ "args": ["glossary-mcp==0.1.0"],
112
+ "env": {
113
+ "GLOSSARY_PATH": "${CLAUDE_PROJECT_DIR:-.}/../glossary"
114
+ }
115
+ }
116
+ }
117
+ }
118
+ ```
119
+
120
+ - **`command: "uvx"`, `args: ["glossary-mcp"]`** — the console-script name
121
+ equals the package name, so **no `--from` flag is needed**. `uvx` resolves the
122
+ package from PyPI into an ephemeral, cached environment on first launch.
123
+ - **`GLOSSARY_PATH`** is the only required environment variable. It may point at a
124
+ directory (the server looks for `glossary.md` inside) or directly at a file. The
125
+ `${CLAUDE_PROJECT_DIR:-.}/../glossary` value assumes the standard sibling layout
126
+ where the consuming repo and its `glossary` repo are checked out side by side.
127
+ `${CLAUDE_PROJECT_DIR}` resolves the project root and requires **Claude Code ≥
128
+ v2.1.195**; the `:-.` fallback keeps it working (relative to the current
129
+ directory) on older versions and other MCP clients.
130
+ - **Pin the version while pre-1.0.** Because the tool surface may still change
131
+ before 1.0, pin so a new release can't reach every consuming repo at once and
132
+ break them in lockstep: `"args": ["glossary-mcp==0.1.0"]`. Bump
133
+ deliberately (repo by repo, or via your propagation tooling). Float the version
134
+ (bare `"glossary-mcp"`, always latest) only once the surface stabilizes
135
+ at ≥ 1.0.
136
+
137
+ ## Tools
138
+
139
+ | Tool | Description |
140
+ |---|---|
141
+ | `lookup_term` | Exact lemma lookup → tags, definition, notes |
142
+ | `search_by_definition` | Find entries whose definition matches a query |
143
+ | `search_notes` | Free-text search over the notes column |
144
+ | `glossary_stats` | Entry count, tag histogram, unique-tag count |
145
+ | `list_terms` | All lemmas, optionally filtered by tag |
146
+ | `add_term` | Append a new entry (refuses a duplicate lemma) |
147
+ | `update_term` | Edit an existing entry's tags/definition/notes by lemma |
148
+
149
+ ### A note on slashes in definitions
150
+
151
+ In the conlangkit format, `/` separates alternative senses in the definition column.
152
+ A definition that contains a *literal* slash (e.g. `allow/ask/deny`) is stored
153
+ escaped on disk as `allow\/ask\/deny` — which renders as a plain `/` on GitHub
154
+ (CommonMark/GFM). **You never type the escape**: pass ordinary prose (with plain
155
+ slashes) to `add_term`/`update_term`, and read ordinary prose back — the server
156
+ escapes and unescapes transparently.
157
+
158
+ ### Case sensitivity
159
+
160
+ Lemma lookup, insertion, and sorting are **case-sensitive** (byte order) — conlangkit
161
+ targets writing systems where case-folding is not meaningful, so `core` and `Core`
162
+ are distinct entries. Use each term's canonical case: lowercase for ordinary terms,
163
+ uppercase for acronyms (`AID`, `GCD`). This keeps you from creating near-duplicates.
164
+
165
+ ## Methodology
166
+
167
+ Non-trivial work in this repo runs under the `cc` craft methodology
168
+ (`~/code/me/cc`); read `constitution.md` first. Follow strict TDD (see
169
+ `AGENTS.md`).
@@ -0,0 +1,147 @@
1
+ # glossary-mcp
2
+
3
+ [![CI](https://github.com/dhh1128/glossary-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/dhh1128/glossary-mcp/actions/workflows/ci.yml)
4
+
5
+ A small, **general-purpose** MCP server that lets an AI **read, search, and safely
6
+ edit a glossary file** in the [conlangkit](https://github.com/dhh1128/conlangkit)
7
+ glossary format — for *any* glossary, not tied to any one project.
8
+
9
+ The glossary is a Markdown pipe-table with four columns:
10
+
11
+ ```
12
+ lemma | tags | definition | notes
13
+ ----- | ---- | ---------- | -----
14
+ core | tier | the constitutive tier-1 material of a party | never shared
15
+ ```
16
+
17
+ Writes go through conlangkit, which owns the file: it keeps entries sorted (by byte
18
+ order) and re-emits the glossary on save. On an already-sorted file that yields a
19
+ **minimal diff** — only the touched row moves. The file is re-read from disk before
20
+ each write (so a long-lived server picks up external hand-edits) and the write is
21
+ atomic (temp file + `os.replace`).
22
+
23
+ ## Prerequisites
24
+
25
+ - Python 3.11+
26
+ - [uv](https://docs.astral.sh/uv/)
27
+ - A glossary directory or file, pointed to by `GLOSSARY_PATH`
28
+
29
+ [conlangkit](https://github.com/dhh1128/conlangkit) (the glossary format library)
30
+ is a normal PyPI dependency, pulled in by `uv sync`.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ uv sync # creates .venv, installs glossary-mcp (editable) + conlangkit + dev deps
36
+ ```
37
+
38
+ ## Running tests
39
+
40
+ ```bash
41
+ uv run pytest # runs the suite with branch coverage (gate: 100%)
42
+ ```
43
+
44
+ The smoke tests run without `GLOSSARY_PATH`. Integration tests run against a
45
+ fixture glossary.
46
+
47
+ ## Running the server
48
+
49
+ ```bash
50
+ export GLOSSARY_PATH=/path/to/glossary # a directory containing glossary.md …
51
+ export GLOSSARY_PATH=/path/to/glossary.md # … or a direct path to the file
52
+ uv run glossary-mcp
53
+ ```
54
+
55
+ `GLOSSARY_PATH` may be a **directory** (the server looks for `glossary.md` inside
56
+ it) or a **file**. The server uses stdio transport. For a local checkout, set
57
+ `command` to a resolvable path, e.g. the project's
58
+ `/path/to/glossary-mcp/.venv/bin/glossary-mcp`:
59
+
60
+ ```json
61
+ {
62
+ "mcpServers": {
63
+ "glossary": {
64
+ "command": "glossary-mcp",
65
+ "env": {
66
+ "GLOSSARY_PATH": "/path/to/glossary"
67
+ }
68
+ }
69
+ }
70
+ }
71
+ ```
72
+
73
+ For consuming the **published** package from *another* repo without a local
74
+ checkout or absolute paths, use `uvx` — see the next section.
75
+
76
+ ## Consuming from another repo (portable `.mcp.json`)
77
+
78
+ `glossary-mcp` is published to [PyPI](https://pypi.org/project/glossary-mcp/),
79
+ so any other repo can wire it into its MCP configuration with **no local checkout,
80
+ no venv, and no absolute paths**. `uvx` fetches and caches the package (and its
81
+ `conlangkit` / `mcp` dependencies) on demand:
82
+
83
+ ```json
84
+ {
85
+ "mcpServers": {
86
+ "glossary": {
87
+ "type": "stdio",
88
+ "command": "uvx",
89
+ "args": ["glossary-mcp==0.1.0"],
90
+ "env": {
91
+ "GLOSSARY_PATH": "${CLAUDE_PROJECT_DIR:-.}/../glossary"
92
+ }
93
+ }
94
+ }
95
+ }
96
+ ```
97
+
98
+ - **`command: "uvx"`, `args: ["glossary-mcp"]`** — the console-script name
99
+ equals the package name, so **no `--from` flag is needed**. `uvx` resolves the
100
+ package from PyPI into an ephemeral, cached environment on first launch.
101
+ - **`GLOSSARY_PATH`** is the only required environment variable. It may point at a
102
+ directory (the server looks for `glossary.md` inside) or directly at a file. The
103
+ `${CLAUDE_PROJECT_DIR:-.}/../glossary` value assumes the standard sibling layout
104
+ where the consuming repo and its `glossary` repo are checked out side by side.
105
+ `${CLAUDE_PROJECT_DIR}` resolves the project root and requires **Claude Code ≥
106
+ v2.1.195**; the `:-.` fallback keeps it working (relative to the current
107
+ directory) on older versions and other MCP clients.
108
+ - **Pin the version while pre-1.0.** Because the tool surface may still change
109
+ before 1.0, pin so a new release can't reach every consuming repo at once and
110
+ break them in lockstep: `"args": ["glossary-mcp==0.1.0"]`. Bump
111
+ deliberately (repo by repo, or via your propagation tooling). Float the version
112
+ (bare `"glossary-mcp"`, always latest) only once the surface stabilizes
113
+ at ≥ 1.0.
114
+
115
+ ## Tools
116
+
117
+ | Tool | Description |
118
+ |---|---|
119
+ | `lookup_term` | Exact lemma lookup → tags, definition, notes |
120
+ | `search_by_definition` | Find entries whose definition matches a query |
121
+ | `search_notes` | Free-text search over the notes column |
122
+ | `glossary_stats` | Entry count, tag histogram, unique-tag count |
123
+ | `list_terms` | All lemmas, optionally filtered by tag |
124
+ | `add_term` | Append a new entry (refuses a duplicate lemma) |
125
+ | `update_term` | Edit an existing entry's tags/definition/notes by lemma |
126
+
127
+ ### A note on slashes in definitions
128
+
129
+ In the conlangkit format, `/` separates alternative senses in the definition column.
130
+ A definition that contains a *literal* slash (e.g. `allow/ask/deny`) is stored
131
+ escaped on disk as `allow\/ask\/deny` — which renders as a plain `/` on GitHub
132
+ (CommonMark/GFM). **You never type the escape**: pass ordinary prose (with plain
133
+ slashes) to `add_term`/`update_term`, and read ordinary prose back — the server
134
+ escapes and unescapes transparently.
135
+
136
+ ### Case sensitivity
137
+
138
+ Lemma lookup, insertion, and sorting are **case-sensitive** (byte order) — conlangkit
139
+ targets writing systems where case-folding is not meaningful, so `core` and `Core`
140
+ are distinct entries. Use each term's canonical case: lowercase for ordinary terms,
141
+ uppercase for acronyms (`AID`, `GCD`). This keeps you from creating near-duplicates.
142
+
143
+ ## Methodology
144
+
145
+ Non-trivial work in this repo runs under the `cc` craft methodology
146
+ (`~/code/me/cc`); read `constitution.md` first. Follow strict TDD (see
147
+ `AGENTS.md`).