mcp-dispatch 0.1.1__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.
Files changed (50) hide show
  1. mcp_dispatch-0.1.1/.gitignore +20 -0
  2. mcp_dispatch-0.1.1/AGENTS.md +88 -0
  3. mcp_dispatch-0.1.1/CHANGELOG.md +24 -0
  4. mcp_dispatch-0.1.1/LICENSE +21 -0
  5. mcp_dispatch-0.1.1/PKG-INFO +86 -0
  6. mcp_dispatch-0.1.1/README.md +63 -0
  7. mcp_dispatch-0.1.1/pyproject.toml +108 -0
  8. mcp_dispatch-0.1.1/src/mcp_dispatch/__init__.py +59 -0
  9. mcp_dispatch-0.1.1/src/mcp_dispatch/__main__.py +3 -0
  10. mcp_dispatch-0.1.1/src/mcp_dispatch/agent_instructions/host.md +102 -0
  11. mcp_dispatch-0.1.1/src/mcp_dispatch/agent_instructions/plugin.md +222 -0
  12. mcp_dispatch-0.1.1/src/mcp_dispatch/check.py +310 -0
  13. mcp_dispatch-0.1.1/src/mcp_dispatch/cli.py +276 -0
  14. mcp_dispatch-0.1.1/src/mcp_dispatch/command.py +121 -0
  15. mcp_dispatch-0.1.1/src/mcp_dispatch/dispatch.py +208 -0
  16. mcp_dispatch-0.1.1/src/mcp_dispatch/docs.py +100 -0
  17. mcp_dispatch-0.1.1/src/mcp_dispatch/errors.py +32 -0
  18. mcp_dispatch-0.1.1/src/mcp_dispatch/lenient.py +172 -0
  19. mcp_dispatch-0.1.1/src/mcp_dispatch/mcp_tools.py +195 -0
  20. mcp_dispatch-0.1.1/src/mcp_dispatch/py.typed +0 -0
  21. mcp_dispatch-0.1.1/src/mcp_dispatch/registry.py +972 -0
  22. mcp_dispatch-0.1.1/src/mcp_dispatch/skills.py +533 -0
  23. mcp_dispatch-0.1.1/src/mcp_dispatch/tags.py +173 -0
  24. mcp_dispatch-0.1.1/src/mcp_dispatch/trials.py +380 -0
  25. mcp_dispatch-0.1.1/tests/__init__.py +0 -0
  26. mcp_dispatch-0.1.1/tests/conftest.py +38 -0
  27. mcp_dispatch-0.1.1/tests/helpers.py +81 -0
  28. mcp_dispatch-0.1.1/tests/test_check.py +1274 -0
  29. mcp_dispatch-0.1.1/tests/test_cli.py +849 -0
  30. mcp_dispatch-0.1.1/tests/test_command.py +389 -0
  31. mcp_dispatch-0.1.1/tests/test_dispatch.py +433 -0
  32. mcp_dispatch-0.1.1/tests/test_guides.py +452 -0
  33. mcp_dispatch-0.1.1/tests/test_mcp.py +1032 -0
  34. mcp_dispatch-0.1.1/tests/test_package.py +59 -0
  35. mcp_dispatch-0.1.1/tests/test_registry.py +1501 -0
  36. mcp_dispatch-0.1.1/tests/test_registry_skills.py +779 -0
  37. mcp_dispatch-0.1.1/tests/test_skills.py +916 -0
  38. mcp_dispatch-0.1.1/tests/test_trials.py +197 -0
  39. mcp_dispatch-0.1.1/trials/README.md +74 -0
  40. mcp_dispatch-0.1.1/trials/guide/kit.py +519 -0
  41. mcp_dispatch-0.1.1/trials/guide/reference/skills/index.json +18 -0
  42. mcp_dispatch-0.1.1/trials/guide/reference/skills/keep-stock.md +14 -0
  43. mcp_dispatch-0.1.1/trials/guide/reference/stock.py +72 -0
  44. mcp_dispatch-0.1.1/trials/guide/template/AGENTS.md +8 -0
  45. mcp_dispatch-0.1.1/trials/guide/template/pyproject.toml +22 -0
  46. mcp_dispatch-0.1.1/trials/guide/template/src/labkit/__init__.py +1 -0
  47. mcp_dispatch-0.1.1/trials/guide/template/src/labkit/host.py +31 -0
  48. mcp_dispatch-0.1.1/trials/guide/template/src/labkit/store.py +28 -0
  49. mcp_dispatch-0.1.1/trials/guide/template/tests/test_host.py +7 -0
  50. mcp_dispatch-0.1.1/trials/results/guide.jsonl +52 -0
