mcp-dispatch 0.1.1__tar.gz → 0.2.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.
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/AGENTS.md +5 -3
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/CHANGELOG.md +12 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/PKG-INFO +4 -2
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/README.md +2 -1
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/pyproject.toml +10 -3
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/__init__.py +1 -1
- mcp_dispatch-0.2.0/src/mcp_dispatch/_skill_meaning.py +100 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/agent_instructions/host.md +3 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/agent_instructions/plugin.md +2 -2
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/cli.py +16 -5
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/dispatch.py +5 -1
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/registry.py +206 -97
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/skills.py +115 -29
- mcp_dispatch-0.2.0/src/mcp_dispatch/tables.py +89 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/tests/conftest.py +14 -0
- mcp_dispatch-0.2.0/tests/data/skill_headers.json +127 -0
- mcp_dispatch-0.2.0/tests/data/skill_questions.txt +223 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/tests/test_cli.py +148 -9
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/tests/test_dispatch.py +3 -3
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/tests/test_guides.py +6 -5
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/tests/test_mcp.py +1 -1
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/tests/test_registry_skills.py +4 -4
- mcp_dispatch-0.2.0/tests/test_skill_meaning.py +297 -0
- mcp_dispatch-0.2.0/tests/test_skill_relevance.py +158 -0
- mcp_dispatch-0.2.0/tests/test_tables.py +17 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/trials/README.md +26 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/trials/results/guide.jsonl +48 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/.gitignore +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/LICENSE +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/__main__.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/check.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/command.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/docs.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/errors.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/lenient.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/mcp_tools.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/py.typed +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/tags.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/src/mcp_dispatch/trials.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/tests/__init__.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/tests/helpers.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/tests/test_check.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/tests/test_command.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/tests/test_package.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/tests/test_registry.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/tests/test_skills.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/tests/test_trials.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/trials/guide/kit.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/trials/guide/reference/skills/index.json +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/trials/guide/reference/skills/keep-stock.md +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/trials/guide/reference/stock.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/trials/guide/template/AGENTS.md +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/trials/guide/template/pyproject.toml +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/trials/guide/template/src/labkit/__init__.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/trials/guide/template/src/labkit/host.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/trials/guide/template/src/labkit/store.py +0 -0
- {mcp_dispatch-0.1.1 → mcp_dispatch-0.2.0}/trials/guide/template/tests/test_host.py +0 -0
|
@@ -41,14 +41,16 @@ trials/ the library's own kit: trials of its guides with assistants tha
|
|
|
41
41
|
- **Fail loudly at the start.** A plugin that cannot be loaded, a tag for a tool the host does not have, a skill index that does not list the files that are there: each stops the host. Nothing is logged and skipped.
|
|
42
42
|
- **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
43
|
- **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
|
|
44
|
+
- **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
45
|
- 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
46
|
- Code style: ruff (line length 88) and mypy clean. Test names are sentences that say what holds.
|
|
47
47
|
- Do not push, tag or change `.github/workflows/workflow.yml` (PyPI trusted publishing is bound to that file name) unless asked.
|
|
48
48
|
|
|
49
49
|
## Not built
|
|
50
50
|
|
|
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
|
|
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); 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.
|
|
52
|
+
|
|
53
|
+
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.
|
|
52
54
|
|
|
53
55
|
## What a host like precis needs that is not here
|
|
54
56
|
|
|
@@ -82,7 +84,7 @@ Found by the passes that wrote the tests (28 Nov 2026) and left as they are; non
|
|
|
82
84
|
- `Dispatch.first_read` sizes each schema without the example path a host may give `server`, so it is a few characters low.
|
|
83
85
|
- The guide says an action's arguments are keyword-only; `def go(self, call, thing: str)` registers all the same.
|
|
84
86
|
- 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
|
|
87
|
+
- 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
88
|
- 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
89
|
- 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
90
|
- 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`.
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.0 (29 Nov 2026)
|
|
4
|
+
|
|
5
|
+
How-to guides are found by meaning, and `help` prints tables for a person.
|
|
6
|
+
|
|
7
|
+
- **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.
|
|
8
|
+
- **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.
|
|
9
|
+
- **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.
|
|
10
|
+
- **When the model cannot be loaded** the search matches by words and says so in one line; it tries again after a minute.
|
|
11
|
+
- 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.
|
|
12
|
+
- **`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`.
|
|
13
|
+
- A plugin that asks for `mcp-dispatch>=0.1.1,<0.2` does not get this release. Nothing a plugin imports changed.
|
|
14
|
+
|
|
3
15
|
## 0.1.1 (29 Nov 2026)
|
|
4
16
|
|
|
5
17
|
The first release on PyPI.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: mcp-dispatch
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
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.2.0"
|
|
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,100 @@
|
|
|
1
|
+
"""The process owns the model. Each registry owns its skill vectors."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from collections.abc import Callable
|
|
7
|
+
from itertools import islice
|
|
8
|
+
from math import sumprod
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from threading import Lock
|
|
11
|
+
from time import monotonic
|
|
12
|
+
from typing import TYPE_CHECKING
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from mcp_dispatch.skills import Skill
|
|
16
|
+
|
|
17
|
+
_MODEL = "BAAI/bge-base-en-v1.5"
|
|
18
|
+
_QUERY = "Represent this sentence for searching relevant passages: "
|
|
19
|
+
# Measured on tests/data (13 guides, 156 paraphrases that share at most one
|
|
20
|
+
# word with their guide, 40 unrelated searches), with the instruction:
|
|
21
|
+
# the right guide is first for 148 and scores .414 to .850, median .633.
|
|
22
|
+
#
|
|
23
|
+
# A search for guides: a guide answers above ASKED_SIMILARITY. At .47 the
|
|
24
|
+
# right guide answers 154 of 156 paraphrases; of the 31 unrelated searches
|
|
25
|
+
# of two words or more, 6 are answered (.552 at most), 25 get "no match".
|
|
26
|
+
ASKED_SIMILARITY = 0.47
|
|
27
|
+
# A search that names no kind, beside other packages: a guide is named above
|
|
28
|
+
# UNASKED_SIMILARITY, within UNASKED_WITHIN of the best guide, and only
|
|
29
|
+
# when the search has UNASKED_WORDS words that are not stop words.
|
|
30
|
+
# One-word searches are what score high against any guide ("hub" .764,
|
|
31
|
+
# "person" .732) and had forced a bar of .77, where 4 of 156 paraphrases
|
|
32
|
+
# named their guide. With two words the highest unrelated search scores
|
|
33
|
+
# .552, and a search for notes that says "notes" comes to .594 against the
|
|
34
|
+
# guides on notes. At .62 the right guide is named for 88 of 156
|
|
35
|
+
# paraphrases and no unrelated search names one (.60: 103). The distance to
|
|
36
|
+
# the best keeps a guide that only shares the subject from being named
|
|
37
|
+
# beside the one that fits: "share a hub" is .881 for sharing a hub and
|
|
38
|
+
# .735 for organising notes in hubs.
|
|
39
|
+
UNASKED_SIMILARITY = 0.62
|
|
40
|
+
UNASKED_WITHIN = 0.10
|
|
41
|
+
UNASKED_WORDS = 2
|
|
42
|
+
_RETRY_SECONDS = 60
|
|
43
|
+
type _Embed = Callable[[list[str]], list[list[float]]]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _cache_dir() -> Path:
|
|
47
|
+
if configured := os.environ.get("FASTEMBED_CACHE_PATH"):
|
|
48
|
+
return Path(configured)
|
|
49
|
+
base = os.environ.get("XDG_CACHE_HOME") or Path.home() / ".cache"
|
|
50
|
+
return Path(base) / "mcp-dispatch" / "fastembed"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _load() -> _Embed:
|
|
54
|
+
from fastembed import TextEmbedding
|
|
55
|
+
|
|
56
|
+
model = TextEmbedding(model_name=_MODEL, cache_dir=str(_cache_dir()), threads=2)
|
|
57
|
+
|
|
58
|
+
def embed(texts: list[str]) -> list[list[float]]:
|
|
59
|
+
# BGE's FastEmbed output is already L2-normalised.
|
|
60
|
+
return [vector.tolist() for vector in model.embed(texts)]
|
|
61
|
+
|
|
62
|
+
return embed
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class _Runtime:
|
|
66
|
+
def __init__(self) -> None:
|
|
67
|
+
self.lock = Lock()
|
|
68
|
+
self.embed: _Embed | None = None
|
|
69
|
+
self.retry_at = 0.0
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
_runtime = _Runtime()
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class SkillVectors:
|
|
76
|
+
def __init__(self) -> None:
|
|
77
|
+
self._skills: tuple[Skill, ...] = ()
|
|
78
|
+
self._vectors: list[list[list[float]]] = []
|
|
79
|
+
|
|
80
|
+
def scores(self, skills: tuple[Skill, ...], q: str) -> list[float] | None:
|
|
81
|
+
with _runtime.lock:
|
|
82
|
+
if monotonic() < _runtime.retry_at:
|
|
83
|
+
return None
|
|
84
|
+
try:
|
|
85
|
+
if _runtime.embed is None:
|
|
86
|
+
_runtime.embed = _load()
|
|
87
|
+
if skills != self._skills:
|
|
88
|
+
headers = [(s.title, s.summary, *s.answers) for s in skills]
|
|
89
|
+
vectors = iter(_runtime.embed([t for h in headers for t in h]))
|
|
90
|
+
self._vectors = [list(islice(vectors, len(h))) for h in headers]
|
|
91
|
+
self._skills = skills
|
|
92
|
+
(query,) = _runtime.embed([_QUERY + q])
|
|
93
|
+
except Exception:
|
|
94
|
+
# A missing file or an unusable ONNX session can first show
|
|
95
|
+
# up during inference. Other registries share the retry wait.
|
|
96
|
+
_runtime.embed = None
|
|
97
|
+
_runtime.retry_at = monotonic() + _RETRY_SECONDS
|
|
98
|
+
return None
|
|
99
|
+
vectors_by_skill = self._vectors
|
|
100
|
+
return [max(sumprod(query, v) for v in group) for group in vectors_by_skill]
|
|
@@ -36,8 +36,11 @@ 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
46
|
`find_plugins()` adds 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 cannot be loaded, or that is tagged for a tool you do not have, stops the start: a host that came up without it would answer "not installed" to calls that worked the day before.
|
|
@@ -180,8 +180,8 @@ An assistant finds a skill with `search {"q": "lend a book", "t": "skill"}` and
|
|
|
180
180
|
```
|
|
181
181
|
uv run mcp-dispatch update # writes skills/index.json, then checks
|
|
182
182
|
uv run mcp-dispatch check # checks only; run it in CI
|
|
183
|
-
uv run mcp-dispatch help shelf/
|
|
184
|
-
uv run mcp-dispatch help shelf/add
|
|
183
|
+
uv run mcp-dispatch help --exact shelf/ # what "shelf/?" answers: the actions
|
|
184
|
+
uv run mcp-dispatch help --exact shelf/add # what "shelf/add?" answers
|
|
185
185
|
```
|
|
186
186
|
|
|
187
187
|
Read the help once as if you had never seen the code: it is all the assistant has.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"""The command line: the guide, the check, the updater, and
|
|
2
|
-
assistant would read.
|
|
1
|
+
"""The command line: the guide, the check, the updater, help and calls.
|
|
3
2
|
|
|
4
3
|
mcp-dispatch guide how to write a plugin (for the assistant that does)
|
|
5
4
|
mcp-dispatch guide host how to set up a host
|
|
6
5
|
mcp-dispatch check is everything an assistant will read in order?
|
|
7
6
|
mcp-dispatch update write the generated files (skills/index.json)
|
|
8
|
-
mcp-dispatch help notes/add
|
|
7
|
+
mcp-dispatch help notes/add help in terminal tables
|
|
8
|
+
mcp-dispatch help --exact notes/add what "notes/add?" answers
|
|
9
9
|
mcp-dispatch call create notes/add text="buy milk" make the call
|
|
10
10
|
|
|
11
11
|
``check``, ``update``, ``help`` and ``call`` look at the plugins installed
|
|
@@ -29,6 +29,7 @@ from __future__ import annotations
|
|
|
29
29
|
|
|
30
30
|
import argparse
|
|
31
31
|
import importlib
|
|
32
|
+
import shutil
|
|
32
33
|
import sys
|
|
33
34
|
import tomllib
|
|
34
35
|
from collections.abc import Iterator, Sequence
|
|
@@ -197,13 +198,18 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|
|
197
198
|
for name, text in (
|
|
198
199
|
("check", "report everything that is wrong with what an assistant reads"),
|
|
199
200
|
("update", "write the generated files: skills/index.json, the contract"),
|
|
200
|
-
("help", "
|
|
201
|
+
("help", "show help for a path"),
|
|
201
202
|
):
|
|
202
203
|
one = sub.add_parser(name, help=text)
|
|
203
204
|
one.add_argument("--host", help='"<module>:<name>" of a Dispatch')
|
|
204
205
|
one.add_argument("--group", help=f"the entry point group (default {GROUP})")
|
|
205
206
|
if name == "help":
|
|
206
207
|
one.add_argument("path", nargs="?", default="")
|
|
208
|
+
one.add_argument(
|
|
209
|
+
"--exact",
|
|
210
|
+
action="store_true",
|
|
211
|
+
help="print what a path ending in ? answers",
|
|
212
|
+
)
|
|
207
213
|
else:
|
|
208
214
|
one.add_argument("--contract", help="the file that pins the contract")
|
|
209
215
|
one = sub.add_parser(
|
|
@@ -237,7 +243,12 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|
|
237
243
|
return 1
|
|
238
244
|
if args.command == "help":
|
|
239
245
|
try:
|
|
240
|
-
|
|
246
|
+
path = args.path.rstrip("?")
|
|
247
|
+
if args.exact:
|
|
248
|
+
print(dispatch.registry.help(path))
|
|
249
|
+
else:
|
|
250
|
+
width = shutil.get_terminal_size(fallback=(100, 24)).columns
|
|
251
|
+
print(dispatch.registry.terminal_help(path, width))
|
|
241
252
|
except DispatchError as exc:
|
|
242
253
|
print(exc.render(), file=sys.stderr)
|
|
243
254
|
return 1
|
|
@@ -56,6 +56,7 @@ class Dispatch:
|
|
|
56
56
|
plugin's generated ``skills/index.json``, or ``"files"`` for a test or a
|
|
57
57
|
check, which reads the skill files themselves; left out, the index,
|
|
58
58
|
unless the command line is looking at this host.
|
|
59
|
+
Set ``skill_search="words"`` to match guides by shared words without loading the model.
|
|
59
60
|
"""
|
|
60
61
|
|
|
61
62
|
def __init__(
|
|
@@ -66,8 +67,11 @@ class Dispatch:
|
|
|
66
67
|
group: str = GROUP,
|
|
67
68
|
initial_limit: int | None = INITIAL_LIMIT,
|
|
68
69
|
skills_from: Literal["index", "files"] | None = None,
|
|
70
|
+
skill_search: Literal["meaning", "words"] = "meaning",
|
|
69
71
|
) -> None:
|
|
70
|
-
self.registry = Registry(
|
|
72
|
+
self.registry = Registry(
|
|
73
|
+
tools, search=search, skills_from=skills_from, skill_search=skill_search
|
|
74
|
+
)
|
|
71
75
|
self.group = group
|
|
72
76
|
self.initial_limit = initial_limit
|
|
73
77
|
self._initial: list[str] = []
|