mcp-dispatch 0.1.1__tar.gz → 0.3.0.dev1__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.
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/AGENTS.md +22 -11
- mcp_dispatch-0.3.0.dev1/CHANGELOG.md +54 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/PKG-INFO +4 -2
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/README.md +2 -1
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/pyproject.toml +10 -3
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/__init__.py +1 -1
- mcp_dispatch-0.3.0.dev1/src/mcp_dispatch/_skill_meaning.py +87 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/agent_instructions/host.md +6 -3
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/agent_instructions/plugin.md +8 -9
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/check.py +219 -73
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/cli.py +84 -66
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/dispatch.py +10 -10
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/errors.py +8 -3
- mcp_dispatch-0.3.0.dev1/src/mcp_dispatch/index.py +253 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/mcp_tools.py +1 -1
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/registry.py +461 -180
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/skills.py +136 -169
- mcp_dispatch-0.3.0.dev1/src/mcp_dispatch/tables.py +89 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/tags.py +9 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/tests/conftest.py +14 -8
- mcp_dispatch-0.3.0.dev1/tests/data/skill_headers.json +127 -0
- mcp_dispatch-0.3.0.dev1/tests/data/skill_questions.txt +223 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/tests/helpers.py +6 -2
- mcp_dispatch-0.3.0.dev1/tests/shelf_functions.py +78 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/tests/test_check.py +353 -341
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/tests/test_cli.py +263 -255
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/tests/test_dispatch.py +48 -56
- mcp_dispatch-0.3.0.dev1/tests/test_functions.py +421 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/tests/test_guides.py +20 -38
- mcp_dispatch-0.3.0.dev1/tests/test_index.py +204 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/tests/test_mcp.py +1 -1
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/tests/test_package.py +0 -1
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/tests/test_registry.py +158 -47
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/tests/test_registry_skills.py +34 -138
- mcp_dispatch-0.3.0.dev1/tests/test_skill_meaning.py +297 -0
- mcp_dispatch-0.3.0.dev1/tests/test_skill_relevance.py +163 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/tests/test_skills.py +0 -201
- mcp_dispatch-0.3.0.dev1/tests/test_tables.py +17 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/trials/README.md +26 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/trials/guide/kit.py +1 -2
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/trials/results/guide.jsonl +48 -0
- mcp_dispatch-0.1.1/CHANGELOG.md +0 -24
- mcp_dispatch-0.1.1/trials/guide/reference/skills/index.json +0 -18
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/.gitignore +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/LICENSE +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/__main__.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/command.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/docs.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/lenient.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/py.typed +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/trials.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/tests/__init__.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/tests/test_command.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/tests/test_trials.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/trials/guide/reference/skills/keep-stock.md +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/trials/guide/reference/stock.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/trials/guide/template/AGENTS.md +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/trials/guide/template/pyproject.toml +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/trials/guide/template/src/labkit/__init__.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/trials/guide/template/src/labkit/host.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/trials/guide/template/src/labkit/store.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/trials/guide/template/tests/test_host.py +0 -0
|
@@ -18,17 +18,19 @@ uv run mcp-dispatch guide host # the guide for a host
|
|
|
18
18
|
|
|
19
19
|
```
|
|
20
20
|
src/mcp_dispatch/
|
|
21
|
-
tags.py Plugin, @action, @searches, Tool, standard_tools: what a plugin author imports; no dependencies
|
|
22
|
-
errors.py DispatchError and how it reads to the caller; PluginError,
|
|
23
|
-
registry.py Registry: the tools, the packages, resolve(tool, arguments) -> Help | Bound, argument checks from type hints, the search, help
|
|
24
|
-
skills.py skill files (header, body), the
|
|
21
|
+
tags.py Plugin (and its `modules`), @action, @searches, Tool, standard_tools: what a plugin author imports; no dependencies
|
|
22
|
+
errors.py DispatchError and how it reads to the caller; PluginError, an entry point that cannot be taken
|
|
23
|
+
registry.py Registry: the tools, the packages, resolve(tool, arguments) -> Help | Bound, argument checks from type hints, the search, help; a plugin found through its entry point is loaded at its first use
|
|
24
|
+
skills.py skill files (header, body), read when a package is registered; the guides as a kind of the store in memory and the bars a guide has to clear; the built-in package `skill`
|
|
25
|
+
index.py the one search's store in memory: MemoryIndex with put, remove, search over things of any kind and their pieces, by meaning or by words; `Registry.index`
|
|
26
|
+
_skill_meaning.py the model, which the process owns, and the bars measured for it
|
|
25
27
|
docs.py Google docstrings read into their parts
|
|
26
28
|
lenient.py JSON sent as text, read with repairs
|
|
27
29
|
dispatch.py Dispatch: a host in a few lines (tools, plugins, the initial message, the server)
|
|
28
30
|
mcp_tools.py the tools as an MCP server shows them (`register` and the annotations need the extra `mcp`; the schemas do not)
|
|
29
|
-
check.py problems(dispatch),
|
|
31
|
+
check.py problems(dispatch), what `mcp-dispatch check` does: every action and skill, and a walk through every page of help; integrity(plugins), the same for a package's own tests; run_problems, every call that is shown to an assistant run once with what a test hands over
|
|
30
32
|
command.py a call made without a client: the words of a command line as arguments, `answer(registry, tool, arguments, run)`
|
|
31
|
-
cli.py the command line: guide, check,
|
|
33
|
+
cli.py the command line: guide, check, help, call
|
|
32
34
|
trials.py run_session: one headless assistant session with the tools it is given, its transcript read into calls and counts; what a project's trial kit builds on
|
|
33
35
|
agent_instructions/ plugin.md, host.md: the guides, shipped in the wheel and printed by `mcp-dispatch guide`
|
|
34
36
|
tests/
|
|
@@ -38,17 +40,22 @@ trials/ the library's own kit: trials of its guides with assistants tha
|
|
|
38
40
|
## Rules
|
|
39
41
|
|
|
40
42
|
- **One way to do a thing.** No aliases for arguments, no second form of a call. A wrong form is refused with the right one in the hint.
|
|
41
|
-
- **
|
|
43
|
+
- **One source for each fact.** What an assistant is told about an action is read from the function: its tag, signature, type hints and docstring. Nothing is generated from them and nothing is pinned in a file; a copy would need a test that keeps it in step (`docs/services.md`, part 8).
|
|
44
|
+
- **Found when the host is deployed, not when it is loaded.** A plugin is loaded when it is first used. One that cannot be loaded, or is tagged for a tool the host does not have, answers `Unavailable` and is logged; a skill file that cannot be read is left out and logged. Neither stops the host. `mcp-dispatch check` loads every plugin and returns 1 for each: a host runs it when it is deployed, and a package's own tests run `check.integrity`. What is known without loading a plugin still stops the start: a name that is no package's name, one name for two plugins, a host without a tool that only reads.
|
|
42
45
|
- **The texts are the interface.** The guides, the tools' default descriptions, the help that `registry.py` prints, every error message and hint are read by an assistant that acts on them. A change to one is tried with fresh assistants before it is merged (`trials/README.md`), and judged against the text it replaces in the same batch.
|
|
43
46
|
- **An error says what to do.** Every problem the check prints names the place and the change. Every `DispatchError` that can name the right call does.
|
|
44
|
-
- **Core has
|
|
47
|
+
- **Core has two dependencies**, pydantic and fastembed. Import fastembed inside the model loader. `mcp` is an extra; import it inside the functions that need it.
|
|
45
48
|
- The library knows nothing of a host's storage, identity or transactions: what an action gets as `call` is the host's and is passed through untouched.
|
|
46
49
|
- Code style: ruff (line length 88) and mypy clean. Test names are sentences that say what holds.
|
|
47
50
|
- Do not push, tag or change `.github/workflows/workflow.yml` (PyPI trusted publishing is bound to that file name) unless asked.
|
|
48
51
|
|
|
49
52
|
## Not built
|
|
50
53
|
|
|
51
|
-
A result object (text, tables, hints, what to store); storing what an action returns; one ranked list across packages in a search without `t` (packages answer one after the other
|
|
54
|
+
A result object (text, tables, hints, what to store); storing what an action returns; one ranked list across packages in a search without `t` (packages answer one after the other); plugin tables and migrations; a contract version a plugin states; in the trial runner, a mock server made from a registry (a session can be ended after its first answered call, against a real server) and clients other than Claude Code.
|
|
55
|
+
|
|
56
|
+
Specified and not built (`docs/services.md`): needs and providers, so that a plugin says what it needs and a host provides it; and the services on top, each a package of its own (one Postgres database with a schema for each module, secrets and settings, things and links, the index). It would answer points 2 and 3 below, and "one ranked list across packages" above.
|
|
57
|
+
|
|
58
|
+
Built from that specification on the branch `one-source` and not released: its part 8, one source for each fact, and the first step of its part 5, the store in memory that the search for guides now goes through (`CHANGELOG.md`, 0.3.0). The store in Postgres, the handle a plugin gets and the one ranked list across packages are not built.
|
|
52
59
|
|
|
53
60
|
## What a host like precis needs that is not here
|
|
54
61
|
|
|
@@ -80,9 +87,13 @@ Found by the passes that wrote the tests (28 Nov 2026) and left as they are; non
|
|
|
80
87
|
- An `Example:` written as a list of one call (`{"calls": [{...}]}`) passes the check and is printed in help that way.
|
|
81
88
|
- The skill search with `limit` 0 or below returns one guide; `best_skills(limit=0)` returns none.
|
|
82
89
|
- `Dispatch.first_read` sizes each schema without the example path a host may give `server`, so it is a few characters low.
|
|
83
|
-
-
|
|
90
|
+
- What stands before the `*` of an action is the host's, handed over by name; what stands after it is an argument. An argument written before the `*` stops the registration when the docstring describes it, and is taken for the host's otherwise: a run finds that (`check.run_problems`), the check does not.
|
|
84
91
|
- A `Note:` alone on its line above `Args:` takes the paragraphs after it out of help, up to the next section. The check names the section, so the author is told.
|
|
85
|
-
- The
|
|
92
|
+
- The two bars of the guide search (`_skill_meaning.py`) were set on one calibration set of 13 guides, 156 paraphrases and 40 unrelated searches, and tried on no other. A search for guides is answered by the guides above .47: the right one for 154 of 156 paraphrases, and 6 of 31 unrelated searches get guides where "No skill matches" was due. Beside other packages a guide is named above .62 and within .10 of the best, and only for a search of two words that are not stop words: the right one for 88 of 156, and for no unrelated search. A host with many guides, or guides that are much alike, may need other numbers.
|
|
86
93
|
- A session of the trial runner leaves the client's own copy of the conversation under `~/.claude/projects/`, one directory per working directory of a run.
|
|
87
94
|
- Tried by a host and not here: Reticula's trial kit (its `trials/`) ran 1,530 scenario runs over this library on 29 Nov 2026. What it found about the library's own texts: a tool called `search` draws the first call (the host guide now says so), and how-to guides are read far more often as skills than they were as notes of the host.
|
|
88
95
|
- Not tried with assistants (`trials/README.md`): the host guide; the check's message for an example that is not JSON, which no run of round one came to see; every message added on 28 Nov 2026 by the two test passes; `mcp-dispatch call`.
|
|
96
|
+
- Not tried with assistants, from the branch `one-source` (1 Dec 2026): the refusal `[error:Unavailable] <package> cannot be loaded on this server` and its hint; the refusal `[error:Unavailable] <path> was written for another server: it needs <name>, which a call here does not have`; in the plugin guide, that nothing is generated from a skill file, the commands of section 5 without `update`, and what a tag for a missing tool does; in the host guide, when a plugin is loaded and what the check is for; the message for a `contract` that is still named in `[tool.mcp-dispatch]`. The plugin guide does not yet say that an action can be a plain function of a module (`Plugin.modules`), nor that what stands before its `*` is handed over by name, nor that a package's tests run every shown call once: whether the method form stays beside the function is open (`docs/services.md`, point 13).
|
|
97
|
+
- The store in memory (`index.py`) is the registry's and no guide names it. Taken by the builder and not ruled (`docs/services.md`, part 5, "Built"): piece 0 of a thing is its title and piece 1 the line a hit shows; the bar below which a match is noise is the store's, the .47 measured on guides, for every kind; a plugin can reach the store as `self.registry.index`, and nothing stops it from putting a person's text there (point 17). A search holds the store's lock while the model works, so a second search of that host waits for it.
|
|
98
|
+
- Over MCP a call is resolved on the event loop, so the first use of a plugin that is slow to import holds the server's other calls for as long as the import takes, once.
|
|
99
|
+
- A page of help names the skills that use an action and the kinds every package finds, so asking for any page loads every plugin. Only a call for a path loads one plugin alone. A search loads them all until there is a store that answers it (`docs/services.md`, part 5).
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.0 (not released; the branch `one-source`)
|
|
4
|
+
|
|
5
|
+
One source for each fact (`docs/services.md`, part 8). This release breaks what 0.2 published.
|
|
6
|
+
|
|
7
|
+
- **An action can be a plain function.** A plugin class names modules, `modules = (handlers,)`, and every tagged function those modules define is an action. The registry holds the function itself, so a test that calls it runs what the dispatcher runs. Methods of the class are actions as before.
|
|
8
|
+
- **What stands before the `*` of an action is the host's, handed over by name.** A parameter called `call` gets the call itself, any other gets what the call holds under that name: `def put(call, *, text)`, `def put(conn, viewer, *, text)` and `def now(*, zone)` are one form. A test calls a function with just what it lists. A call that does not hold a name answers `[error:Unavailable] <path> was written for another server`. An argument written before the `*` and described in the docstring stops the registration; it used to register.
|
|
9
|
+
- **An action is looked up where it is defined at each call**, in its module or on its plugin, so a test that replaces a function there replaces the action.
|
|
10
|
+
- **A package's tests run every call that is shown to an assistant once**: `check.run_problems(dispatch, make)` and `integrity(..., call=make)` run the example of each action and each call a skill names, with what the test hands over. A call that its action refuses has reached its function; one that does not get there, or raises, is a problem.
|
|
11
|
+
- **Nothing is generated.** A host reads a plugin's skills from the skill files. Gone: `skills/index.json`, `mcp-dispatch update`, `skills_from` of `Registry`, `Dispatch` and `build_registry`, `check.update`. Delete the `index.json` files; nothing reads them.
|
|
12
|
+
- **Nothing is pinned.** Gone: `Registry.contract()`, `--contract`, and `contract` under `[tool.mcp-dispatch]`, which the command line refuses with what to do. What is lost: a default or a type that changes and that no test asserts.
|
|
13
|
+
- **A plugin is loaded when it is first used.** `find_plugins()` takes note of the entry points and loads nothing. A call or help for a path loads that package; `?`, a search, the skills and any page of help load them all, once.
|
|
14
|
+
- **A plugin that cannot be loaded no longer stops the host.** Calls for its paths answer `[error:Unavailable]`, the log has the reason, `Registry.unavailable` keeps it, and `mcp-dispatch check` returns 1 for it. Run the check when a host is deployed. `PluginError` is now raised only for what the entry points alone show: a name that is no package's name, one name for two plugins.
|
|
15
|
+
- **A skill file that cannot be read** is left out by a running host with a line in the log, and is a problem of the check.
|
|
16
|
+
- **The check walks as an assistant does**: `?`, the search, each package, each action, each argument, with every page of help made. `check.integrity({"shelf": Shelf})` is the same check for a package's own tests, with no host and nothing installed. `problems(dispatch, texts=...)` also checks the calls a host names in texts of its own.
|
|
17
|
+
- **The search for guides goes through a store in memory** (`mcp_dispatch.index`, `Registry.index`): `put`, `remove` and `search` over things of any kind, each with several pieces, by meaning or by words. The guides are its first kind (`docs/services.md`, part 5, the first step). Every answer of a search is as it was. A piece is embedded once, and again only when its text changes; a guide added later no longer has every guide embedded again. Gone, and never part of what a plugin imports: `skills.fits`, `_skill_meaning.SkillVectors`.
|
|
18
|
+
- **Fixed:** an argument whose type has no JSON schema (a `Callable`) registered, and help for its action then raised. It now stops the registration and is named.
|
|
19
|
+
- Not tried with assistants yet: the `Unavailable` refusal and the sentences of both guides that changed (`AGENTS.md`, "Known and open").
|
|
20
|
+
|
|
21
|
+
## 0.2.0 (29 Nov 2026)
|
|
22
|
+
|
|
23
|
+
How-to guides are found by meaning, and `help` prints tables for a person.
|
|
24
|
+
|
|
25
|
+
- **fastembed is a dependency.** An install grows by 27 packages and about 148 MB; the model, `BAAI/bge-base-en-v1.5`, is about 219 MB and is loaded at the first search that needs it. Import, start, `check`, `update`, `help` and `guide` load nothing. The model files are looked for under `FASTEMBED_CACHE_PATH`, else `mcp-dispatch/fastembed` under `XDG_CACHE_HOME` or `~/.cache`. A host that wants none of it passes `skill_search="words"` to `Dispatch` or `Registry` and gets the matching of 0.1.
|
|
26
|
+
- **A search for guides** (`"t": "skill"`, and any search where the guides alone answer) ranks them by how close a guide's title, summary or one of its `answers` is to what was asked. Guides that are not close are left out; when none is, the answer is "No skill matches", as before. `best_skills` ranks the same way.
|
|
27
|
+
- **A search that names no kind** names a guide beside the other packages' answers only when it is close, within reach of the closest, and the search has two words that are not stop words; three guides at most. The rule of 0.1, two shared words, is gone.
|
|
28
|
+
- **When the model cannot be loaded** the search matches by words and says so in one line; it tries again after a minute.
|
|
29
|
+
- The numbers behind the two bars, and what they were measured on, are in `_skill_meaning.py` and `tests/test_skill_relevance.py`. They were set on one set of 13 guides.
|
|
30
|
+
- **`mcp-dispatch help` prints tables** at the width of the terminal. `mcp-dispatch help --exact <path>` prints what an assistant gets for `"<path>?"`, character for character what `help` printed in 0.1. The plugin guide says `help --exact`.
|
|
31
|
+
- A plugin that asks for `mcp-dispatch>=0.1.1,<0.2` does not get this release. Nothing a plugin imports changed.
|
|
32
|
+
|
|
33
|
+
## 0.1.1 (29 Nov 2026)
|
|
34
|
+
|
|
35
|
+
The first release on PyPI.
|
|
36
|
+
|
|
37
|
+
- A search whose `t` holds several kinds (`"paper,memory"`) or means every kind (`"*"`, `"all"`, `"any"`) is refused with the calls to send. It used to go to the package that takes any kind, as one kind of that name.
|
|
38
|
+
- The package passes `mypy --strict`, and the project's own mypy run holds it to that.
|
|
39
|
+
|
|
40
|
+
## 0.1.0 (29 Nov 2026)
|
|
41
|
+
|
|
42
|
+
Tagged, not published: the publish job named no environment and PyPI's trusted publisher is bound to `pypi`. Pre-alpha: the interface may change with any release before 1.0; a release that changes it raises the second number, so a plugin that asks for `>=0.1.1,<0.2` keeps working until then.
|
|
43
|
+
|
|
44
|
+
- Lifted out of Reticula (`reticula_mcp.dispatch`, 0.6.0 in development).
|
|
45
|
+
- The tools are the host's: `Dispatch(tools)` or the standard set `get`, `create`, `destroy`, `share`. An action's tag names its tool. A tag for a tool the host does not have, or a plugin that cannot be loaded, stops the start.
|
|
46
|
+
- The search is a tool of its own, `search`, always there, and takes no path: `search {"q": "...", "t": "<kind>"}`.
|
|
47
|
+
- Skills are markdown files with a header (`title`, `summary`, `answers`). A running host reads the generated `skills/index.json` and a skill's text only when asked.
|
|
48
|
+
- `Dispatch`: a host in a few lines, with an initial message built from parts and limited in size.
|
|
49
|
+
- `mcp-dispatch guide`, `check`, `update`, `help`. The check never prints `ok` for a project in which no plugin was found.
|
|
50
|
+
- `mcp-dispatch call <tool> [<path>] [<key>=<value> ...]` makes a call without a client; a host names what its actions get as `call` under `[tool.mcp-dispatch]`. The function is called for each call; a context manager it returns is entered for that one call, so that a refusal rolls a transaction back.
|
|
51
|
+
- A search that names no kind asks every package. The how-to guides answer there only when one shares two words with what was asked, three at most, and say nothing otherwise; `"t": "skill"` asks for them alone.
|
|
52
|
+
- The host guide says that a call which has to come first is named in the search's description too. Measured on Reticula 0.6.0 (Haiku, 30 runs an arm, one batch): with the search as a tool of its own, the start call came first in 58 of 90 conversations that began with one plain request, and in 90 of 90 once the search's description said so.
|
|
53
|
+
- `mcp_dispatch.trials`: the runner for trials with assistants that have never seen a project. A session has the file tools and a shell, or the tools of an MCP server and nothing else; a conversation can be resumed for its next turn or ended after its first answered call. A project's kit (scenarios, starting state, judging) builds on it.
|
|
54
|
+
- Licence: MIT.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: mcp-dispatch
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0.dev1
|
|
4
4
|
Summary: A few MCP tools with paths behind them: plugins publish actions and skills, help comes from signatures and docstrings, and a check keeps what an assistant reads in order.
|
|
5
5
|
Project-URL: Homepage, https://github.com/retospect/mcp-dispatch
|
|
6
6
|
Project-URL: Repository, https://github.com/retospect/mcp-dispatch
|
|
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
17
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
18
|
Requires-Python: >=3.12
|
|
19
|
+
Requires-Dist: fastembed>=0.9.1
|
|
19
20
|
Requires-Dist: pydantic>=2.7
|
|
20
21
|
Provides-Extra: mcp
|
|
21
22
|
Requires-Dist: mcp<2,>=1.30; extra == 'mcp'
|
|
@@ -43,8 +44,9 @@ What you get:
|
|
|
43
44
|
|
|
44
45
|
- **A small first read.** Five tool descriptions and a short first message, however many actions are installed.
|
|
45
46
|
- **One switch per risk.** A client that lets an assistant read without asking, and asks before it deletes or shares, needs four settings.
|
|
47
|
+
- **Guide search.** Describe a task in your own words to find guides by meaning. By default, the first search over installed guides loads the model.
|
|
46
48
|
- **Plugins.** A package adds its actions by listing one class under an entry point. The host finds it when it starts.
|
|
47
|
-
- **A command line that falls out of it.** `mcp-dispatch call create shelf/add title=Dune` makes the same call without a client, and `mcp-dispatch help shelf/add` prints what an assistant would read about it.
|
|
49
|
+
- **A command line that falls out of it.** `mcp-dispatch call create shelf/add title=Dune` makes the same call without a client, and `mcp-dispatch help --exact shelf/add` prints what an assistant would read about it.
|
|
48
50
|
- **Interface text that is checked.** `mcp-dispatch check` fails when an action is not documented in full, when an example call is not one the action accepts, or when a how-to guide names a call that no longer exists.
|
|
49
51
|
- **Interface text that can be tried.** `mcp_dispatch.trials` runs an assistant that has never seen your server against it, with your tools and nothing else, and keeps what it called. A text an assistant acts on is judged by what assistants do with it, beside the text it replaces.
|
|
50
52
|
|
|
@@ -20,8 +20,9 @@ What you get:
|
|
|
20
20
|
|
|
21
21
|
- **A small first read.** Five tool descriptions and a short first message, however many actions are installed.
|
|
22
22
|
- **One switch per risk.** A client that lets an assistant read without asking, and asks before it deletes or shares, needs four settings.
|
|
23
|
+
- **Guide search.** Describe a task in your own words to find guides by meaning. By default, the first search over installed guides loads the model.
|
|
23
24
|
- **Plugins.** A package adds its actions by listing one class under an entry point. The host finds it when it starts.
|
|
24
|
-
- **A command line that falls out of it.** `mcp-dispatch call create shelf/add title=Dune` makes the same call without a client, and `mcp-dispatch help shelf/add` prints what an assistant would read about it.
|
|
25
|
+
- **A command line that falls out of it.** `mcp-dispatch call create shelf/add title=Dune` makes the same call without a client, and `mcp-dispatch help --exact shelf/add` prints what an assistant would read about it.
|
|
25
26
|
- **Interface text that is checked.** `mcp-dispatch check` fails when an action is not documented in full, when an example call is not one the action accepts, or when a how-to guide names a call that no longer exists.
|
|
26
27
|
- **Interface text that can be tried.** `mcp_dispatch.trials` runs an assistant that has never seen your server against it, with your tools and nothing else, and keeps what it called. A text an assistant acts on is judged by what assistants do with it, beside the text it replaces.
|
|
27
28
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "mcp-dispatch"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0.dev1"
|
|
8
8
|
description = "A few MCP tools with paths behind them: plugins publish actions and skills, help comes from signatures and docstrings, and a check keeps what an assistant reads in order."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.12"
|
|
@@ -20,8 +20,10 @@ classifiers = [
|
|
|
20
20
|
"Intended Audience :: Developers",
|
|
21
21
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
22
22
|
]
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
dependencies = [
|
|
24
|
+
"fastembed>=0.9.1",
|
|
25
|
+
"pydantic>=2.7",
|
|
26
|
+
]
|
|
25
27
|
|
|
26
28
|
[project.optional-dependencies]
|
|
27
29
|
# What a host needs to serve the tools over MCP (Dispatch.server, Dispatch.mount).
|
|
@@ -103,6 +105,11 @@ extra_checks = true
|
|
|
103
105
|
module = ["tests.*"]
|
|
104
106
|
disable_error_code = ["union-attr", "index", "arg-type"]
|
|
105
107
|
|
|
108
|
+
[[tool.mypy.overrides]]
|
|
109
|
+
module = ["fastembed.*"]
|
|
110
|
+
ignore_missing_imports = true
|
|
111
|
+
|
|
106
112
|
[tool.pytest.ini_options]
|
|
107
113
|
testpaths = ["tests"]
|
|
108
114
|
timeout = 60
|
|
115
|
+
markers = ["real_model: checks skill retrieval against locally cached model files"]
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""The process owns the model. Each store in memory owns its vectors (index.py)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from collections.abc import Callable
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from threading import Lock
|
|
9
|
+
from time import monotonic
|
|
10
|
+
|
|
11
|
+
_MODEL = "BAAI/bge-base-en-v1.5"
|
|
12
|
+
_QUERY = "Represent this sentence for searching relevant passages: "
|
|
13
|
+
# Measured on tests/data (13 guides, 156 paraphrases that share at most one
|
|
14
|
+
# word with their guide, 40 unrelated searches), with the instruction:
|
|
15
|
+
# the right guide is first for 148 and scores .414 to .850, median .633.
|
|
16
|
+
#
|
|
17
|
+
# A search for guides: a guide answers above ASKED_SIMILARITY. At .47 the
|
|
18
|
+
# right guide answers 154 of 156 paraphrases; of the 31 unrelated searches
|
|
19
|
+
# of two words or more, 6 are answered (.552 at most), 25 get "no match".
|
|
20
|
+
ASKED_SIMILARITY = 0.47
|
|
21
|
+
# A search that names no kind, beside other packages: a guide is named above
|
|
22
|
+
# UNASKED_SIMILARITY, within UNASKED_WITHIN of the best guide, and only
|
|
23
|
+
# when the search has UNASKED_WORDS words that are not stop words.
|
|
24
|
+
# One-word searches are what score high against any guide ("hub" .764,
|
|
25
|
+
# "person" .732) and had forced a bar of .77, where 4 of 156 paraphrases
|
|
26
|
+
# named their guide. With two words the highest unrelated search scores
|
|
27
|
+
# .552, and a search for notes that says "notes" comes to .594 against the
|
|
28
|
+
# guides on notes. At .62 the right guide is named for 88 of 156
|
|
29
|
+
# paraphrases and no unrelated search names one (.60: 103). The distance to
|
|
30
|
+
# the best keeps a guide that only shares the subject from being named
|
|
31
|
+
# beside the one that fits: "share a hub" is .881 for sharing a hub and
|
|
32
|
+
# .735 for organising notes in hubs.
|
|
33
|
+
UNASKED_SIMILARITY = 0.62
|
|
34
|
+
UNASKED_WITHIN = 0.10
|
|
35
|
+
UNASKED_WORDS = 2
|
|
36
|
+
_RETRY_SECONDS = 60
|
|
37
|
+
type _Embed = Callable[[list[str]], list[list[float]]]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _cache_dir() -> Path:
|
|
41
|
+
if configured := os.environ.get("FASTEMBED_CACHE_PATH"):
|
|
42
|
+
return Path(configured)
|
|
43
|
+
base = os.environ.get("XDG_CACHE_HOME") or Path.home() / ".cache"
|
|
44
|
+
return Path(base) / "mcp-dispatch" / "fastembed"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _load() -> _Embed:
|
|
48
|
+
from fastembed import TextEmbedding
|
|
49
|
+
|
|
50
|
+
model = TextEmbedding(model_name=_MODEL, cache_dir=str(_cache_dir()), threads=2)
|
|
51
|
+
|
|
52
|
+
def embed(texts: list[str]) -> list[list[float]]:
|
|
53
|
+
# BGE's FastEmbed output is already L2-normalised.
|
|
54
|
+
return [vector.tolist() for vector in model.embed(texts)]
|
|
55
|
+
|
|
56
|
+
return embed
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class _Runtime:
|
|
60
|
+
def __init__(self) -> None:
|
|
61
|
+
self.lock = Lock()
|
|
62
|
+
self.embed: _Embed | None = None
|
|
63
|
+
self.retry_at = 0.0
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
_runtime = _Runtime()
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def embedded(texts: list[str], q: str) -> tuple[list[list[float]], list[float]] | None:
|
|
70
|
+
"""The vectors of ``texts`` and of the question ``q``, one caller at a
|
|
71
|
+
time. None while the model cannot be used: it is tried again after
|
|
72
|
+
``_RETRY_SECONDS``, by every store of the process."""
|
|
73
|
+
with _runtime.lock:
|
|
74
|
+
if monotonic() < _runtime.retry_at:
|
|
75
|
+
return None
|
|
76
|
+
try:
|
|
77
|
+
if _runtime.embed is None:
|
|
78
|
+
_runtime.embed = _load()
|
|
79
|
+
vectors = _runtime.embed(texts) if texts else []
|
|
80
|
+
(query,) = _runtime.embed([_QUERY + q])
|
|
81
|
+
except Exception:
|
|
82
|
+
# A missing file or an unusable ONNX session can first show
|
|
83
|
+
# up during inference. Other registries share the retry wait.
|
|
84
|
+
_runtime.embed = None
|
|
85
|
+
_runtime.retry_at = monotonic() + _RETRY_SECONDS
|
|
86
|
+
return None
|
|
87
|
+
return vectors, query
|
|
@@ -25,7 +25,7 @@ if __name__ == "__main__":
|
|
|
25
25
|
dependencies = ["mcp-dispatch[mcp]"]
|
|
26
26
|
|
|
27
27
|
[tool.mcp-dispatch]
|
|
28
|
-
host = "my_package.host:dispatch" # so that check
|
|
28
|
+
host = "my_package.host:dispatch" # so that check and help look at this host
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
A project that has no host of its own and lists its plugins under another entry point group says so in the same table: `group = "my_host.plugins"`.
|
|
@@ -36,11 +36,14 @@ A project that has no host of its own and lists its plugins under another entry
|
|
|
36
36
|
|
|
37
37
|
- Your own words for a standard tool: `Dispatch(standard_tools({"get": "Read the shelf. ..."}))`. A description is read by the assistant before every first call: say what the tool is for and show one call.
|
|
38
38
|
- Your own words for the search: `Dispatch(search="Search the books. ...")`.
|
|
39
|
+
- Guide search and `best_skills` rank by meaning. Pass `skill_search="words"` to `Dispatch` or `Registry` for word matching without loading a model.
|
|
39
40
|
- Your own set: `Dispatch([Tool("read", "...", writes=False), Tool("write", "...")])`. `writes=False` marks a tool that changes nothing; `destructive=True` one whose actions cannot be undone, which a client may ask the person about. One tool must only read. A plugin is written for the names of the tools: with your own set, only plugins tagged for it load.
|
|
40
41
|
|
|
42
|
+
The first guide search loads `BAAI/bge-base-en-v1.5` and embeds the installed headers in memory. Set `FASTEMBED_CACHE_PATH` to reuse model files, including in an image with `HF_HUB_OFFLINE=1`. The default cache is `mcp-dispatch/fastembed` under `XDG_CACHE_HOME` or `~/.cache`. If the model is unavailable, the search matches by words and says so in the answer. A search for guides that none is close to answers "No skill matches"; beside the answers of other packages a guide is named only when it fits well and the search has two words or more.
|
|
43
|
+
|
|
41
44
|
## The plugins
|
|
42
45
|
|
|
43
|
-
`find_plugins()`
|
|
46
|
+
`find_plugins()` takes note of every plugin installed under the entry point group (`Dispatch(group="my_host.plugins")` for a group of your own). `add("shelf", Shelf)` adds one class by hand. A plugin that was found is loaded when it is first used: at the first call or help for one of its paths, or when everything installed is asked for (`?`, a search, the skills). One that cannot be loaded then, or that is tagged for a tool you do not have, does not stop the host: calls for its paths are answered `[error:Unavailable]`, and the log has the reason. Run `uv run mcp-dispatch check` when you deploy the host: it loads every plugin and returns 1 when one cannot be loaded.
|
|
44
47
|
|
|
45
48
|
## What an assistant is told first
|
|
46
49
|
|
|
@@ -99,4 +102,4 @@ A value is passed as its text and read by the action's type hints. What the acti
|
|
|
99
102
|
uv run mcp-dispatch check
|
|
100
103
|
```
|
|
101
104
|
|
|
102
|
-
With `[tool.mcp-dispatch] host = ...` it checks this host: every plugin's docstrings
|
|
105
|
+
With `[tool.mcp-dispatch] host = ...` it checks this host: every plugin's docstrings and skills, and the size of the initial message. Nothing is pinned in a file: the paths and their arguments are what the functions say, and the tests that call them say what holds.
|
{mcp_dispatch-0.1.1 → mcp_dispatch-0.3.0.dev1}/src/mcp_dispatch/agent_instructions/plugin.md
RENAMED
|
@@ -100,7 +100,7 @@ The tag names the tool the action is called through:
|
|
|
100
100
|
| `DESTROY` | removes something for good |
|
|
101
101
|
| `SHARE` | gives someone access, changes it or takes it away |
|
|
102
102
|
|
|
103
|
-
The question for `DESTROY` and `SHARE` is "can it be undone?", not "does it delete?". A tag that names a tool the host does not have
|
|
103
|
+
The question for `DESTROY` and `SHARE` is "can it be undone?", not "does it delete?". A tag that names a tool the host does not have makes the whole package unavailable on that host; the check says so.
|
|
104
104
|
|
|
105
105
|
The shape:
|
|
106
106
|
|
|
@@ -171,17 +171,16 @@ answers:
|
|
|
171
171
|
- The header has `title` and `summary`, one line each, and `answers`: the questions the skill answers, at least one and better three to six, in the words of someone who does not know the answer yet. The search matches a question against these three, so they decide whether the skill is found.
|
|
172
172
|
- No argument lists: the help has them. Say which calls, in which order, and why.
|
|
173
173
|
- Write every example call as `<tool> {json}`, the JSON exactly as it is sent: each is read as JSON and checked against the signatures. A blank for the assistant to fill is a string, quotes included: `"book": "<the book's id>"`. A number or a yes/no has no blank: write a real value, `"count": 5`, and say in the sentence what it stands for. `"count": <how many>` is not JSON and fails the check.
|
|
174
|
-
-
|
|
174
|
+
- Nothing is generated from a skill file and nothing is written beside it. A host reads the headers when it loads the package. A file it cannot read is left out there, and the check names it: run the check after adding or changing a skill.
|
|
175
175
|
|
|
176
176
|
An assistant finds a skill with `search {"q": "lend a book", "t": "skill"}` and reads it with `get {"path": "skill/get", "name": "lend-a-book"}`.
|
|
177
177
|
|
|
178
|
-
## 5. Check,
|
|
178
|
+
## 5. Check, read it as the assistant will
|
|
179
179
|
|
|
180
180
|
```
|
|
181
|
-
uv run mcp-dispatch
|
|
182
|
-
uv run mcp-dispatch
|
|
183
|
-
uv run mcp-dispatch help shelf/
|
|
184
|
-
uv run mcp-dispatch help shelf/add # what "shelf/add?" answers
|
|
181
|
+
uv run mcp-dispatch check # run it in CI too
|
|
182
|
+
uv run mcp-dispatch help --exact shelf/ # what "shelf/?" answers: the actions
|
|
183
|
+
uv run mcp-dispatch help --exact shelf/add # what "shelf/add?" answers
|
|
185
184
|
```
|
|
186
185
|
|
|
187
186
|
Read the help once as if you had never seen the code: it is all the assistant has.
|
|
@@ -199,7 +198,7 @@ class Books: # stands in for what the host hands to every call
|
|
|
199
198
|
return "b12"
|
|
200
199
|
|
|
201
200
|
|
|
202
|
-
registry = Registry(
|
|
201
|
+
registry = Registry()
|
|
203
202
|
registry.register("shelf", Shelf)
|
|
204
203
|
found = registry.resolve("create", {"path": "shelf/add", "title": "Dune"})
|
|
205
204
|
assert isinstance(found, Bound)
|
|
@@ -214,7 +213,7 @@ from mcp_dispatch.check import problems
|
|
|
214
213
|
|
|
215
214
|
|
|
216
215
|
def test_everything_an_assistant_reads_is_in_order():
|
|
217
|
-
dispatch = Dispatch(
|
|
216
|
+
dispatch = Dispatch()
|
|
218
217
|
assert dispatch.find_plugins(), "no plugin was found: is its entry point listed?"
|
|
219
218
|
assert problems(dispatch) == []
|
|
220
219
|
```
|