@@ -0,0 +1,20 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .mypy_cache/
7
+ .ruff_cache/
8
+ .pytest_cache/
9
+ .venv/
10
+ .coverage
11
+ htmlcov/
12
+
13
+ # secrets
14
+ .env
15
+ .env.*
16
+ *.pem
17
+ *.key
18
+
19
+ # what a trial run leaves behind (trials/README.md)
20
+ trials/runs/
@@ -0,0 +1,88 @@
1
+ # AGENTS.md: mcp-dispatch
2
+
3
+ A small framework for MCP servers used by language models: a few tools, paths behind them, plugins that publish actions and skills. Assistants write against it; people read the README.
4
+
5
+ If you are here to BUILD ON the library (write a plugin, set up a host), you do not need this file: run `uv run mcp-dispatch guide` in your own project. This file is for work ON the library.
6
+
7
+ ## Set up, test
8
+
9
+ ```
10
+ uv sync
11
+ uv run pytest
12
+ uv run ruff check . && uv run ruff format --check . && uv run mypy
13
+ uv run mcp-dispatch guide # the guide a plugin author reads
14
+ uv run mcp-dispatch guide host # the guide for a host
15
+ ```
16
+
17
+ ## Layout
18
+
19
+ ```
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, a plugin that cannot be loaded
23
+ registry.py Registry: the tools, the packages, resolve(tool, arguments) -> Help | Bound, argument checks from type hints, the search, help, contract()
24
+ skills.py skill files (header, body), the generated index, the search over skills, the built-in package `skill`
25
+ docs.py Google docstrings read into their parts
26
+ lenient.py JSON sent as text, read with repairs
27
+ dispatch.py Dispatch: a host in a few lines (tools, plugins, the initial message, the server)
28
+ 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), update(dispatch): what `mcp-dispatch check` and `update` do
30
+ 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, update, help, call
32
+ 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
+ agent_instructions/ plugin.md, host.md: the guides, shipped in the wheel and printed by `mcp-dispatch guide`
34
+ tests/
35
+ trials/ the library's own kit: trials of its guides with assistants that have never seen it (trials/README.md)
36
+ ```
37
+
38
+ ## Rules
39
+
40
+ - **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
+ - **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
+ - **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
+ - **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 one dependency**, pydantic. `mcp` is an extra; import it inside the functions that need it.
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
+ - Code style: ruff (line length 88) and mypy clean. Test names are sentences that say what holds.
47
+ - Do not push, tag or change `.github/workflows/workflow.yml` (PyPI trusted publishing is bound to that file name) unless asked.
48
+
49
+ ## Not built
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, and a guide is named only when it shares two words with what was asked); skill search by meaning (a host's embedder); 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
+ ## What a host like precis needs that is not here
54
+
55
+ Read from the source of precis-mcp on 29 Nov 2026 (seven verbs over more than 50 kinds, more than 300 skills, plugins for handlers, job types, migrations, skills and commands) and tried against this library with a throwaway plugin. Its live server could not be reached, so nothing here was seen running there. What already carries over: an id that is a string, a number or a list of both; a dict argument, also sent as JSON text or from a shell; `dry_run` and `confirm` as plain arguments; an answer of any size.
56
+
57
+ In the order in which they would bite a port:
58
+
59
+ 1. **A call by kind and id, with no path.** precis is called as `get(kind='paper', id='pa12')`, and an id's two letters can name the kind, so `get(id='pa12')` works. Here every call names `<package>/<action>`; `kinds=` on an action is shown in help and checked by nobody.
60
+ 2. **One ranked search over several kinds.** precis takes `kind='paper,memory'` and `kind='*'` and merges the hits of every kind into one list. Here `t` is one kind and packages answer one after the other. Since today a `t` with a comma or `*` is refused with the calls to send; before, it went to whichever package takes any kind, as a kind of that odd name.
61
+ 3. **A plugin that is installed but cannot run here.** precis leaves out a kind whose key, setting or service is missing, or whose plugin was built for another contract, and tells the assistant which kinds are missing and why. Here any plugin that cannot be loaded stops the host, which is right for a broken plugin and wrong for a paid service nobody configured. Wanted: a plugin says what it needs, and a call to it answers "not available here" with the reason.
62
+ 4. **A host that only reads.** `precis serve --read-only` offers `get` and `search` alone. Here a host without `create` refuses to start with a plugin that has a `create` action. Wanted: a tool the host knows and does not offer.
63
+ 5. **An answer that is not text.** precis returns plots as image blocks beside the text. Here an action that returns anything but `str` is a `TypeError` (the result object under "Not built").
64
+ 6. **A refusal marked as an error.** precis answers a refused call with `isError: true` and the text; here it is text with `isError: false` (first point under "Known and open").
65
+ 7. **An answer that fits.** precis cuts an answer over 24 kB at a line, adds an outline of what was cut and names the call that reads the rest. Here an action's answer goes out whole.
66
+ 8. **Many skills.** `skill/list` prints every skill on one line each: fine for six, about 30 kB for the skills of precis, which is why precis stopped listing them. No tiers, no listing by package, and a long skill is returned whole.
67
+ 9. **A list of calls checked before the first runs.** precis checks every item of its batch of memory searches before it runs any. Here a malformed third call is refused after the first two ran.
68
+ 10. **Skills as MCP prompts and resources**, and resource templates for refs. Here the tools are the only way in.
69
+ 11. **A near miss that has one reading.** precis runs `view='full'` as the view it must mean and says so in the first line. Here a value that is not one of the fixed set is refused with the set: one way to do a thing, by rule.
70
+
71
+ The host's own, with the seam in place (`run`, `bound.tool.writes`, `bound.action.path`): who is calling and what their role may write, a ledger of calls, a retry of a call that met a lock, hints that are not refusals, jobs that run after the call returns.
72
+
73
+ ## Known and open
74
+
75
+ Found by the passes that wrote the tests (28 Nov 2026) and left as they are; none is pinned by a test as wanted behaviour.
76
+
77
+ - Over MCP an answer `[error:Code] ...` has `isError: false`: a client cannot tell a refusal from an answer. Reticula's trialled texts were measured that way; changing it is a trial of its own.
78
+ - The glue in `mcp_tools.register` reaches into a private part of the SDK (`mcp._tool_manager._tools`, a subclass of its `Tool`). Not checked against `mcp` 2.x.
79
+ - A skill's header is read by a small parser, not YAML: `title: x # note` keeps the comment, and `[a, 'b, c']` splits inside the quotes.
80
+ - An `Example:` written as a list of one call (`{"calls": [{...}]}`) passes the check and is printed in help that way.
81
+ - The skill search with `limit` 0 or below returns one guide; `best_skills(limit=0)` returns none.
82
+ - `Dispatch.first_read` sizes each schema without the example path a host may give `server`, so it is a few characters low.
83
+ - The guide says an action's arguments are keyword-only; `def go(self, call, thing: str)` registers all the same.
84
+ - 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 bar for a guide in a search that names no kind (two shared words, three guides at most) is a guess: it was set so that a search for notes does not bring a guide for every common word, and has been through no trial of its own.
86
+ - 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
+ - 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
+ - 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`.
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1 (29 Nov 2026)
4
+
5
+ The first release on PyPI.
6
+
7
+ - 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.
8
+ - The package passes `mypy --strict`, and the project's own mypy run holds it to that.
9
+
10
+ ## 0.1.0 (29 Nov 2026)
11
+
12
+ 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.
13
+
14
+ - Lifted out of Reticula (`reticula_mcp.dispatch`, 0.6.0 in development).
15
+ - 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.
16
+ - The search is a tool of its own, `search`, always there, and takes no path: `search {"q": "...", "t": "<kind>"}`.
17
+ - 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.
18
+ - `Dispatch`: a host in a few lines, with an initial message built from parts and limited in size.
19
+ - `mcp-dispatch guide`, `check`, `update`, `help`. The check never prints `ok` for a project in which no plugin was found.
20
+ - `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.
21
+ - 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.
22
+ - 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.
23
+ - `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.
24
+ - Licence: MIT.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Reto Stamm
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,86 @@
1
+ Metadata-Version: 2.5
2
+ Name: mcp-dispatch
3
+ Version: 0.1.1
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
+ Project-URL: Homepage, https://github.com/retospect/mcp-dispatch
6
+ Project-URL: Repository, https://github.com/retospect/mcp-dispatch
7
+ Project-URL: Issues, https://github.com/retospect/mcp-dispatch/issues
8
+ Author-email: Reto Stamm <reto@retostamm.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: mcp,mcp-server,model-context-protocol,plugins,skills,tools
12
+ Classifier: Development Status :: 2 - Pre-Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.12
19
+ Requires-Dist: pydantic>=2.7
20
+ Provides-Extra: mcp
21
+ Requires-Dist: mcp<2,>=1.30; extra == 'mcp'
22
+ Description-Content-Type: text/markdown
23
+
24
+ # mcp-dispatch
25
+
26
+ A small framework for MCP servers whose tools are used by language models.
27
+
28
+ An MCP server usually shows an assistant one tool per thing it can do. Every tool's name, description and schema is read in every conversation, so a server that can do much costs much before the first call, and a permission has to be given tool by tool.
29
+
30
+ mcp-dispatch shows five tools and keeps everything else behind them:
31
+
32
+ | Tool | What it is for |
33
+ |---|---|
34
+ | `get` | reads |
35
+ | `search` | finds things, and the how-to guides |
36
+ | `create` | adds or changes |
37
+ | `destroy` | removes for good |
38
+ | `share` | gives someone access |
39
+
40
+ A call names a path and its arguments: `create {"path": "shelf/add", "title": "Dune"}`. The paths come from plugins: Python classes whose tagged methods are the actions. What the assistant needs to know about an action is made from its signature and docstring and is fetched when it is needed (`"shelf/add?"`), as are the how-to guides a plugin ships (`search {"q": "lend a book", "t": "skill"}`).
41
+
42
+ What you get:
43
+
44
+ - **A small first read.** Five tool descriptions and a short first message, however many actions are installed.
45
+ - **One switch per risk.** A client that lets an assistant read without asking, and asks before it deletes or shares, needs four settings.
46
+ - **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.
48
+ - **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
+ - **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
+
51
+ ## Who writes against it
52
+
53
+ Assistants do. The guide is written for them and ships in the package:
54
+
55
+ ```
56
+ uv run mcp-dispatch guide # how to write a plugin
57
+ uv run mcp-dispatch guide host # how to set up a host
58
+ ```
59
+
60
+ If you work with an assistant, put this line into your project's `AGENTS.md`:
61
+
62
+ ```
63
+ This project builds on mcp-dispatch. Before you write or change a plugin, read `uv run mcp-dispatch guide`; before you finish, `uv run mcp-dispatch check` must print ok.
64
+ ```
65
+
66
+ ## A host in a few lines
67
+
68
+ ```python
69
+ from mcp_dispatch import SKILL_SEARCH, Dispatch
70
+
71
+ dispatch = Dispatch() # the standard tools and the search
72
+ dispatch.find_plugins() # every plugin that is installed
73
+ dispatch.add_initial_message("You keep the lab's bookshelf for its people.")
74
+ dispatch.add_initial_message(SKILL_SEARCH)
75
+ dispatch.server("bookshelf").run()
76
+ ```
77
+
78
+ Install with `pip install "mcp-dispatch[mcp]"` for a host, `pip install mcp-dispatch` for a plugin.
79
+
80
+ ## State
81
+
82
+ Pre-alpha. It was built inside [Reticula](https://github.com/retospect/reticula-mcp) and lifted out. The texts an assistant reads have been tried only as far as `trials/README.md` records.
83
+
84
+ ## Licence
85
+
86
+ MIT, see `LICENSE`. A plugin or a host that builds on mcp-dispatch may carry any licence.
@@ -0,0 +1,63 @@
1
+ # mcp-dispatch
2
+
3
+ A small framework for MCP servers whose tools are used by language models.
4
+
5
+ An MCP server usually shows an assistant one tool per thing it can do. Every tool's name, description and schema is read in every conversation, so a server that can do much costs much before the first call, and a permission has to be given tool by tool.
6
+
7
+ mcp-dispatch shows five tools and keeps everything else behind them:
8
+
9
+ | Tool | What it is for |
10
+ |---|---|
11
+ | `get` | reads |
12
+ | `search` | finds things, and the how-to guides |
13
+ | `create` | adds or changes |
14
+ | `destroy` | removes for good |
15
+ | `share` | gives someone access |
16
+
17
+ A call names a path and its arguments: `create {"path": "shelf/add", "title": "Dune"}`. The paths come from plugins: Python classes whose tagged methods are the actions. What the assistant needs to know about an action is made from its signature and docstring and is fetched when it is needed (`"shelf/add?"`), as are the how-to guides a plugin ships (`search {"q": "lend a book", "t": "skill"}`).
18
+
19
+ What you get:
20
+
21
+ - **A small first read.** Five tool descriptions and a short first message, however many actions are installed.
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
+ - **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
+ - **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
+ - **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
+ ## Who writes against it
29
+
30
+ Assistants do. The guide is written for them and ships in the package:
31
+
32
+ ```
33
+ uv run mcp-dispatch guide # how to write a plugin
34
+ uv run mcp-dispatch guide host # how to set up a host
35
+ ```
36
+
37
+ If you work with an assistant, put this line into your project's `AGENTS.md`:
38
+
39
+ ```
40
+ This project builds on mcp-dispatch. Before you write or change a plugin, read `uv run mcp-dispatch guide`; before you finish, `uv run mcp-dispatch check` must print ok.
41
+ ```
42
+
43
+ ## A host in a few lines
44
+
45
+ ```python
46
+ from mcp_dispatch import SKILL_SEARCH, Dispatch
47
+
48
+ dispatch = Dispatch() # the standard tools and the search
49
+ dispatch.find_plugins() # every plugin that is installed
50
+ dispatch.add_initial_message("You keep the lab's bookshelf for its people.")
51
+ dispatch.add_initial_message(SKILL_SEARCH)
52
+ dispatch.server("bookshelf").run()
53
+ ```
54
+
55
+ Install with `pip install "mcp-dispatch[mcp]"` for a host, `pip install mcp-dispatch` for a plugin.
56
+
57
+ ## State
58
+
59
+ Pre-alpha. It was built inside [Reticula](https://github.com/retospect/reticula-mcp) and lifted out. The texts an assistant reads have been tried only as far as `trials/README.md` records.
60
+
61
+ ## Licence
62
+
63
+ MIT, see `LICENSE`. A plugin or a host that builds on mcp-dispatch may carry any licence.
@@ -0,0 +1,108 @@
1
+ [build-system]
2
+ requires = ["hatchling==1.33.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "mcp-dispatch"
7
+ version = "0.1.1"
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
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Reto Stamm", email = "reto@retostamm.com" }]
14
+ keywords = ["mcp", "mcp-server", "model-context-protocol", "plugins", "tools", "skills"]
15
+ classifiers = [
16
+ "Development Status :: 2 - Pre-Alpha",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Intended Audience :: Developers",
21
+ "Topic :: Software Development :: Libraries :: Python Modules",
22
+ ]
23
+ # What a plugin needs: the checks of a call's arguments come from pydantic.
24
+ dependencies = ["pydantic>=2.7"]
25
+
26
+ [project.optional-dependencies]
27
+ # What a host needs to serve the tools over MCP (Dispatch.server, Dispatch.mount).
28
+ mcp = ["mcp>=1.30,<2"]
29
+
30
+ [project.scripts]
31
+ mcp-dispatch = "mcp_dispatch.cli:main"
32
+
33
+ [dependency-groups]
34
+ dev = [
35
+ "pytest>=8",
36
+ "pytest-timeout>=2.3",
37
+ "ruff>=0.8",
38
+ "mypy>=1.13",
39
+ "mcp>=1.30,<2",
40
+ ]
41
+
42
+ [project.urls]
43
+ Homepage = "https://github.com/retospect/mcp-dispatch"
44
+ Repository = "https://github.com/retospect/mcp-dispatch"
45
+ Issues = "https://github.com/retospect/mcp-dispatch/issues"
46
+
47
+ [tool.hatch.build.targets.wheel]
48
+ packages = ["src/mcp_dispatch"]
49
+
50
+ [tool.hatch.build.targets.sdist]
51
+ # the tests load the trial kit's template and reference answer
52
+ include = ["src", "tests", "trials", "README.md", "CHANGELOG.md", "AGENTS.md"]
53
+
54
+ [tool.ruff]
55
+ target-version = "py312"
56
+ line-length = 88
57
+ # what a trial hands to an assistant and what comes back is not this package's code
58
+ extend-exclude = ["trials/guide/template", "trials/guide/reference", "trials/runs"]
59
+
60
+ [tool.ruff.lint]
61
+ select = ["E", "F", "I", "UP", "B", "SIM", "RUF", "PLW1514", "D417"]
62
+ preview = true
63
+ explicit-preview-rules = true
64
+ ignore = [
65
+ "B008", "E501", "E741",
66
+ "RUF001", "RUF002", "RUF003", "RUF012",
67
+ "SIM102", "SIM103", "SIM105", "SIM108", "SIM110", "SIM117",
68
+ "B007", "B905", "B010", "RUF005",
69
+ ]
70
+
71
+ [tool.ruff.lint.per-file-ignores]
72
+ "tests/**" = ["B007", "D417", "E402", "F841", "RUF012", "RUF015", "RUF059"]
73
+ "src/**" = ["RUF059"]
74
+ # Published actions document the arguments an assistant sends, not the call
75
+ # context the dispatcher adds; the check (check.py) looks at them instead.
76
+ "src/mcp_dispatch/skills.py" = ["RUF059", "D417"]
77
+
78
+ [tool.ruff.format]
79
+ exclude = ["*.md"]
80
+
81
+ [tool.mypy]
82
+ python_version = "3.12"
83
+ check_untyped_defs = true
84
+ warn_unused_ignores = true
85
+ files = ["src", "tests"]
86
+
87
+ [[tool.mypy.overrides]]
88
+ # the package itself is held to what `mypy --strict` asks for
89
+ module = ["mcp_dispatch.*"]
90
+ disallow_untyped_calls = true
91
+ disallow_untyped_defs = true
92
+ disallow_incomplete_defs = true
93
+ disallow_untyped_decorators = true
94
+ disallow_any_generics = true
95
+ disallow_subclassing_any = true
96
+ warn_return_any = true
97
+ no_implicit_reexport = true
98
+ strict_equality = true
99
+ extra_checks = true
100
+
101
+ [[tool.mypy.overrides]]
102
+ # tests look into Optional results without ceremony
103
+ module = ["tests.*"]
104
+ disable_error_code = ["union-attr", "index", "arg-type"]
105
+
106
+ [tool.pytest.ini_options]
107
+ testpaths = ["tests"]
108
+ timeout = 60
@@ -0,0 +1,59 @@
1
+ """A few tools, paths behind them, plugins that publish actions and skills.
2
+
3
+ A plugin author needs :class:`Plugin`, :func:`action`, :func:`searches`, the
4
+ names of the tools and :class:`DispatchError`. A host needs :class:`Dispatch`.
5
+ An assistant that builds on this starts with the guide: ``mcp-dispatch guide``.
6
+ """
7
+
8
+ from mcp_dispatch.dispatch import INITIAL_LIMIT, SKILL_SEARCH, Dispatch
9
+ from mcp_dispatch.errors import BAD_INPUT, NOT_FOUND, DispatchError, PluginError
10
+ from mcp_dispatch.registry import (
11
+ GROUP,
12
+ Action,
13
+ Bound,
14
+ Help,
15
+ Registry,
16
+ build_registry,
17
+ )
18
+ from mcp_dispatch.skills import Skill
19
+ from mcp_dispatch.tags import (
20
+ CREATE,
21
+ DESTROY,
22
+ GET,
23
+ SEARCH,
24
+ SHARE,
25
+ Plugin,
26
+ Tool,
27
+ action,
28
+ searches,
29
+ standard_tools,
30
+ )
31
+
32
+ __version__ = "0.1.1"
33
+
34
+ __all__ = [
35
+ "BAD_INPUT",
36
+ "CREATE",
37
+ "DESTROY",
38
+ "GET",
39
+ "GROUP",
40
+ "INITIAL_LIMIT",
41
+ "NOT_FOUND",
42
+ "SEARCH",
43
+ "SHARE",
44
+ "SKILL_SEARCH",
45
+ "Action",
46
+ "Bound",
47
+ "Dispatch",
48
+ "DispatchError",
49
+ "Help",
50
+ "Plugin",
51
+ "PluginError",
52
+ "Registry",
53
+ "Skill",
54
+ "Tool",
55
+ "action",
56
+ "build_registry",
57
+ "searches",
58
+ "standard_tools",
59
+ ]
@@ -0,0 +1,3 @@
1
+ from mcp_dispatch.cli import main
2
+
3
+ raise SystemExit(main())
@@ -0,0 +1,102 @@
1
+ # Set up a host for mcp-dispatch
2
+
3
+ A host is the program an assistant connects to. It names the tools, finds the plugins, says what an assistant is told first, and serves. The plugins do the rest (`mcp-dispatch guide`).
4
+
5
+ ```python
6
+ # src/my_package/host.py
7
+ from mcp_dispatch import SKILL_SEARCH, Dispatch
8
+
9
+
10
+ def dispatch() -> Dispatch:
11
+ d = Dispatch() # the standard tools and the search
12
+ d.find_plugins() # every plugin installed under "mcp_dispatch.plugins"
13
+ d.add_initial_message("You keep the lab's bookshelf for its people.")
14
+ d.add_initial_message(SKILL_SEARCH)
15
+ return d
16
+
17
+
18
+ if __name__ == "__main__":
19
+ dispatch().server("bookshelf").run()
20
+ ```
21
+
22
+ ```toml
23
+ # pyproject.toml
24
+ [project]
25
+ dependencies = ["mcp-dispatch[mcp]"]
26
+
27
+ [tool.mcp-dispatch]
28
+ host = "my_package.host:dispatch" # so that check, update and help look at this host
29
+ ```
30
+
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"`.
32
+
33
+ ## The tools
34
+
35
+ `Dispatch()` has the standard set, one tool per kind of change, so that a client's permission per tool is a switch per risk: `get` reads, `create` writes, `destroy` removes for good, `share` gives access. The `search` tool is always there and is not listed by the host.
36
+
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
+ - Your own words for the search: `Dispatch(search="Search the books. ...")`.
39
+ - 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
+ ## The plugins
42
+
43
+ `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.
44
+
45
+ ## What an assistant is told first
46
+
47
+ The initial message, the tools' descriptions and their schemas are read in every conversation, before the first call. Keep them small; `mcp-dispatch check` prints their size.
48
+
49
+ - `add_initial_message(text)` adds a part; the parts are joined in the order added. The whole has a limit of 2000 characters (`Dispatch(initial_limit=...)`).
50
+ - Say who the assistant works for, what the first call is if there is one, and how to find out more. `SKILL_SEARCH` is the line for the last: it names the search for how-to guides.
51
+ - A skill that every conversation needs: `add_initial_message(d.skill("lend-a-book"))`. One or two at most; every other skill is found when it is needed.
52
+ - What depends on who is calling (their own notes, the one or two skills that fit their role) cannot be in the initial message: a server has one. Put it in the answer of an action, and name that action in the initial message as the first call. Such an action can pick skills with `self.registry.best_skills("<what this caller does>", limit=2)`.
53
+ - If one call has to come first, say so in the search's description as well: `Dispatch(search="Search the books, after the start call has begun the conversation. ...")`, with the start call written out as your first message writes it. A tool called `search` is an obvious first call. On a host whose first message named its start call, conversations that began with one plain request began with the search in a third of the cases, and in none once the search's description said what comes before it.
54
+ - Every part here is a text an assistant acts on. Change one at a time and try the change with a real assistant before you ship it: `mcp_dispatch.trials.run_session` runs one that has your server's tools and nothing else, and reads what it called from the transcript.
55
+
56
+ ## What an action gets as `call`
57
+
58
+ `server(name, call=make)` calls `make(ctx)` for every call and passes the result to the action as its first argument; `ctx` is the MCP context of the request. Left out, actions get `None`.
59
+
60
+ ```python
61
+ store = Store("books.db")
62
+ dispatch().server("bookshelf", call=lambda ctx: store).run()
63
+ ```
64
+
65
+ The server runs each call in a worker thread. An action's `DispatchError` reaches the assistant as `[error:Code] message` with a `hint:` line; any other exception is logged and answered as `[error:Internal]` without details.
66
+
67
+ ## A server of your own
68
+
69
+ A host with its own sign-in, transactions or limits builds its FastMCP server itself and mounts the tools:
70
+
71
+ ```python
72
+ mcp = FastMCP("notes", instructions=d.initial_message) # and your own sign-in, routes, settings
73
+
74
+ async def run(ctx, bound):
75
+ # one call: open the transaction (bound.tool.writes says of which kind),
76
+ # build what the actions get as `call`, run, commit or roll back
77
+ return await in_a_transaction(ctx, lambda call: bound.run(call))
78
+
79
+ d.mount(mcp, run)
80
+ ```
81
+
82
+ `bound.action.path` names the call for a log; `bound.params` are its checked arguments. Let an action's `DispatchError` pass through `run`, so that your transaction rolls back: it reaches the assistant as `[error:Code] message` all the same. Any other exception is yours to log and to answer.
83
+
84
+ ## From a command line
85
+
86
+ Every action can be called without a client, with the same tool, path and arguments:
87
+
88
+ ```
89
+ uv run mcp-dispatch call create shelf/add title=Dune author="Frank Herbert"
90
+ uv run mcp-dispatch call search q=herbert t=book
91
+ uv run mcp-dispatch call create '{"path": "shelf/add", "title": "Dune"}'
92
+ ```
93
+
94
+ A value is passed as its text and read by the action's type hints. What the actions get as `call` there is what a function of yours returns, named in the same table: `call = "my_package.host:store"`. It is called once for each call that is made. If it returns a context manager, that is entered for the one call and left after it: open a transaction there, commit it when the block ends, and roll it back when it ends with an exception, which is how a refused call leaves it. The command returns 0 when the call went well and 1 when it was refused.
95
+
96
+ ## Check
97
+
98
+ ```
99
+ uv run mcp-dispatch check
100
+ ```
101
+
102
+ With `[tool.mcp-dispatch] host = ...` it checks this host: every plugin's docstrings, skills and index, and the size of the initial message. `contract = "tests/contract.json"` in the same table pins the paths and their arguments in a file: the check fails when they differ, and `uv run mcp-dispatch update` writes the file again after a change that is meant.