asm-protocol 0.5.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Caleb (yi guo)
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,395 @@
1
+ Metadata-Version: 2.4
2
+ Name: asm-protocol
3
+ Version: 0.5.0
4
+ Summary: Agent Service Manifest: value metadata and scoring for autonomous service selection
5
+ Author: Yi Guo
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: jsonschema>=4.0
11
+ Provides-Extra: mcp
12
+ Requires-Dist: mcp>=1.2; extra == "mcp"
13
+ Provides-Extra: langchain
14
+ Requires-Dist: langchain-core>=0.3; extra == "langchain"
15
+ Dynamic: license-file
16
+
17
+ # Agent Service Manifest (ASM)
18
+
19
+ **MCP tells agents what services can do. ASM tells agents what services are worth.**
20
+
21
+ ASM is the value-metadata layer for **agent tool selection**. When an agent carries out a task for a human, it faces many candidate tools — GUI apps, CLIs, and APIs; free and paid; cloud and local-only. ASM gives it the structured metadata to quickly pick one it *can actually drive*, is *allowed* to use, and that *fits the task* — then rank the survivors on cost, quality, latency, and data terms.
22
+
23
+ It is **not** a model picker. The tools are real products — task managers, design apps, data tools, schedulers — anything an agent might invoke on a user's behalf.
24
+
25
+ ## Try it: pick a tool for a task
26
+
27
+ ```bash
28
+ git clone https://github.com/calebguo007/asm-spec.git && cd asm-spec
29
+ python library/select_demo.py
30
+ ```
31
+
32
+ For *"make a study plan and remind me daily"* with a cloud agent on Windows, the selector drops the tools it can't drive (Apple Reminders, Things 3 — local-device only) and the ones it can't call directly (Any.do — Zapier only), then ranks the rest. Ask for a built-in pomodoro and the pick changes to TickTick. Ask to *"edit an image and lay out a poster"* and it picks free, scriptable **Photopea** over paid Photoshop — and filters **Affinity Designer**, which exposes no automation API at all.
33
+
34
+ The library it selects over is in [`library/`](library/) — 26 real tools across task management, creative design, research, communication, developer tools, and booking/travel today, each carrying:
35
+
36
+ - **invocation** — can an agent drive it, and from where (cloud API / local script / GUI-only)
37
+ - **pricing**, **quality**, **sla**, **payment**
38
+ - **usage_terms** — whether automated use is even permitted
39
+ - **data_governance** — ownership, export, whether it trains on your data
40
+
41
+ Entries are schema-validated and source-linked; unverified dimensions are marked, not faked.
42
+
43
+ June 2026 coverage update: the tool-selection library now includes 26 source-linked tools across task management, creative design, research, communication, developer tools, and booking/travel. Booking and messaging entries deliberately expose `operational_constraints` so agents can separate read-only search from approval-gated actions such as sending messages, creating PRs, or purchasing flights.
44
+
45
+ Productization/distribution plan: [`docs/productization-distribution.md`](docs/productization-distribution.md).
46
+
47
+ Coverage report and remaining unknowns: [`docs/library-coverage-report.md`](docs/library-coverage-report.md).
48
+
49
+ ## The gap ASM fills
50
+
51
+ The discovery layer is crowded — MCP / Server Cards, Zapier (8000+ apps), Composio (850+) all tell an agent *how to connect* to a tool. None tells it *which of several to pick*. We audited 14,519 entries across five MCP registries/directories: **0** expose pricing + SLA + quality + payment together in machine-actionable form. ASM is that missing value/selection layer — and it rides on top of the connection layers, not against them.
52
+
53
+ ASM is MCP-compatible: publish a standalone `.well-known/asm`, or embed ASM in MCP Registry `server.json` under `_meta.io.modelcontextprotocol.registry/publisher-provided.asm`. Convention: inline blocks carry *static* facts; *mutable* value data (pricing/SLA/quality) should live behind `asm_url` so freshness has a single re-stampable source — guidance hardened by a production multi-server host (see [`docs/integrations/mcp-registry.md`](docs/integrations/mcp-registry.md)).
54
+
55
+ ## Use it from an agent (MCP server)
56
+
57
+ ASM ships an MCP server so any MCP client (Claude Desktop, Cursor, an agent host) can call the selector as a tool — no schema adoption required:
58
+
59
+ ```bash
60
+ git clone https://github.com/calebguo007/asm-spec && cd asm-spec
61
+ pip install mcp
62
+ python asm_selector_mcp.py # stdio MCP server
63
+ ```
64
+
65
+ It exposes three tools: **`select_tool`** (pick a tool for a task and return its risk/approval policy), **`list_library_tools`**, and **`get_tool_manifest`**. Point your client's MCP config at `python /path/to/asm-spec/asm_selector_mcp.py`; the selector reads `library/` (override with `ASM_LIBRARY_DIR`). The same selector is importable directly: `from library_select import select`.
66
+
67
+ The same engine is also available as:
68
+
69
+ ```bash
70
+ # CLI (human or scripted)
71
+ asm select "find and book a refundable flight" --taxonomy tool.booking.travel \
72
+ --requires flight_search,flight_order_create --json
73
+
74
+ # Hosted HTTP API (stdlib-only; deploy anywhere that runs Python)
75
+ python asm_select_api.py # POST /select, GET /tools, GET /healthz on :8787
76
+ ```
77
+
78
+ LangChain / LangGraph builders get the same selector as a drop-in tool (`pip install langchain-core`):
79
+
80
+ ```python
81
+ import sys; sys.path += ["asm-spec", "asm-spec/integrations/langchain"]
82
+ from asm_tools import ASMToolSelectorTool
83
+ agent_tools = [ASMToolSelectorTool()] # name: asm_tool_selector
84
+ ```
85
+
86
+ A public instance runs at **https://asm-spec.onrender.com** (free tier — first request after idle may take ~50s to wake):
87
+
88
+ ```bash
89
+ curl -X POST https://asm-spec.onrender.com/select -H "Content-Type: application/json" \
90
+ -d '{"task":"find and book a refundable flight","taxonomy":"tool.booking.travel",
91
+ "required_functions":["flight_search","flight_order_create"],
92
+ "require_approval_for":["financial_charge"]}'
93
+ # -> {"selected": {"display_name": "Amadeus Self-Service APIs", ...},
94
+ # "risk_class": "critical", "approval_required": true, ...}
95
+ ```
96
+
97
+ ## One slice: ranking AI services (OpenRouter)
98
+
99
+ The same engine works for the AI-service taxonomy. No clone, no install (needs [uv](https://docs.astral.sh/uv/)):
100
+
101
+ ```bash
102
+ uvx --from git+https://github.com/calebguo007/asm-spec.git \
103
+ asm openrouter 'best value coding model under $3 per 1M tokens'
104
+ ```
105
+
106
+ It builds ephemeral ASM manifests from OpenRouter's live model metadata, scores them on price vs. quality (LMArena Elo), and can emit a router config (LiteLLM / Vercel AI SDK / LangChain). Model routing is the easiest slice to demo — one taxonomy among many, not the point.
107
+
108
+ ![ASM OpenRouter CLI demo](docs/assets/asm-openrouter-demo.gif)
109
+
110
+ Latest paper signals:
111
+
112
+ - 0/50 MCP-related GitHub repos and 0/14,519 registry/directory entries expose complete value metadata.
113
+ - 75 source-linked manifests across 47 taxonomies validate against `schema/asm-v0.3.schema.json`.
114
+ - Raw-doc LLM selection reaches 63.9-72.2% top-1 accuracy; ASM-manifest selection reaches 100.0%.
115
+ - Live execution shows ASM works only when quality metrics are semantically comparable; mixed benchmark scales are a real failure mode.
116
+ - External Arena/OpenRouter analysis is reported as a stress test, not a claim that any quality metric is universally correct.
117
+
118
+ Long-form results: [`docs/paper-results.md`](docs/paper-results.md). Reproducibility map: [`ARTIFACT.md`](ARTIFACT.md).
119
+
120
+ ---
121
+
122
+ ## Try ASM in 60 Seconds
123
+
124
+ ```bash
125
+ git clone https://github.com/calebguo007/asm-spec.git
126
+ cd asm-spec
127
+ pip install -e .
128
+ asm openrouter 'cheap coding model under $0.50 per 1M tokens'
129
+ ```
130
+
131
+ Example output shape:
132
+
133
+ ```text
134
+ Selected: MoonshotAI: Kimi K2.6 (free)
135
+ Model: moonshotai/kimi-k2.6:free
136
+ Reason: MoonshotAI: Kimi K2.6 scored 1.000 via TOPSIS...
137
+
138
+ Ranked services:
139
+ 1. MoonshotAI: Kimi K2.6 (free) (...)
140
+ 2. Tencent: Hy3 preview (...)
141
+ 3. StepFun: Step 3.5 Flash (...)
142
+
143
+ Rejected by hard constraints: none
144
+ ```
145
+
146
+ Emit a LiteLLM router snippet:
147
+
148
+ ```bash
149
+ asm openrouter route --format litellm 'cheap coding model under $0.50 per 1M tokens'
150
+ ```
151
+
152
+ Other export formats:
153
+
154
+ ```bash
155
+ asm openrouter --format json 'best value model for long-context summarization'
156
+ asm openrouter route --format vercel-ai-sdk 'high quality reasoning model'
157
+ asm openrouter route --format langchain 'cheap reliable chat model'
158
+ ```
159
+
160
+ OpenRouter value-router notes: [`docs/openrouter-value-router.md`](docs/openrouter-value-router.md).
161
+
162
+ Local manifest demo:
163
+
164
+ ```bash
165
+ asm score "cheap reliable TTS under 1s"
166
+ ```
167
+
168
+ Validate an MCP `server.json` with embedded ASM:
169
+
170
+ ```bash
171
+ asm-mcp-validate examples/mcp-server-json/remote-with-asm.server.json
172
+ ```
173
+
174
+ Validate a draft v0.4 pre-call operational envelope:
175
+
176
+ ```bash
177
+ asm-mcp-validate examples/mcp-server-json/operational-envelope-with-asm.server.json
178
+ ```
179
+
180
+ If the console script is not on `PATH`, use:
181
+
182
+ ```bash
183
+ python -m mcp_server_json_asm examples/mcp-server-json/remote-with-asm.server.json
184
+ ```
185
+
186
+ Try OpenRouter live model ranking:
187
+
188
+ ```bash
189
+ asm openrouter 'cheap LLM under $1 per 1M tokens under 1s'
190
+ ```
191
+
192
+ This builds ephemeral ASM manifests from OpenRouter's public `/api/v1/models`
193
+ metadata and merges the checked-in OpenRouter usage-ranking snapshot as a
194
+ revealed-preference signal. OpenRouter does not expose per-model latency in
195
+ that endpoint, so ASM reports and ignores latency hard constraints for this
196
+ source unless `--strict-latency` is set.
197
+
198
+ Extract the embedded ASM manifest:
199
+
200
+ ```bash
201
+ asm-mcp-validate examples/mcp-server-json/remote-with-asm.server.json \
202
+ --write-out /tmp/remote-search.asm.json
203
+ ```
204
+
205
+ ---
206
+
207
+ ## Add ASM to Your MCP Server
208
+
209
+ ### Option 1: publish `.well-known/asm`
210
+
211
+ Serve a normal ASM manifest:
212
+
213
+ ```text
214
+ https://your-service.example/.well-known/asm
215
+ ```
216
+
217
+ ### Option 2: embed ASM in MCP Registry `server.json`
218
+
219
+ ```json
220
+ {
221
+ "name": "io.example/search",
222
+ "description": "Search MCP server",
223
+ "_meta": {
224
+ "io.modelcontextprotocol.registry/publisher-provided": {
225
+ "asm": {
226
+ "asm_version": "0.3",
227
+ "service_id": "example/search@1.0",
228
+ "taxonomy": "tool.data.search",
229
+ "pricing": {
230
+ "billing_dimensions": [
231
+ { "dimension": "query", "unit": "per_1K", "cost_per_unit": 2.5, "currency": "USD" }
232
+ ]
233
+ },
234
+ "sla": { "latency_p50": "650ms", "uptime": 0.995 },
235
+ "quality": {
236
+ "metrics": [
237
+ { "name": "answer_relevance", "score": 0.91, "scale": "0-1", "self_reported": true }
238
+ ]
239
+ },
240
+ "provenance": {
241
+ "source_url": "https://example.com/pricing",
242
+ "retrieved_at": "2026-05-08T00:00:00Z",
243
+ "last_verified_at": "2026-05-08T00:00:00Z",
244
+ "verification_status": "self_reported"
245
+ }
246
+ },
247
+ "asm_url": "https://example.com/.well-known/asm"
248
+ }
249
+ }
250
+ }
251
+ ```
252
+
253
+ Full guide: [`docs/integrations/mcp-registry.md`](docs/integrations/mcp-registry.md).
254
+
255
+ Producer adoption guide: [`docs/adoption/producer-guide.md`](docs/adoption/producer-guide.md).
256
+
257
+ Draft v0.4 operational envelope RFC:
258
+ [`docs/rfcs/operational-envelope-v0.4.md`](docs/rfcs/operational-envelope-v0.4.md).
259
+
260
+ Examples:
261
+
262
+ - [`examples/mcp-server-json/basic-with-asm.server.json`](examples/mcp-server-json/basic-with-asm.server.json)
263
+ - [`examples/mcp-server-json/remote-with-asm.server.json`](examples/mcp-server-json/remote-with-asm.server.json)
264
+ - [`examples/mcp-server-json/package-with-asm.server.json`](examples/mcp-server-json/package-with-asm.server.json)
265
+ - [`examples/mcp-server-json/operational-envelope-with-asm.server.json`](examples/mcp-server-json/operational-envelope-with-asm.server.json)
266
+
267
+ ---
268
+
269
+ ## Reference Integrations
270
+
271
+ Real third-party services that have implemented ASM-compatible value metadata or receipt formats. Each one ships a spec page in this repo plus, where applicable, a reference receipt example.
272
+
273
+ | Service | Type | Status | Spec |
274
+ |---|---|---|---|
275
+ | **Akkhar-Code** (Akkhar-Labs) | Agentic IDE, `tool.code.orchestration` | Trust Delta receipt extension v0.1 | [`docs/integrations/akkhar-code-receipt-spec.md`](docs/integrations/akkhar-code-receipt-spec.md) · [reference receipt](examples/receipts/akkhar-code-receipt.json) · RFC [#7](https://github.com/calebguo007/asm-spec/issues/7), PR [#8](https://github.com/calebguo007/asm-spec/pull/8) |
276
+
277
+ If you're implementing ASM (manifest, `.well-known/asm` endpoint, or a receipt emitter) and want a reference-integration row, open an issue with `integration` label.
278
+
279
+ ---
280
+
281
+ ## Manifest Template
282
+
283
+ Only three fields are required; value metadata is optional but makes the service rankable.
284
+
285
+ ```json
286
+ {
287
+ "asm_version": "0.3",
288
+ "service_id": "provider/service@version",
289
+ "taxonomy": "tool.data.search",
290
+ "display_name": "Service Name",
291
+ "provenance": {
292
+ "source_url": "https://provider.example/pricing",
293
+ "retrieved_at": "2026-05-08T00:00:00Z",
294
+ "last_verified_at": "2026-05-08T00:00:00Z",
295
+ "verification_status": "self_reported",
296
+ "notes": "Where pricing, SLA, and quality claims came from."
297
+ },
298
+ "pricing": {
299
+ "billing_dimensions": [
300
+ { "dimension": "request", "unit": "per_1K", "cost_per_unit": 1.0, "currency": "USD" }
301
+ ]
302
+ },
303
+ "quality": {
304
+ "metrics": [
305
+ { "name": "task_success_rate", "score": 0.9, "scale": "0-1", "self_reported": true }
306
+ ]
307
+ },
308
+ "sla": {
309
+ "latency_p50": "500ms",
310
+ "uptime": 0.99,
311
+ "rate_limit": "60 req/min"
312
+ },
313
+ "payment": {
314
+ "methods": ["stripe", "api_key_prepaid"],
315
+ "auth_type": "api_key",
316
+ "signup_url": "https://provider.example/signup"
317
+ }
318
+ }
319
+ ```
320
+
321
+ Schema: [`schema/asm-v0.3.schema.json`](schema/asm-v0.3.schema.json).
322
+
323
+ ---
324
+
325
+ ## Repository Map
326
+
327
+ ```text
328
+ schema/ ASM JSON Schema
329
+ library/ Tool-value library (agent tool selection) + select_demo.py
330
+ manifests/ 75 source-linked manifests
331
+ scorer/ Python TOPSIS scorer and tests
332
+ registry/ MCP registry server exposing ASM tools
333
+ examples/mcp-server-json/ MCP Registry server.json examples
334
+ docs/integrations/ MCP Registry and aggregator integration docs
335
+ experiments/ Audit, selection, LLM, live, and external stress-test scripts
336
+ paper/ Paper draft
337
+ ARTIFACT.md Claim-to-artifact reproducibility map
338
+ ```
339
+
340
+ ---
341
+
342
+ ## Reproduce the Paper Numbers
343
+
344
+ ```bash
345
+ pip install -r requirements.txt
346
+ make reproduce
347
+ ```
348
+
349
+ Live LLM/API experiments require external credentials and are documented separately in `ARTIFACT.md`.
350
+
351
+ ---
352
+
353
+ ## Design Principles
354
+
355
+ 1. Backward-compatible with MCP.
356
+ 2. Minimal required fields: `asm_version`, `service_id`, `taxonomy`.
357
+ 3. Value metadata is structured, source-linked, and auditable.
358
+ 4. Quality metrics preserve their original benchmark semantics.
359
+ 5. ASM declares value; AP2/payment systems execute settlement; receipts verify what happened.
360
+
361
+ ---
362
+
363
+ ## Contributing
364
+
365
+ Good first issues: [`docs/good-first-issues.md`](docs/good-first-issues.md).
366
+ Open starter issues: [Cohere](https://github.com/calebguo007/asm-spec/issues/1), [Mistral AI](https://github.com/calebguo007/asm-spec/issues/2), [Together AI](https://github.com/calebguo007/asm-spec/issues/3), [Groq](https://github.com/calebguo007/asm-spec/issues/4), [Fireworks AI](https://github.com/calebguo007/asm-spec/issues/5).
367
+
368
+ Common contribution paths:
369
+
370
+ - Add a source-linked manifest.
371
+ - Embed ASM in an MCP `server.json`.
372
+ - Report stale pricing/SLA/quality metadata.
373
+ - Propose a taxonomy or benchmark compatibility rule.
374
+ - Build an aggregator import script.
375
+
376
+ See [`CONTRIBUTING.md`](CONTRIBUTING.md).
377
+
378
+ ---
379
+
380
+ ## Citation
381
+
382
+ ```bibtex
383
+ @misc{asm2026,
384
+ title={Agent Service Manifest: Value-Aware Settlement for Autonomous Service Selection},
385
+ author={Guo, Yi},
386
+ year={2026},
387
+ howpublished={\url{https://github.com/calebguo007/asm-spec}}
388
+ }
389
+ ```
390
+
391
+ ---
392
+
393
+ ## License
394
+
395
+ MIT. See [`LICENSE`](LICENSE).