Skip to content

Commit aafbe22

Browse files
authored
fix(mcp): include wikitext in the mcp extra, streamline tools docs (#203)
* docs(tools): document uv tool install for osw and osw-mcp - register the installed `osw-mcp` command instead of `uvx --from` - editable install from a checkout for CLI and MCP development - extras combine, e.g. `osw[mcp,wikitext]` - when `--reinstall` is needed, and the Windows Scripts lock - keep the entity model regeneration warning and name the read-only exception * fix(mcp): include the wikitext extra in the mcp extra - osw.wiki_tools warns at import time without mwparserfromhell - on stdio that warning reaches every MCP client's log * docs(tools): streamline install and registration guidance - index.md: one install path, no developer instructions - mcp.md: name both registration options in the intro - mcp.md: "Which command to register for the MCP server", two options - mcp.md: the editable developer install now lives in Notes for developers - drop `osw[mcp,wikitext]`, since `osw[mcp]` now implies it * docs(mcp): note that uvx reuses an installed osw tool - uvx runs the installed tool when it satisfies the specification - an explicit version keeps a server independent of it
1 parent efde689 commit aafbe22

4 files changed

Lines changed: 95 additions & 15 deletions

File tree

‎docs/tools/index.md‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@ differ in exactly one way: only the CLI accepts filesystem paths.
88

99
## Setup
1010

11-
Install one of the two; the second includes the first:
11+
Install `osw` as a uv tool. The `mcp` extra adds the server to the same install:
1212

1313
```bash
1414
uv tool install osw # the `osw` command
1515
uv tool install "osw[mcp]" # the same, plus the `osw-mcp` server
1616
```
1717

18+
uv writes both console scripts to its tool bin directory, `~/.local/bin` by
19+
default. Run `uv tool update-shell` once if that directory is not on your PATH
20+
yet, and `uv tool upgrade osw` to update them later. Quote the argument:
21+
`osw[mcp]` contains brackets, which zsh reads as a glob pattern and then refuses
22+
to run.
23+
24+
Without the `mcp` extra, uv still writes `osw-mcp` to the bin directory, but
25+
that copy raises `ModuleNotFoundError` at startup. Install `osw[mcp]` before you
26+
register the server with a client.
27+
1828
<details markdown="1">
1929
<summary>Other ways to install</summary>
2030

@@ -24,13 +34,14 @@ uv add "osw[mcp]" # as a dependency of the current uv project
2434
uvx --from "osw[mcp]" osw-mcp # run the server without installing it
2535
```
2636

27-
`uvx` is what the registration examples further down use, so the server needs
28-
no install of its own.
37+
`uvx` needs no install of its own.
38+
[Which command to register](mcp.md#which-command-to-register-for-the-mcp-server)
39+
explains when to prefer it over the installed command.
2940

3041
</details>
3142

32-
`osw[mcp]` is also part of `osw[all]`. The other extras are listed in the
33-
[Get Started guide](../get-started.md#optional-extras).
43+
`osw[mcp]` includes `osw[wikitext]`, and is itself part of `osw[all]`. The other
44+
extras are listed in the [Get Started guide](../get-started.md#optional-extras).
3445

3546
## In this section
3647

‎docs/tools/mcp.md‎

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ introspect category schemas, read entities and every page slot, create/update
88
and delete entities, and read and write file pages as text. The transport is
99
stdio; SSE and HTTP are not supported.
1010

11+
A registered server runs the `osw-mcp` console script, and there are two ways to
12+
reach it: let `uvx` fetch it for each server, or install `osw[mcp]` once and
13+
register the command directly. See
14+
[Which command to register for the MCP server](#which-command-to-register-for-the-mcp-server).
15+
1116
**No filesystem access:** no MCP tool takes or returns a local path. File
1217
content moves inline as text (`get_file_info`, `read_file_text`,
1318
`write_file_text`), and everything path-based lives in the CLI instead
@@ -49,6 +54,36 @@ Notes:
4954
for every project, or `-s project` to write a shared `.mcp.json`.
5055
- List what is registered with `claude mcp list`.
5156

57+
### Which command to register for the MCP server
58+
59+
- **To pin the `osw` version per server, register the `uvx` command**, as in the
60+
example above and in every other example on this page. The package
61+
specification is part of the entry, so one server can name a version or a
62+
checkout that the others do not use. `uvx` needs no install of its own. The
63+
cost is that changing the version means editing every entry that should
64+
change. Note that `uvx` reuses an installed `osw` tool whenever that
65+
installation satisfies the specification, so an unpinned `osw[mcp]` runs the
66+
installed version if there is one. Write an explicit version, for example
67+
`osw[mcp]==2.6.2`, when a server must be independent of it.
68+
69+
- **To let all servers share one `osw` version, register the installed
70+
`osw-mcp` command.** Install `osw[mcp]` as a uv tool ([Setup](index.md#setup)),
71+
then register that command in place of the whole `uvx --from ...` invocation:
72+
73+
```bash
74+
claude mcp add osw-dev \
75+
-e OSW_DOMAIN=wiki-dev.open-semantic-lab.org \
76+
-e OSW_CRED_FILEPATH=/abs/path/to/accounts.pwd.yaml \
77+
-- osw-mcp
78+
```
79+
80+
In JSON that entry is `"command": "osw-mcp"` with an empty `args` array.
81+
`uv tool upgrade osw` then changes the version for every server at once. The
82+
cost is that `osw-mcp` has to be on the PATH of the client, and that no
83+
server can keep an older version.
84+
85+
Everything else about an entry, `env` included, is the same either way.
86+
5287
## Registering a server
5388

5489
A server entry can carry its settings in two ways:
@@ -172,21 +207,50 @@ Why the MCP server is shaped the way it is, and how that differs from the CLI:
172207

173208
## Notes for developers
174209

175-
To try an unreleased branch against a real client, point `uvx` at the checkout
176-
instead of at PyPI. Everything else about the registration stays the same:
210+
To try an unreleased branch against a real client, run it from the checkout. The
211+
same two options apply as above.
212+
213+
Point `uvx` at the checkout instead of at PyPI. Everything else about the
214+
registration stays the same:
177215

178216
```bash
179217
uvx --reinstall --from "/abs/path/to/osw-python[mcp]" osw-mcp
180218
```
181219

182-
`--reinstall` is what picks up your latest edits, since `uvx` caches the wheel
183-
it builds. In a JSON `args` array, a Windows path needs forward slashes or
220+
`--reinstall` is what makes `uvx` use your latest edits, since it caches the
221+
wheel it builds. In a JSON `args` array, a Windows path needs forward slashes or
184222
doubled backslashes.
185223

186-
Prefer that over an editable install for the server. `create_or_update_entity`
187-
and `export_entity_jsonld` call `fetch_schema`, which regenerates
188-
`src/osw/model/entity.py` inside the installed package: `uvx` builds a
189-
non-editable wheel, so the write lands in the uv cache, while under
190-
`pip install -e` or `uv sync` it lands in your working tree. The read tools
224+
Or install the checkout as an editable uv tool. The server then registers as
225+
plain `osw-mcp`, no client config contains the checkout path, and edits take
226+
effect at the next server start without a reinstall:
227+
228+
```bash
229+
cd /path/to/osw-python
230+
uv tool install --reinstall --editable ".[mcp]"
231+
```
232+
233+
`osw` and `osw-mcp` then import from `src/` in that checkout. Four consequences:
234+
235+
- Both commands follow the checked-out branch, so switching branches changes
236+
what a registered server runs.
237+
- Run the install command again after a change to `pyproject.toml`. uv
238+
re-resolves from the checkout and installs the difference.
239+
- Returning to a released version needs `--reinstall`. Without it uv finds the
240+
requirement satisfied, keeps the editable environment and rewrites only the
241+
tool receipt, so receipt and environment disagree.
242+
- On Windows, an install that has to replace the tool environment fails with
243+
`os error 5` while an `osw-mcp` server from it is running, because the running
244+
process locks the tool's `Scripts` directory. Stop the MCP clients first.
245+
246+
One difference decides between `uvx` and the editable install.
247+
`create_or_update_entity` and
248+
`export_entity_jsonld` call `fetch_schema`, which regenerates
249+
`src/osw/model/entity.py` inside the installed package. `uvx` builds a
250+
non-editable wheel, so the regenerated file is written into the uv cache. Under
251+
an editable install, as under `pip install -e` or `uv sync`, it is written into
252+
your working tree, where git tracks it. Note that `export_entity_jsonld` is
253+
declared read-only and still triggers this. The remaining read tools
191254
(`get_entity`, `get_slot`, `get_category_schema`, ...) read raw page slots and
192-
never trigger it.
255+
never trigger it. So choose `uvx` whenever a client may call either of those two
256+
operations, and the editable install otherwise.

‎pyproject.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ mcp = [
8787
# official MCP Python SDK; provides MCPServer from mcp.server.
8888
# requires 2.x: 1.x has no MCPServer, and 2.0 removed the vendored FastMCP.
8989
"mcp>=2",
90+
# without it osw.wiki_tools warns at import time, which is noise on the
91+
# server's stderr and appears in every client's log.
92+
"osw[wikitext]",
9093
]
9194
workflow = [
9295
"prefect>=2.20.25,<3.0",

‎uv.lock‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)