@multiagentcoordinationprotocol/mcp 0.0.0-stage → 0.3.0
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.
- package/CHANGELOG.md +20 -0
- package/LICENSE +201 -0
- package/README.md +260 -2
- package/contract/gate/cli.json +32 -0
- package/contract/gate/context-id-vectors.json +164 -0
- package/contract/gate/example.gate.json +22 -0
- package/contract/gate/gate.schema.json +70 -0
- package/contract/gate/session.json +82 -0
- package/contract/tools.json +819 -0
- package/dist/bridge.d.ts +66 -0
- package/dist/bridge.js +324 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +47 -0
- package/dist/config.d.ts +54 -0
- package/dist/config.js +136 -0
- package/dist/contract.d.ts +39 -0
- package/dist/contract.js +52 -0
- package/dist/gate/approval.d.ts +66 -0
- package/dist/gate/approval.js +202 -0
- package/dist/gate/cli.d.ts +14 -0
- package/dist/gate/cli.js +71 -0
- package/dist/gate/config.d.ts +38 -0
- package/dist/gate/config.js +111 -0
- package/dist/gate/context-id.d.ts +9 -0
- package/dist/gate/context-id.js +22 -0
- package/dist/gate/contract.d.ts +19 -0
- package/dist/gate/contract.js +64 -0
- package/dist/gate/jcs.d.ts +18 -0
- package/dist/gate/jcs.js +56 -0
- package/dist/gate/proxy.d.ts +30 -0
- package/dist/gate/proxy.js +71 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +66 -0
- package/dist/results.d.ts +111 -0
- package/dist/results.js +7 -0
- package/dist/server.d.ts +34 -0
- package/dist/server.js +109 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +6 -0
- package/package.json +67 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.3.0](https://github.com/multiagentcoordinationprotocol/macp-mcp-typescript/compare/v0.2.0...v0.3.0) (2026-10-25)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **gate:** macp-mcp gate — quorum-gated upstream tool calls (W3.8) ([#5](https://github.com/multiagentcoordinationprotocol/macp-mcp-typescript/issues/5)) ([503f5f4](https://github.com/multiagentcoordinationprotocol/macp-mcp-typescript/commit/503f5f413ee77de1d95d9e7802f647313d6e1df7))
|
|
9
|
+
|
|
10
|
+
## [0.2.0](https://github.com/multiagentcoordinationprotocol/macp-mcp-typescript/compare/v0.1.0...v0.2.0) (2026-10-25)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* macp-mcp TypeScript twin, an MCP server for MACP Decision sessions ([#1](https://github.com/multiagentcoordinationprotocol/macp-mcp-typescript/issues/1)) ([39310ca](https://github.com/multiagentcoordinationprotocol/macp-mcp-typescript/commit/39310ca8b6056af95fdde5d0dc33edbad9da5aee))
|
|
16
|
+
|
|
17
|
+
## Changelog
|
|
18
|
+
|
|
19
|
+
All notable changes to this project are documented here. Releases are cut by
|
|
20
|
+
release-please from Conventional Commits.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,261 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @multiagentcoordinationprotocol/mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An MCP server that lets any MCP client (Claude Desktop, Claude Code, Cursor and
|
|
4
|
+
others) run or join a [MACP](https://multiagentcoordinationprotocol.io) Decision
|
|
5
|
+
session. It is the TypeScript twin of the Python
|
|
6
|
+
[macp-mcp](https://github.com/multiagentcoordinationprotocol/macp-mcp). Both
|
|
7
|
+
expose the same tool surface: the same names, input schemas and outputs,
|
|
8
|
+
pinned by one shared manifest ([Tool contract](#tool-contract)).
|
|
9
|
+
Package versions are independent of the Python macp-mcp; tool parity is
|
|
10
|
+
enforced by `make verify-contract`, not by matching version numbers.
|
|
11
|
+
|
|
12
|
+
MCP decides which tools a model can call. MACP decides who may use them and
|
|
13
|
+
when, and records what was decided. The model drives every step through
|
|
14
|
+
ordinary MCP tool calls. The MACP runtime enforces who may propose, vote and
|
|
15
|
+
commit, ends the session in one binding Commitment, and gives that outcome an
|
|
16
|
+
RFC-MACP-0013 hash that anyone can recompute.
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
MCP client (model) ──stdio──▶ macp-mcp ──gRPC──▶ MACP runtime
|
|
20
|
+
tool calls one MACP agent enforces membership, order,
|
|
21
|
+
(macp-sdk-typescript) identity; records the Commitment
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npx -y @multiagentcoordinationprotocol/mcp # or: npm i -g @multiagentcoordinationprotocol/mcp
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Node 20 or newer. The installed binary is called `macp-mcp`, like the Python
|
|
31
|
+
server's. It needs a MACP runtime to talk to. For local development:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
docker run -p 50051:50051 -e MACP_ALLOW_INSECURE=1 -e MACP_MEMORY_ONLY=1 \
|
|
35
|
+
ghcr.io/multiagentcoordinationprotocol/macp-runtime:0.9.0
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
One `macp-mcp` process is one MACP agent. For several agents to take part in a
|
|
39
|
+
session, run one server per agent (for example, one per MCP client), each with
|
|
40
|
+
its own `MACP_AGENT_ID`.
|
|
41
|
+
|
|
42
|
+
## Configure your MCP client
|
|
43
|
+
|
|
44
|
+
### Claude Desktop
|
|
45
|
+
|
|
46
|
+
Add the server to `claude_desktop_config.json` (Settings → Developer → Edit Config):
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"mcpServers": {
|
|
51
|
+
"macp": {
|
|
52
|
+
"command": "npx",
|
|
53
|
+
"args": ["-y", "@multiagentcoordinationprotocol/mcp"],
|
|
54
|
+
"env": {
|
|
55
|
+
"MACP_RUNTIME_TARGET": "127.0.0.1:50051",
|
|
56
|
+
"MACP_AGENT_ID": "coordinator",
|
|
57
|
+
"MACP_ALLOW_INSECURE": "1"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Claude Code
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
claude mcp add macp \
|
|
68
|
+
--env MACP_RUNTIME_TARGET=127.0.0.1:50051 \
|
|
69
|
+
--env MACP_AGENT_ID=coordinator \
|
|
70
|
+
--env MACP_ALLOW_INSECURE=1 \
|
|
71
|
+
-- npx -y @multiagentcoordinationprotocol/mcp
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Then ask the model something like: _"Start a MACP decision with alice on
|
|
75
|
+
which deployment plan to use, propose a canary rollout, and vote for it."_
|
|
76
|
+
|
|
77
|
+
### Against a production runtime
|
|
78
|
+
|
|
79
|
+
Drop `MACP_ALLOW_INSECURE` and pass the bearer token the runtime issued for
|
|
80
|
+
this agent:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
"env": {
|
|
84
|
+
"MACP_RUNTIME_TARGET": "macp.example.com:443",
|
|
85
|
+
"MACP_AGENT_ID": "coordinator",
|
|
86
|
+
"MACP_AUTH_TOKEN": "<token issued for coordinator>"
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Environment variables
|
|
91
|
+
|
|
92
|
+
These are the same variables, with the same defaults, as the Python server.
|
|
93
|
+
|
|
94
|
+
| Variable | Default | Meaning |
|
|
95
|
+
| --------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
96
|
+
| `MACP_RUNTIME_TARGET` | `127.0.0.1:50051` | Runtime gRPC address (`host:port`). |
|
|
97
|
+
| `MACP_AGENT_ID` | `mcp-agent` | The MACP agent this server acts as. With dev-agent auth it is also the bearer token. With `MACP_AUTH_TOKEN` it is the identity the runtime must bind the token to. |
|
|
98
|
+
| `MACP_AUTH_TOKEN` | unset | Bearer token issued by the runtime. When unset, dev-agent auth is used, which needs a runtime started with `MACP_ALLOW_INSECURE=1`. |
|
|
99
|
+
| `MACP_ALLOW_INSECURE` | off | `1`/`true`/`yes`/`on` uses plaintext gRPC. For a local runtime only. |
|
|
100
|
+
| `MACP_TLS_CA_FILE` | system trust | PEM bundle for a private CA. Cannot be combined with `MACP_ALLOW_INSECURE`. |
|
|
101
|
+
| `MACP_DEFAULT_TTL_MS` | `300000` | Session TTL used when `start_session` is called without `ttl_ms`. |
|
|
102
|
+
| `MACP_REPLAY_IDLE_MS` | `1000` | How long a history read waits for the next envelope before treating the replay as complete. |
|
|
103
|
+
|
|
104
|
+
The server logs to stderr only, because stdout carries the MCP protocol. A bad
|
|
105
|
+
configuration exits with status 2 and a one-line message.
|
|
106
|
+
|
|
107
|
+
## Tools
|
|
108
|
+
|
|
109
|
+
| Tool | Kind | What it does |
|
|
110
|
+
| ---------------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
111
|
+
| `start_session` | write | Start a Decision session with this agent as initiator. Takes `intent`, `participants` and optional `ttl_ms` and `context_id`. Returns the `session_id` to share. |
|
|
112
|
+
| `propose` | write | Put an option (`proposal_id`, `option`, `rationale`) up for decision. |
|
|
113
|
+
| `evaluate` | write | Record a scored assessment (`APPROVE` / `REVIEW` / `BLOCK` / `REJECT`, confidence 0..1) before voting. |
|
|
114
|
+
| `vote` | write | Cast this agent's `APPROVE` / `REJECT` / `ABSTAIN` vote on a proposal. |
|
|
115
|
+
| `commit` | write | Resolve the session with a binding Commitment (`action`, `authority_scope`, `reason`). Under the default policy only the initiator can commit. |
|
|
116
|
+
| `get_session` | read | The session's state, participants, proposals, evaluations, votes, approve totals and majority winner. |
|
|
117
|
+
| `get_commitment` | read | The resolved session's binding Commitment, the exact payload bytes (`payload_b64`) and its RFC-MACP-0013 `commitment_hash`. |
|
|
118
|
+
| `verify` | read | Recompute a commitment hash with the SDK verifier, either from the runtime's recorded history (`session_id`) or from bytes you hold (`payload_b64`). Returns `match`, `mismatch` or `cannot_verify`. |
|
|
119
|
+
|
|
120
|
+
Errors the model can act on, such as a runtime rejection or a bad argument,
|
|
121
|
+
come back as tool errors with the text `"<CODE>: <message>"`, for example
|
|
122
|
+
`FORBIDDEN: Forbidden` when a non-initiator tries to commit. The code is the
|
|
123
|
+
MACP error code: the Ack failure code, then the `macp-error-code` trailer, then
|
|
124
|
+
the gRPC status name.
|
|
125
|
+
|
|
126
|
+
The server is stateless. Every read replays the session from the runtime, so a
|
|
127
|
+
restart loses nothing, and several servers (agents) can share one session.
|
|
128
|
+
|
|
129
|
+
## Gate upstream tool calls (`macp-mcp gate`)
|
|
130
|
+
|
|
131
|
+
`macp-mcp gate` is a second mode of the same binary. It runs as an MCP server
|
|
132
|
+
in front of another (upstream) MCP server, and puts the tool calls you name
|
|
133
|
+
behind a MACP session: a matching call reaches the upstream only after a
|
|
134
|
+
Quorum or Decision session commits `approve`. Every other call passes straight
|
|
135
|
+
through.
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
macp-mcp gate --policy gate.json --upstream npx -y @modelcontextprotocol/server-filesystem /srv/data
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`--upstream` takes the rest of the command line as the upstream's stdio
|
|
142
|
+
command. The gate uses the same environment variables as the base server
|
|
143
|
+
(`MACP_AGENT_ID` is the gate's identity: it initiates and commits every
|
|
144
|
+
session). The upstream inherits the gate's environment minus
|
|
145
|
+
`MACP_AUTH_TOKEN`, so the gate's credential never reaches it.
|
|
146
|
+
|
|
147
|
+
`gate.json` names the rules; the first rule whose `tool` matches wins (exact
|
|
148
|
+
name, or a glob with `*` and `?`):
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"version": 1,
|
|
153
|
+
"server": "filesystem",
|
|
154
|
+
"rules": [
|
|
155
|
+
{ "tool": "write_*", "mode": "macp.mode.quorum.v1", "participants": ["alice", "bob", "carol"], "threshold": 2 },
|
|
156
|
+
{ "tool": "move_file", "mode": "macp.mode.decision.v1", "participants": ["alice", "bob"], "ttl_ms": 60000 }
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
| Field | Meaning |
|
|
162
|
+
| ---------------- | ------------------------------------------------------------------------------------------------- |
|
|
163
|
+
| `server` | The upstream's name, bound into every gated call's `context_id`. |
|
|
164
|
+
| `tool` | Exact tool name or glob. |
|
|
165
|
+
| `mode` | `macp.mode.quorum.v1` (ApprovalRequest + ballots) or `macp.mode.decision.v1` (Proposal + votes). |
|
|
166
|
+
| `participants` | The approvers. Must not include the gate's own agent id. |
|
|
167
|
+
| `threshold` | APPROVE ballots needed, in either mode. Default: a strict majority of `participants`. |
|
|
168
|
+
| `ttl_ms` | Session TTL. Default `300000`. |
|
|
169
|
+
| `policy_version` | Optional RFC-MACP-0012 policy to bind the session to, for example one of the spec's policy packs. |
|
|
170
|
+
|
|
171
|
+
For a gated call the gate:
|
|
172
|
+
|
|
173
|
+
1. Starts a session whose `context_id` is `sha256:` + the hex SHA-256 of the
|
|
174
|
+
RFC 8785 (JCS) form of `{"arguments", "server", "tool"}`. The same canonical
|
|
175
|
+
JSON travels in the ApprovalRequest `details` (Quorum) or the Proposal
|
|
176
|
+
`rationale` (Decision), so an approver can recompute the binding.
|
|
177
|
+
2. Commits `approve` as soon as the approvers' latest ballots reach the
|
|
178
|
+
threshold, or `deny` as soon as they no longer can (REJECT and ABSTAIN both
|
|
179
|
+
count as not-approve).
|
|
180
|
+
3. On `approve`, forwards the call and adds the commitment to the result,
|
|
181
|
+
beside any `_meta` the upstream set:
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
"_meta": {
|
|
185
|
+
"io.multiagentcoordinationprotocol/commitment": {
|
|
186
|
+
"session_id": "…", "mode": "macp.mode.quorum.v1", "outcome": "approve",
|
|
187
|
+
"commitment_hash": "sha256:…"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
`commitment_hash` is the RFC-MACP-0013 hash; the base server's `verify`
|
|
193
|
+
tool recomputes it from the runtime's history.
|
|
194
|
+
|
|
195
|
+
4. Otherwise refuses with a tool error, and never calls the upstream:
|
|
196
|
+
`POLICY_DENIED: …` when the session commits `deny` (or a bound policy
|
|
197
|
+
refuses the commitment), `SESSION_NOT_OPEN: …` when the session expires or
|
|
198
|
+
is cancelled without a commitment. If the session is still open 5 s after
|
|
199
|
+
its TTL, the gate cancels it. A call whose arguments hold an integer
|
|
200
|
+
outside ±(2^53−1) is refused with `INVALID_ARGUMENT: …` before any session
|
|
201
|
+
opens: JSON may already have rounded it, so it has no canonical form.
|
|
202
|
+
|
|
203
|
+
Approvers are ordinary MACP agents, for example a base `macp-mcp` server
|
|
204
|
+
driven by a person or another model, voting through the runtime. See
|
|
205
|
+
[examples/gated-tool-call.md](examples/gated-tool-call.md) for a full
|
|
206
|
+
transcript. The policy schema, CLI flags, wire values and `context_id` test
|
|
207
|
+
vectors live in [`contract/gate/`](contract/gate), byte-identical to the
|
|
208
|
+
Python macp-mcp's.
|
|
209
|
+
|
|
210
|
+
## Tool contract
|
|
211
|
+
|
|
212
|
+
[`contract/tools.json`](contract/tools.json) pins the tool names,
|
|
213
|
+
descriptions, annotations, input schemas and output schemas as fully inlined
|
|
214
|
+
JSON Schema 2020-12. The Python macp-mcp generates it, and this repo keeps a
|
|
215
|
+
byte-identical copy. This server does not derive its schemas from code: it
|
|
216
|
+
serves the manifest verbatim from `tools/list` and validates every call's
|
|
217
|
+
arguments against it with Ajv, so the advertised surface cannot drift from
|
|
218
|
+
the file. The file also ships in the npm package as
|
|
219
|
+
`@multiagentcoordinationprotocol/mcp/contract/tools.json`.
|
|
220
|
+
|
|
221
|
+
The gate's contract (`contract/gate/`) is vendored the same way. CI fails if
|
|
222
|
+
any of these files drifts from the Python repo's (`make verify-contract`).
|
|
223
|
+
After a deliberate surface change lands in macp-mcp, run `make sync-contract`
|
|
224
|
+
and implement the change here.
|
|
225
|
+
|
|
226
|
+
## Library use
|
|
227
|
+
|
|
228
|
+
The package also exports the pieces, for embedding the server in another
|
|
229
|
+
process or testing against it:
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
import { buildServer, loadSettings } from '@multiagentcoordinationprotocol/mcp';
|
|
233
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
234
|
+
|
|
235
|
+
const { server } = buildServer({ settings: loadSettings() });
|
|
236
|
+
await server.connect(new StdioServerTransport());
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Development
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
npm ci
|
|
243
|
+
npm run check && npm run lint && npm run format:check
|
|
244
|
+
npm test # unit tests (fake runtime, in-memory MCP client)
|
|
245
|
+
make verify-contract # contract/tools.json == the Python macp-mcp's
|
|
246
|
+
|
|
247
|
+
# Acceptance: two stdio MCP clients drive a Decision session to RESOLVED
|
|
248
|
+
docker run -d --rm --name macp-runtime-test -p 50051:50051 \
|
|
249
|
+
-e MACP_BIND_ADDR=0.0.0.0:50051 -e MACP_ALLOW_INSECURE=1 -e MACP_MEMORY_ONLY=1 \
|
|
250
|
+
ghcr.io/multiagentcoordinationprotocol/macp-runtime:0.9.0
|
|
251
|
+
npx tsx scripts/wait-for-runtime.ts
|
|
252
|
+
npm run test:integration
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Releases follow macp-sdk-typescript: release-please opens the release PR, and
|
|
256
|
+
merging it creates the GitHub release, which publishes to npmjs with
|
|
257
|
+
provenance.
|
|
258
|
+
|
|
259
|
+
## License
|
|
260
|
+
|
|
261
|
+
Apache-2.0
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contract_version": "1",
|
|
3
|
+
"command": "macp-mcp gate",
|
|
4
|
+
"usage": "macp-mcp gate --policy <gate.json> --upstream <command> [args...]",
|
|
5
|
+
"flags": [
|
|
6
|
+
{
|
|
7
|
+
"name": "--policy",
|
|
8
|
+
"required": true,
|
|
9
|
+
"value": "PATH",
|
|
10
|
+
"description": "The gate.json policy file (contract/gate/gate.schema.json)."
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "--upstream",
|
|
14
|
+
"required": true,
|
|
15
|
+
"value": "COMMAND [ARGS...]",
|
|
16
|
+
"description": "The upstream MCP server's stdio command line. Must be the last option: every argument after it belongs to the upstream command."
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"environment": {
|
|
20
|
+
"read": ["MACP_RUNTIME_TARGET", "MACP_AGENT_ID", "MACP_AUTH_TOKEN", "MACP_ALLOW_INSECURE", "MACP_TLS_CA_FILE"],
|
|
21
|
+
"withheld_from_upstream": ["MACP_AUTH_TOKEN"],
|
|
22
|
+
"note": "The upstream process inherits the gate's environment minus withheld_from_upstream. The gate is the MACP agent MACP_AGENT_ID; it initiates and commits every approval session."
|
|
23
|
+
},
|
|
24
|
+
"exit_codes": {
|
|
25
|
+
"2": "Unusable configuration: bad MACP_* environment, an invalid gate.json, or a missing --upstream command. One line on stderr."
|
|
26
|
+
},
|
|
27
|
+
"server": {
|
|
28
|
+
"name": "macp-mcp-gate",
|
|
29
|
+
"proxies": ["tools/list", "tools/call"],
|
|
30
|
+
"instructions": "Some tools on this server are gated by MACP: a call to one opens a MACP session and runs only after the named approvers approve it. A refused call returns an error starting POLICY_DENIED or SESSION_NOT_OPEN; do not retry it unchanged."
|
|
31
|
+
}
|
|
32
|
+
}
|