laya-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- laya_mcp-0.1.0/LICENSE +202 -0
- laya_mcp-0.1.0/PKG-INFO +258 -0
- laya_mcp-0.1.0/README.md +224 -0
- laya_mcp-0.1.0/pyproject.toml +68 -0
- laya_mcp-0.1.0/setup.cfg +4 -0
- laya_mcp-0.1.0/src/laya_mcp/__init__.py +105 -0
- laya_mcp-0.1.0/src/laya_mcp/__main__.py +25 -0
- laya_mcp-0.1.0/src/laya_mcp/calibration.py +504 -0
- laya_mcp-0.1.0/src/laya_mcp/capability.py +302 -0
- laya_mcp-0.1.0/src/laya_mcp/cli.py +355 -0
- laya_mcp-0.1.0/src/laya_mcp/errors.py +409 -0
- laya_mcp-0.1.0/src/laya_mcp/harnesses.py +727 -0
- laya_mcp-0.1.0/src/laya_mcp/mcp_server.py +475 -0
- laya_mcp-0.1.0/src/laya_mcp/planning.py +472 -0
- laya_mcp-0.1.0/src/laya_mcp/protocol.py +280 -0
- laya_mcp-0.1.0/src/laya_mcp/py.typed +0 -0
- laya_mcp-0.1.0/src/laya_mcp/server.py +366 -0
- laya_mcp-0.1.0/src/laya_mcp/validate.py +277 -0
- laya_mcp-0.1.0/src/laya_mcp/worker.py +694 -0
- laya_mcp-0.1.0/src/laya_mcp.egg-info/PKG-INFO +258 -0
- laya_mcp-0.1.0/src/laya_mcp.egg-info/SOURCES.txt +23 -0
- laya_mcp-0.1.0/src/laya_mcp.egg-info/dependency_links.txt +1 -0
- laya_mcp-0.1.0/src/laya_mcp.egg-info/entry_points.txt +2 -0
- laya_mcp-0.1.0/src/laya_mcp.egg-info/requires.txt +15 -0
- laya_mcp-0.1.0/src/laya_mcp.egg-info/top_level.txt +1 -0
laya_mcp-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
laya_mcp-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: laya-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server for Laya typed decisions: a warm model sidecar, token-budget preflight, a persisted calibration store, and honest confidence.
|
|
5
|
+
Author: PerryLink
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/PerryLink/laya-mcp
|
|
8
|
+
Project-URL: Repository, https://github.com/PerryLink/laya-mcp
|
|
9
|
+
Project-URL: Issues, https://github.com/PerryLink/laya-mcp/issues
|
|
10
|
+
Keywords: laya,mcp,mcp-server,decision-model,system-one,calibration,typed-decisions
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: laya<0.4,>=0.3.4
|
|
22
|
+
Provides-Extra: server
|
|
23
|
+
Requires-Dist: fastapi>=0.110; extra == "server"
|
|
24
|
+
Requires-Dist: uvicorn>=0.27; extra == "server"
|
|
25
|
+
Provides-Extra: mcp
|
|
26
|
+
Requires-Dist: mcp<2,>=1.28; extra == "mcp"
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
29
|
+
Requires-Dist: httpx>=0.27; extra == "dev"
|
|
30
|
+
Requires-Dist: pyyaml>=6; extra == "dev"
|
|
31
|
+
Requires-Dist: twine>=5; extra == "dev"
|
|
32
|
+
Requires-Dist: build>=1; extra == "dev"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# laya-mcp
|
|
36
|
+
|
|
37
|
+
[Laya](https://github.com/NandhaKishorM/laya) is a fast, non-autoregressive
|
|
38
|
+
"System 1" decision model: it answers typed questions — `noul` (yes/no),
|
|
39
|
+
`choice`, `score` — over a piece of state and returns probabilities, in a single
|
|
40
|
+
forward pass. It is genuinely good, and it is a research artifact.
|
|
41
|
+
|
|
42
|
+
This is the part that makes it survive contact with a server.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install 'laya-mcp[mcp]'
|
|
46
|
+
laya-mcp serve # loads the model once, keeps it warm on 127.0.0.1:8787
|
|
47
|
+
laya-mcp install # registers it with whichever agent harness you have
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
> **Status: 0.1.0, work in progress.** The core is implemented and its pure logic
|
|
51
|
+
> is covered by 66 checks, but it has not yet been exercised end-to-end against a
|
|
52
|
+
> live harness in CI. Interfaces may move before 1.0.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## The problem this solves
|
|
57
|
+
|
|
58
|
+
Laya truncates things silently, and the omissions are the kind you only notice
|
|
59
|
+
after acting on a wrong answer.
|
|
60
|
+
|
|
61
|
+
**It cuts the state, from the end, and says nothing.** `build_sequence` gives the
|
|
62
|
+
state whatever room is left after the options and slices it `st[:room]`. A long
|
|
63
|
+
document loses its tail — which for a contract, a log or an email thread is often
|
|
64
|
+
where the answer was — and the model then answers about the surviving prefix at
|
|
65
|
+
full confidence. Nothing in the response marks it.
|
|
66
|
+
|
|
67
|
+
**It shortens options until labels are indistinguishable.** Options share a fixed
|
|
68
|
+
`head_max_len` budget (192 tokens on the English checkpoint, 256 on the others).
|
|
69
|
+
Past a point every label gets ~4 tokens. This is the documented cause of the
|
|
70
|
+
Banking77 collapse (0.425 against Jev's 0.870), and again, nothing reports it.
|
|
71
|
+
|
|
72
|
+
**Its validation is one check.** An unknown `type` is a bare `KeyError` from
|
|
73
|
+
`QTYPES[q["t"]]`; a missing `criteria` is a bare `KeyError` too. They are
|
|
74
|
+
indistinguishable from a bug in the model, and neither names the question at
|
|
75
|
+
fault.
|
|
76
|
+
|
|
77
|
+
**Its `confidence` is not accuracy.** It is `1 - H(p)/log(k)` for `choice` and
|
|
78
|
+
`score` and `max(p, 1-p)` for `noul`. A normalised entropy is *low* when
|
|
79
|
+
probability is spread out even when the top option is right, and *high* on a
|
|
80
|
+
confident wrong answer — the English checkpoint scores 0.000 accuracy on Khmer at
|
|
81
|
+
0.952 confidence. A threshold on it does not mean what it looks like.
|
|
82
|
+
|
|
83
|
+
**And it demotes itself to CPU in silence.** On a CUDA OOM it moves the model to
|
|
84
|
+
CPU in fp32, in place, permanently, printing to stdout. No flag is set anywhere.
|
|
85
|
+
A process that hits this once keeps answering, roughly 10–15x slower, and nothing
|
|
86
|
+
in the response admits it.
|
|
87
|
+
|
|
88
|
+
So this package adds what is missing: a **preflight** that says what would be
|
|
89
|
+
cut, **structured errors** naming the question, an **honest confidence contract**,
|
|
90
|
+
and a **health surface** that reports a demotion.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## What it does
|
|
95
|
+
|
|
96
|
+
| | |
|
|
97
|
+
|---|---|
|
|
98
|
+
| **Warm sidecar** | One `Router`, preloaded, for the life of the process. Laya's default (`max_loaded=1`) rebuilds a model on every language switch — measured upstream at a 7.4 s median reload on CPU, 10.3 s on a T4. |
|
|
99
|
+
| **Token-budget preflight** | `laya_plan` reports exactly what would be truncated, and how many tokens each option actually gets, **without running the model**. The option arithmetic reproduces `build_sequence` line for line. |
|
|
100
|
+
| **Structured errors** | Every Laya failure becomes a code, an HTTP status, the offending question id, and a hint. `KeyError('ranking')` becomes `invalid_question` naming the type. |
|
|
101
|
+
| **Honest confidence** | `confidence` is labelled for what it is, on every response. `noul` answers also carry a `no` / `uncertain` / `yes` band, because a calibrated probability is not a decision. |
|
|
102
|
+
| **Calibration store** | Fit a temperature per `(primitive, option bucket)` against your own labels, persist it, reload it. `laya-multilingual` ships **no** fitted temperatures at all, so its probabilities are raw until you do this. |
|
|
103
|
+
| **Device honesty** | Reports a silent CPU demotion, and `doctor` proves the GPU works by running a real op rather than trusting `torch.cuda.is_available()`. |
|
|
104
|
+
| **Serialised inference** | A lock, by default. Laya is not thread-safe: `system_one` reassigns `self.device` and calls `self.model.to(...)` on an OOM, so concurrent calls can race a device move against a forward pass. |
|
|
105
|
+
| **Restartable** | `DELETE /model` releases the model and empties the CUDA allocator cache, which `Router.unload` does not. A model server that leaks needs to be recyclable. |
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## One installer, five harnesses
|
|
110
|
+
|
|
111
|
+
There is no portable way to register an MCP server. Measured against real
|
|
112
|
+
installed harnesses, they disagree on the file, the format, and the key:
|
|
113
|
+
|
|
114
|
+
| harness | config | format | key |
|
|
115
|
+
|---|---|---|---|
|
|
116
|
+
| Claude Code | `~/.claude.json` | JSON | `mcpServers` |
|
|
117
|
+
| Codex | `~/.codex/config.toml` | TOML | `[mcp_servers.<name>]` |
|
|
118
|
+
| opencode | `~/.config/opencode/opencode.json[c]` | JSON | `mcp` |
|
|
119
|
+
| OpenClaw | `~/.openclaw/openclaw.json` | JSON | `mcp.servers` |
|
|
120
|
+
| Hermes | `~/.hermes/config.yaml` | YAML | `mcp_servers` |
|
|
121
|
+
|
|
122
|
+
`laya-mcp install` detects which are present and writes the right shape to each.
|
|
123
|
+
Every writer merges rather than replaces, backs the file up first, and refuses to
|
|
124
|
+
touch a file it cannot parse — `~/.claude.json` is a large shared file holding
|
|
125
|
+
history and per-project state, and clobbering it to install a decision model
|
|
126
|
+
would be a catastrophic trade.
|
|
127
|
+
|
|
128
|
+
Two honest limitations:
|
|
129
|
+
|
|
130
|
+
* **opencode differs from everyone three more times** inside its own entry:
|
|
131
|
+
`command` is a single array holding the executable *and* its arguments, the
|
|
132
|
+
environment key is `environment`, not `env`, and the toggle is `enabled`.
|
|
133
|
+
Setting `disabled: true` there is silently ignored.
|
|
134
|
+
* **`pi` is not supported.** Not an oversight: `pi` has no native MCP support.
|
|
135
|
+
Its settings reference contains no MCP key, and its own upstream request for MCP
|
|
136
|
+
is titled *"Add MCP extension example"* — in `pi`, MCP is an extension you
|
|
137
|
+
build. There is no config file an installer can write. `install` detects it and
|
|
138
|
+
says so.
|
|
139
|
+
|
|
140
|
+
`install` points the harness at `python -m laya_mcp mcp` rather than at the
|
|
141
|
+
`laya-mcp` console script, deliberately: on Windows a console script is a `.cmd`
|
|
142
|
+
shim and the MCP SDK spawns with `shell: false`, which cannot execute it.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Tools
|
|
147
|
+
|
|
148
|
+
| tool | what it answers |
|
|
149
|
+
|---|---|
|
|
150
|
+
| `laya_ask` | A batch of typed questions over one state. The general one. |
|
|
151
|
+
| `laya_noul` | One yes/no question. Returns `P(true)` and a band. |
|
|
152
|
+
| `laya_choice` | One multiple-choice question. Returns the label and the distribution. |
|
|
153
|
+
| `laya_score` | One ordered-scale question. |
|
|
154
|
+
| `laya_plan` | "Will this fit, and what will be cut?" — no forward pass. |
|
|
155
|
+
|
|
156
|
+
Every description says what the tool is *not* for. A decision model asked to write
|
|
157
|
+
prose produces nothing useful, and an agent that does not know that will keep
|
|
158
|
+
trying.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## HTTP
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
laya-mcp serve --model english --port 8787
|
|
166
|
+
curl -s localhost:8787/health
|
|
167
|
+
curl -s localhost:8787/ask -H 'content-type: application/json' -d '{
|
|
168
|
+
"state": {"subject": "Duplicate charge", "body": "Billed twice. Refund or we cancel."},
|
|
169
|
+
"questions": {
|
|
170
|
+
"churn": {"type": "noul", "instructions": "Does the user threaten to cancel?"},
|
|
171
|
+
"team": {"type": "choice", "instructions": "Which team?",
|
|
172
|
+
"criteria": {"billing": "invoices, refunds", "tech": "bugs, outages"}}
|
|
173
|
+
}
|
|
174
|
+
}'
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`GET /health`, `GET /capabilities`, `GET /version`, `POST /ask`, `POST /plan`,
|
|
178
|
+
`DELETE /model`. Loopback only by default; binding elsewhere warns loudly, because
|
|
179
|
+
there is no authentication.
|
|
180
|
+
|
|
181
|
+
`POST /plan` takes the same body as `/ask` and returns the same `budget` block
|
|
182
|
+
`/ask` reports, computed by the same `plan_questions` call — without a forward
|
|
183
|
+
pass. It is how a client can ask "will this be cut?" before paying for an answer.
|
|
184
|
+
On a cold host it pays a model *load*, which is not the same thing as an
|
|
185
|
+
inference.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Configuration worth knowing
|
|
190
|
+
|
|
191
|
+
| flag | why |
|
|
192
|
+
|---|---|
|
|
193
|
+
| `--head-max-len` | Raised at startup, this is the fix for high-cardinality `choice`. Options share it, so more room per label is the only way to keep them distinguishable. Read fresh on every call, so setting it once is enough. |
|
|
194
|
+
| `--max-len` | The total budget. Raising it is the fix for a truncated state. |
|
|
195
|
+
| `--concurrency` | Raise only if you know Laya is not sharing device state. The default of 1 is correctness, not caution. |
|
|
196
|
+
| `--sidecar` | Point `laya-mcp mcp` at a running `serve`. Strongly recommended: a harness spawns one stdio server per session, and hosting the model in each one pays the load cost per session. |
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## What this does not fix
|
|
201
|
+
|
|
202
|
+
Upstream's own numbers are worth repeating, because an integration layer that
|
|
203
|
+
implies otherwise is lying to you.
|
|
204
|
+
|
|
205
|
+
* **The base checkpoints are near chance zero-shot on typed decisions** — 0.362
|
|
206
|
+
for English against a **0.461 majority-class baseline**. Guessing the most
|
|
207
|
+
common answer beats the model.
|
|
208
|
+
* **`score` is the weakest primitive.** Independently measured at 35% against
|
|
209
|
+
Jev's 70% on a five-level ordinal task.
|
|
210
|
+
* **Calibration needs labelled data.** Raw ECE is 0.466 for English and 0.314 for
|
|
211
|
+
multilingual, improving to 0.081 and 0.106 after fitting. A temperature cannot
|
|
212
|
+
be invented; this package will not pretend to.
|
|
213
|
+
* **Position bias is real.** One published fixture run answered "A" on 46 of 50
|
|
214
|
+
multiple-choice items.
|
|
215
|
+
* **Accuracy falls off above ~20 options**, per the author.
|
|
216
|
+
|
|
217
|
+
Calibration makes a probability *honest*; it cannot make a model *right*. If the
|
|
218
|
+
accuracy is not there for your task, fit on your own domain or do not deploy it.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Verify
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
python tests/smoke_pure.py # 66 checks: validation, planning, calibration, errors
|
|
226
|
+
python tests/install_harnesses.py # 35 checks: every harness dialect, in a temp dir
|
|
227
|
+
python tests/mcp_protocol.py # 25 checks: a real MCP handshake and real tool calls
|
|
228
|
+
laya-mcp doctor # what is installed, and what the GPU can really do
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
126 checks, and each suite covers a layer the others cannot reach.
|
|
232
|
+
|
|
233
|
+
`smoke_pure.py` needs no torch, model, network or harness config. `install_harnesses.py`
|
|
234
|
+
redirects every harness into a temporary directory, because `~/.claude.json` is a
|
|
235
|
+
large shared file holding history and per-project state and a test that clobbered
|
|
236
|
+
it would be a worse bug than any it could catch.
|
|
237
|
+
|
|
238
|
+
`mcp_protocol.py` is the one that matters most and the one that was missing
|
|
239
|
+
longest. It spawns the server exactly as a harness does
|
|
240
|
+
(`python -m laya_mcp mcp`), performs the real `initialize` handshake with the
|
|
241
|
+
official SDK, lists tools, and calls them through the sidecar to the model. Two
|
|
242
|
+
real defects escaped the other suites and were caught only here: `FastMCP` in
|
|
243
|
+
mcp 1.30 takes no `version` argument, so the server failed to start at all; and
|
|
244
|
+
the token-budget warning was written into the DSH plugin's tool description but
|
|
245
|
+
never into this server's, so a client using MCP could not have known that an
|
|
246
|
+
oversized state is cut from the end.
|
|
247
|
+
|
|
248
|
+
The harness dialects were additionally verified by letting the harnesses parse
|
|
249
|
+
the files this tool writes: `codex mcp list --json` and `openclaw mcp list --json`
|
|
250
|
+
both report the registered server with the correct stdio transport. For the other
|
|
251
|
+
three the format is verified but harness acceptance is not, which is stated rather
|
|
252
|
+
than implied — `pi` has no MCP support at all, and this machine's Hermes runtime is
|
|
253
|
+
incomplete.
|
|
254
|
+
|
|
255
|
+
## Licence
|
|
256
|
+
|
|
257
|
+
Apache-2.0. Laya is Apache-2.0, by Convai Innovations. This is an independent
|
|
258
|
+
integration and is not affiliated with or endorsed by that project.
|