@t2kai/mcp 0.1.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/LICENSE +201 -0
- package/README.md +123 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +67 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +30 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +524 -0
- package/dist/server.js.map +1 -0
- package/package.json +70 -0
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 2026 T2K contributors
|
|
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
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# `@t2kai/mcp`
|
|
2
|
+
|
|
3
|
+
Local stdio MCP server for the open T2K ontology, decision, and learning
|
|
4
|
+
runtime. It lets an MCP host validate and compile ontology packs, execute and
|
|
5
|
+
evaluate policies, and optionally inspect or write a local governed lifecycle.
|
|
6
|
+
|
|
7
|
+
Node.js 20.10 or newer is required.
|
|
8
|
+
|
|
9
|
+
## Start in the Safe Default Mode
|
|
10
|
+
|
|
11
|
+
Use this standard MCP host configuration:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"mcpServers": {
|
|
16
|
+
"t2k": {
|
|
17
|
+
"command": "npx",
|
|
18
|
+
"args": ["-y", "@t2kai/mcp@latest"]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The default mode has no network or database requirement and exposes only
|
|
25
|
+
deterministic, read-only computation:
|
|
26
|
+
|
|
27
|
+
- `validate_ontology_pack`
|
|
28
|
+
- `compile_ontology_pack_set`
|
|
29
|
+
- `evaluate_reference_policy`
|
|
30
|
+
- `evaluate_reference_replay`
|
|
31
|
+
- `evaluate_reference_reward`
|
|
32
|
+
|
|
33
|
+
The `t2k://capabilities` resource reports the active mode and exact tool set.
|
|
34
|
+
|
|
35
|
+
## Add a Local Lifecycle
|
|
36
|
+
|
|
37
|
+
Set `T2K_DATABASE_URL` to expose lifecycle inspection without enabling writes:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"mcpServers": {
|
|
42
|
+
"t2k": {
|
|
43
|
+
"command": "npx",
|
|
44
|
+
"args": ["-y", "@t2kai/mcp@latest"],
|
|
45
|
+
"env": {
|
|
46
|
+
"T2K_DATABASE_URL": "postgresql://postgres:postgres@127.0.0.1:5432/t2k",
|
|
47
|
+
"T2K_MCP_AUTO_MIGRATE": "true"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This adds `get_active_policy`, `get_lifecycle_snapshot`,
|
|
55
|
+
`verify_event_chain`, and the `t2k://lifecycle/snapshot` resource. Schema
|
|
56
|
+
migration is additive and idempotent; it is opt-in so the process does not
|
|
57
|
+
silently claim a database schema.
|
|
58
|
+
|
|
59
|
+
## Explicitly Enable Agent Writes
|
|
60
|
+
|
|
61
|
+
Mutation tools require all three settings:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"T2K_DATABASE_URL": "postgresql://postgres:postgres@127.0.0.1:5432/t2k",
|
|
66
|
+
"T2K_MCP_ALLOW_MUTATIONS": "true",
|
|
67
|
+
"T2K_MCP_ACTOR_ID": "agent:local-assistant"
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Every write is then recorded as that fixed `agent` identity. A tool call cannot
|
|
72
|
+
supply or override `actorType` or `actorId`. Agent mode can create policies and
|
|
73
|
+
contexts, compute recommendations, open already-authorized episodes, record
|
|
74
|
+
receipts and observations, assess rewards, and propose learning candidates.
|
|
75
|
+
|
|
76
|
+
The server deliberately does **not** expose operations that assert a human
|
|
77
|
+
judgment:
|
|
78
|
+
|
|
79
|
+
- policy acceptance or deployment;
|
|
80
|
+
- recommendation authorization;
|
|
81
|
+
- episode closure;
|
|
82
|
+
- candidate evaluation, promotion, deployment, or rollback.
|
|
83
|
+
|
|
84
|
+
Those operations must run through a trusted human interface that authenticates
|
|
85
|
+
the reviewer and enforces separation of duties. This omission is a security
|
|
86
|
+
boundary, not an incomplete tool list.
|
|
87
|
+
|
|
88
|
+
## Programmatic Use
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
92
|
+
import { createT2kMcpRuntime } from "@t2kai/mcp";
|
|
93
|
+
|
|
94
|
+
const runtime = await createT2kMcpRuntime({
|
|
95
|
+
connectionString: process.env.T2K_DATABASE_URL,
|
|
96
|
+
allowMutations: false,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
await runtime.server.connect(new StdioServerTransport());
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
An application can instead provide an existing `PostgresReferenceLifecycle`.
|
|
103
|
+
The runtime closes only database pools that it creates itself.
|
|
104
|
+
|
|
105
|
+
## Threat Boundary
|
|
106
|
+
|
|
107
|
+
- Treat MCP tool arguments as untrusted input; the core runtime validates
|
|
108
|
+
manifests, policy contracts, state, rewards, receipts, and lifecycle order.
|
|
109
|
+
- Use a dedicated database role and database. Database ownership can bypass the
|
|
110
|
+
append-only trigger, so independently anchor event heads when non-repudiation
|
|
111
|
+
is required.
|
|
112
|
+
- Keep database URLs out of committed host configuration. Prefer environment or
|
|
113
|
+
secret injection supported by the MCP host.
|
|
114
|
+
- Mutation mode does not authenticate a human and must not be used as a path to
|
|
115
|
+
synthesize human approvals.
|
|
116
|
+
|
|
117
|
+
See the full integration guide in
|
|
118
|
+
[`docs/MCP.md`](../../docs/MCP.md) and the lifecycle trust boundary in
|
|
119
|
+
[`packages/core/README.md`](../core/README.md).
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
Apache-2.0. Contributions require DCO sign-off in the public repository.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { createT2kMcpRuntime, T2K_MCP_VERSION } from "./server.js";
|
|
5
|
+
const help = `t2k-mcp ${T2K_MCP_VERSION}
|
|
6
|
+
|
|
7
|
+
Safe local MCP adapter for the open T2K runtime.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
t2k-mcp
|
|
11
|
+
t2k-mcp --help
|
|
12
|
+
t2k-mcp --version
|
|
13
|
+
|
|
14
|
+
Environment:
|
|
15
|
+
T2K_DATABASE_URL Enable local lifecycle read tools.
|
|
16
|
+
T2K_MCP_AUTO_MIGRATE=true Apply the idempotent reference schema at startup.
|
|
17
|
+
T2K_MCP_ALLOW_MUTATIONS=true
|
|
18
|
+
Enable agent mutation tools.
|
|
19
|
+
T2K_MCP_ACTOR_ID=<id> Fixed agent identity required for mutations.
|
|
20
|
+
|
|
21
|
+
Human approval, authorization, closure, evaluation, promotion, deployment, and
|
|
22
|
+
rollback operations are deliberately never exposed by this MCP server.
|
|
23
|
+
`;
|
|
24
|
+
function enabled(value) {
|
|
25
|
+
return value === "1" || value?.toLowerCase() === "true";
|
|
26
|
+
}
|
|
27
|
+
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
|
28
|
+
process.stdout.write(help);
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
if (process.argv.includes("--version") || process.argv.includes("-v")) {
|
|
32
|
+
process.stdout.write(`${T2K_MCP_VERSION}\n`);
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
if (process.argv.length > 2) {
|
|
36
|
+
process.stderr.write("t2k-mcp received an unsupported argument. Use --help.\n");
|
|
37
|
+
process.exit(2);
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const runtime = await createT2kMcpRuntime({
|
|
41
|
+
connectionString: process.env.T2K_DATABASE_URL,
|
|
42
|
+
autoMigrate: enabled(process.env.T2K_MCP_AUTO_MIGRATE),
|
|
43
|
+
allowMutations: enabled(process.env.T2K_MCP_ALLOW_MUTATIONS),
|
|
44
|
+
actorId: process.env.T2K_MCP_ACTOR_ID,
|
|
45
|
+
logger(message, error) {
|
|
46
|
+
const detail = error instanceof Error ? ` ${error.stack ?? error.message}` : "";
|
|
47
|
+
process.stderr.write(`${message}${detail}\n`);
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
const transport = new StdioServerTransport();
|
|
51
|
+
const shutdown = () => {
|
|
52
|
+
void runtime.close().then(() => process.exit(0), (error) => {
|
|
53
|
+
const message = error instanceof Error ? error.message : "Unknown error.";
|
|
54
|
+
process.stderr.write(`t2k-mcp shutdown failed: ${message}\n`);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
process.once("SIGINT", shutdown);
|
|
59
|
+
process.once("SIGTERM", shutdown);
|
|
60
|
+
await runtime.server.connect(transport);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
const message = error instanceof Error ? error.message : "Unknown startup error.";
|
|
64
|
+
process.stderr.write(`t2k-mcp failed to start: ${message}\n`);
|
|
65
|
+
process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C,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAC1C,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC;IAClF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,OAAO,IAAI,CAAC,CAAC;IAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { PostgresReferenceLifecycle, type ReferenceLifecycleActor } from "@t2kai/core/postgres";
|
|
3
|
+
export declare const T2K_MCP_VERSION: string;
|
|
4
|
+
export declare const T2K_MCP_HUMAN_GOVERNANCE_OPERATIONS: readonly ["accept_policy_version", "deploy_policy_version", "authorize_recommendation", "close_decision_episode", "evaluate_learning_candidate", "promote_learning_candidate", "deploy_promotion", "rollback_promotion"];
|
|
5
|
+
export interface T2kMcpCapabilities {
|
|
6
|
+
mode: "semantic-only" | "lifecycle-read-only" | "agent-mutation";
|
|
7
|
+
transport: "stdio";
|
|
8
|
+
databaseConfigured: boolean;
|
|
9
|
+
mutationToolsEnabled: boolean;
|
|
10
|
+
actor: ReferenceLifecycleActor | null;
|
|
11
|
+
tools: string[];
|
|
12
|
+
omittedHumanGovernanceOperations: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface CreateT2kMcpRuntimeOptions {
|
|
15
|
+
lifecycle?: PostgresReferenceLifecycle;
|
|
16
|
+
connectionString?: string;
|
|
17
|
+
allowMutations?: boolean;
|
|
18
|
+
actorId?: string;
|
|
19
|
+
autoMigrate?: boolean;
|
|
20
|
+
serverName?: string;
|
|
21
|
+
serverVersion?: string;
|
|
22
|
+
logger?: (message: string, error?: unknown) => void;
|
|
23
|
+
}
|
|
24
|
+
export interface T2kMcpRuntime {
|
|
25
|
+
server: McpServer;
|
|
26
|
+
capabilities: T2kMcpCapabilities;
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export declare function createT2kMcpRuntime(options?: CreateT2kMcpRuntimeOptions): Promise<T2kMcpRuntime>;
|
|
30
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAqBpE,OAAO,EACL,0BAA0B,EAE1B,KAAK,uBAAuB,EAC7B,MAAM,sBAAsB,CAAC;AAS9B,eAAO,MAAM,eAAe,QAA0B,CAAC;AAEvD,eAAO,MAAM,mCAAmC,0NAStC,CAAC;AAoDX,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,eAAe,GAAG,qBAAqB,GAAG,gBAAgB,CAAC;IACjE,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,KAAK,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACtC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,gCAAgC,EAAE,MAAM,EAAE,CAAC;CAC5C;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,CAAC,EAAE,0BAA0B,CAAC;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,EAAE,kBAAkB,CAAC;IACjC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AA6mBD,wBAAsB,mBAAmB,CACvC,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,aAAa,CAAC,CAoJxB"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { ReferencePolicyError, ReferenceRewardError, evaluateReferencePolicy, evaluateReferenceReplay, evaluateReferenceReward, validateOntologyPackManifest, } from "@t2kai/core";
|
|
4
|
+
import { compileOntologyPackSet, } from "@t2kai/core/compiler";
|
|
5
|
+
import { PostgresReferenceLifecycle, ReferenceLifecycleError, } from "@t2kai/core/postgres";
|
|
6
|
+
import * as z from "zod/v4";
|
|
7
|
+
const packageManifest = createRequire(import.meta.url)("../package.json");
|
|
8
|
+
if (typeof packageManifest.version !== "string" || !packageManifest.version) {
|
|
9
|
+
throw new Error("@t2kai/mcp package version is missing.");
|
|
10
|
+
}
|
|
11
|
+
export const T2K_MCP_VERSION = packageManifest.version;
|
|
12
|
+
export const T2K_MCP_HUMAN_GOVERNANCE_OPERATIONS = [
|
|
13
|
+
"accept_policy_version",
|
|
14
|
+
"deploy_policy_version",
|
|
15
|
+
"authorize_recommendation",
|
|
16
|
+
"close_decision_episode",
|
|
17
|
+
"evaluate_learning_candidate",
|
|
18
|
+
"promote_learning_candidate",
|
|
19
|
+
"deploy_promotion",
|
|
20
|
+
"rollback_promotion",
|
|
21
|
+
];
|
|
22
|
+
const SEMANTIC_TOOL_NAMES = [
|
|
23
|
+
"validate_ontology_pack",
|
|
24
|
+
"compile_ontology_pack_set",
|
|
25
|
+
"evaluate_reference_policy",
|
|
26
|
+
"evaluate_reference_replay",
|
|
27
|
+
"evaluate_reference_reward",
|
|
28
|
+
];
|
|
29
|
+
const LIFECYCLE_READ_TOOL_NAMES = [
|
|
30
|
+
"get_active_policy",
|
|
31
|
+
"get_lifecycle_snapshot",
|
|
32
|
+
"verify_event_chain",
|
|
33
|
+
];
|
|
34
|
+
const LIFECYCLE_MUTATION_TOOL_NAMES = [
|
|
35
|
+
"create_reasoning_policy",
|
|
36
|
+
"propose_policy_version",
|
|
37
|
+
"create_decision_context",
|
|
38
|
+
"compute_recommendation",
|
|
39
|
+
"open_decision_episode",
|
|
40
|
+
"record_execution_receipt",
|
|
41
|
+
"record_observation",
|
|
42
|
+
"assess_reward",
|
|
43
|
+
"propose_learning_candidate",
|
|
44
|
+
];
|
|
45
|
+
const outputSchema = { result: z.unknown() };
|
|
46
|
+
const jsonObjectSchema = z.record(z.string(), z.unknown());
|
|
47
|
+
const learningModeSchema = z.enum([
|
|
48
|
+
"none",
|
|
49
|
+
"supervised_feedback",
|
|
50
|
+
"contextual_bandit",
|
|
51
|
+
"sequential_rl",
|
|
52
|
+
"optimization",
|
|
53
|
+
]);
|
|
54
|
+
const readOnlyAnnotations = {
|
|
55
|
+
readOnlyHint: true,
|
|
56
|
+
destructiveHint: false,
|
|
57
|
+
idempotentHint: true,
|
|
58
|
+
openWorldHint: false,
|
|
59
|
+
};
|
|
60
|
+
const mutationAnnotations = {
|
|
61
|
+
readOnlyHint: false,
|
|
62
|
+
destructiveHint: false,
|
|
63
|
+
idempotentHint: false,
|
|
64
|
+
openWorldHint: false,
|
|
65
|
+
};
|
|
66
|
+
function normalizeJson(value) {
|
|
67
|
+
if (value === undefined)
|
|
68
|
+
return null;
|
|
69
|
+
return JSON.parse(JSON.stringify(value));
|
|
70
|
+
}
|
|
71
|
+
function successResult(value) {
|
|
72
|
+
const result = normalizeJson(value);
|
|
73
|
+
return {
|
|
74
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
75
|
+
structuredContent: { result },
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function safeErrorMessage(error) {
|
|
79
|
+
if (error instanceof ReferenceLifecycleError ||
|
|
80
|
+
error instanceof ReferencePolicyError ||
|
|
81
|
+
error instanceof ReferenceRewardError) {
|
|
82
|
+
return error.message;
|
|
83
|
+
}
|
|
84
|
+
return "The T2K operation failed. Inspect the server log for details.";
|
|
85
|
+
}
|
|
86
|
+
function protectedTool(logger, operation) {
|
|
87
|
+
return async (input) => {
|
|
88
|
+
try {
|
|
89
|
+
return successResult(await operation(input));
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
logger("T2K MCP tool execution failed.", error);
|
|
93
|
+
return {
|
|
94
|
+
content: [{ type: "text", text: safeErrorMessage(error) }],
|
|
95
|
+
isError: true,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function requireTrimmed(value, label) {
|
|
101
|
+
const normalized = value?.trim();
|
|
102
|
+
if (!normalized)
|
|
103
|
+
throw new Error(`${label} is required.`);
|
|
104
|
+
return normalized;
|
|
105
|
+
}
|
|
106
|
+
function asJsonObject(value) {
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
function registerSemanticTools(server, logger) {
|
|
110
|
+
server.registerTool("validate_ontology_pack", {
|
|
111
|
+
title: "Validate T2K ontology pack",
|
|
112
|
+
description: "Validate one ontology-pack manifest against the exact public T2K schema.",
|
|
113
|
+
inputSchema: { manifest: z.unknown() },
|
|
114
|
+
outputSchema,
|
|
115
|
+
annotations: readOnlyAnnotations,
|
|
116
|
+
}, protectedTool(logger, ({ manifest }) => validateOntologyPackManifest(manifest)));
|
|
117
|
+
server.registerTool("compile_ontology_pack_set", {
|
|
118
|
+
title: "Compile T2K ontology packs",
|
|
119
|
+
description: "Resolve and compile ontology-pack manifests deterministically from explicit roots and context values.",
|
|
120
|
+
inputSchema: {
|
|
121
|
+
manifests: z.array(z.unknown()),
|
|
122
|
+
roots: z.array(z.object({ ontologyId: z.string().min(1), version: z.string().min(1) })),
|
|
123
|
+
contextValues: jsonObjectSchema.optional(),
|
|
124
|
+
},
|
|
125
|
+
outputSchema,
|
|
126
|
+
annotations: readOnlyAnnotations,
|
|
127
|
+
}, protectedTool(logger, (input) => compileOntologyPackSet(input)));
|
|
128
|
+
server.registerTool("evaluate_reference_policy", {
|
|
129
|
+
title: "Evaluate T2K reference policy",
|
|
130
|
+
description: "Compute an action from an executable reference-policy specification and a state snapshot.",
|
|
131
|
+
inputSchema: {
|
|
132
|
+
specification: jsonObjectSchema,
|
|
133
|
+
state: jsonObjectSchema,
|
|
134
|
+
},
|
|
135
|
+
outputSchema,
|
|
136
|
+
annotations: readOnlyAnnotations,
|
|
137
|
+
}, protectedTool(logger, (input) => evaluateReferencePolicy(asJsonObject(input.specification), asJsonObject(input.state))));
|
|
138
|
+
server.registerTool("evaluate_reference_replay", {
|
|
139
|
+
title: "Evaluate held-out policy replay",
|
|
140
|
+
description: "Compute held-out inverse-propensity replay for a candidate and baseline; no caller-supplied verdict is accepted.",
|
|
141
|
+
inputSchema: {
|
|
142
|
+
candidateSpecification: jsonObjectSchema,
|
|
143
|
+
baselineSpecification: jsonObjectSchema,
|
|
144
|
+
episodes: z.array(z.unknown()).min(1),
|
|
145
|
+
},
|
|
146
|
+
outputSchema,
|
|
147
|
+
annotations: readOnlyAnnotations,
|
|
148
|
+
}, protectedTool(logger, (input) => evaluateReferenceReplay({
|
|
149
|
+
candidateSpecification: asJsonObject(input.candidateSpecification),
|
|
150
|
+
baselineSpecification: asJsonObject(input.baselineSpecification),
|
|
151
|
+
episodes: input.episodes,
|
|
152
|
+
})));
|
|
153
|
+
server.registerTool("evaluate_reference_reward", {
|
|
154
|
+
title: "Evaluate governed reward",
|
|
155
|
+
description: "Compute a reward vector and guardrail-aware scalar from a declared reward specification and observations.",
|
|
156
|
+
inputSchema: {
|
|
157
|
+
rewardSpec: z.array(z.unknown()).min(1),
|
|
158
|
+
observations: z.array(z.unknown()),
|
|
159
|
+
},
|
|
160
|
+
outputSchema,
|
|
161
|
+
annotations: readOnlyAnnotations,
|
|
162
|
+
}, protectedTool(logger, (input) => evaluateReferenceReward({
|
|
163
|
+
rewardSpec: input.rewardSpec,
|
|
164
|
+
observations: input.observations,
|
|
165
|
+
})));
|
|
166
|
+
}
|
|
167
|
+
function registerLifecycleReadTools(server, lifecycle, logger) {
|
|
168
|
+
server.registerTool("get_active_policy", {
|
|
169
|
+
title: "Get active T2K policy",
|
|
170
|
+
description: "Read the deployed policy bound to a decision type.",
|
|
171
|
+
inputSchema: { decisionType: z.string().min(1) },
|
|
172
|
+
outputSchema,
|
|
173
|
+
annotations: readOnlyAnnotations,
|
|
174
|
+
}, protectedTool(logger, ({ decisionType }) => lifecycle.getActivePolicy(decisionType)));
|
|
175
|
+
server.registerTool("get_lifecycle_snapshot", {
|
|
176
|
+
title: "Get T2K lifecycle snapshot",
|
|
177
|
+
description: "Read the local reference lifecycle state, reward aggregates, and event-chain status.",
|
|
178
|
+
outputSchema,
|
|
179
|
+
annotations: readOnlyAnnotations,
|
|
180
|
+
}, protectedTool(logger, () => lifecycle.snapshot()));
|
|
181
|
+
server.registerTool("verify_event_chain", {
|
|
182
|
+
title: "Verify T2K event chain",
|
|
183
|
+
description: "Verify the append-only local lifecycle event hash chain.",
|
|
184
|
+
outputSchema,
|
|
185
|
+
annotations: readOnlyAnnotations,
|
|
186
|
+
}, protectedTool(logger, () => lifecycle.verifyEventChain()));
|
|
187
|
+
}
|
|
188
|
+
function registerLifecycleMutationTools(server, lifecycle, actor, logger) {
|
|
189
|
+
server.registerTool("create_reasoning_policy", {
|
|
190
|
+
title: "Create T2K reasoning policy",
|
|
191
|
+
description: "Create a local reasoning-policy family as the configured MCP agent.",
|
|
192
|
+
inputSchema: {
|
|
193
|
+
policyKey: z.string().min(1),
|
|
194
|
+
label: z.string().min(1),
|
|
195
|
+
description: z.string().optional(),
|
|
196
|
+
decisionType: z.string().min(1),
|
|
197
|
+
},
|
|
198
|
+
outputSchema,
|
|
199
|
+
annotations: mutationAnnotations,
|
|
200
|
+
}, protectedTool(logger, (input) => lifecycle.createPolicy(input, actor)));
|
|
201
|
+
server.registerTool("propose_policy_version", {
|
|
202
|
+
title: "Propose T2K policy version",
|
|
203
|
+
description: "Propose an executable local policy version. Acceptance and deployment remain human-only outside MCP.",
|
|
204
|
+
inputSchema: {
|
|
205
|
+
policyKey: z.string().min(1),
|
|
206
|
+
policyVersion: z.string().min(1),
|
|
207
|
+
learningMode: learningModeSchema,
|
|
208
|
+
specification: jsonObjectSchema,
|
|
209
|
+
rewardSpec: z.array(z.unknown()).min(1),
|
|
210
|
+
parentVersionId: z.string().nullable().optional(),
|
|
211
|
+
rationale: z.string().min(1),
|
|
212
|
+
},
|
|
213
|
+
outputSchema,
|
|
214
|
+
annotations: mutationAnnotations,
|
|
215
|
+
}, protectedTool(logger, (input) => lifecycle.createPolicyVersion(input.policyKey, {
|
|
216
|
+
policyVersion: input.policyVersion,
|
|
217
|
+
learningMode: input.learningMode,
|
|
218
|
+
specification: asJsonObject(input.specification),
|
|
219
|
+
rewardSpec: input.rewardSpec,
|
|
220
|
+
parentVersionId: input.parentVersionId,
|
|
221
|
+
rationale: input.rationale,
|
|
222
|
+
}, actor)));
|
|
223
|
+
server.registerTool("create_decision_context", {
|
|
224
|
+
title: "Create T2K Decision Context",
|
|
225
|
+
description: "Freeze current state, objective, constraints, authority, policy binding, and learning contract.",
|
|
226
|
+
inputSchema: {
|
|
227
|
+
contextKey: z.string().min(1),
|
|
228
|
+
question: z.string().min(1),
|
|
229
|
+
decisionType: z.string().min(1),
|
|
230
|
+
stateSnapshot: jsonObjectSchema,
|
|
231
|
+
objective: jsonObjectSchema,
|
|
232
|
+
constraints: z.array(z.unknown()).optional(),
|
|
233
|
+
requiredAuthority: jsonObjectSchema.optional(),
|
|
234
|
+
learningContract: jsonObjectSchema,
|
|
235
|
+
},
|
|
236
|
+
outputSchema,
|
|
237
|
+
annotations: mutationAnnotations,
|
|
238
|
+
}, protectedTool(logger, (input) => lifecycle.createDecisionContext({
|
|
239
|
+
contextKey: input.contextKey,
|
|
240
|
+
question: input.question,
|
|
241
|
+
decisionType: input.decisionType,
|
|
242
|
+
stateSnapshot: asJsonObject(input.stateSnapshot),
|
|
243
|
+
objective: asJsonObject(input.objective),
|
|
244
|
+
constraints: input.constraints,
|
|
245
|
+
requiredAuthority: input.requiredAuthority
|
|
246
|
+
? asJsonObject(input.requiredAuthority)
|
|
247
|
+
: undefined,
|
|
248
|
+
learningContract: input.learningContract,
|
|
249
|
+
}, actor)));
|
|
250
|
+
server.registerTool("compute_recommendation", {
|
|
251
|
+
title: "Compute T2K recommendation",
|
|
252
|
+
description: "Run the policy frozen in a Decision Context. Human authorization remains outside MCP.",
|
|
253
|
+
inputSchema: {
|
|
254
|
+
contextKey: z.string().min(1),
|
|
255
|
+
recommendationKey: z.string().min(1),
|
|
256
|
+
behaviorProbability: z.number().positive().max(1).optional(),
|
|
257
|
+
rationale: z.string().optional(),
|
|
258
|
+
reasoningTrace: jsonObjectSchema.optional(),
|
|
259
|
+
},
|
|
260
|
+
outputSchema,
|
|
261
|
+
annotations: mutationAnnotations,
|
|
262
|
+
}, protectedTool(logger, (input) => lifecycle.recommend(input.contextKey, {
|
|
263
|
+
recommendationKey: input.recommendationKey,
|
|
264
|
+
behaviorProbability: input.behaviorProbability,
|
|
265
|
+
rationale: input.rationale,
|
|
266
|
+
reasoningTrace: input.reasoningTrace
|
|
267
|
+
? asJsonObject(input.reasoningTrace)
|
|
268
|
+
: undefined,
|
|
269
|
+
}, actor)));
|
|
270
|
+
server.registerTool("open_decision_episode", {
|
|
271
|
+
title: "Open T2K decision episode",
|
|
272
|
+
description: "Open an episode from an already human-authorized decision and its immutable context binding.",
|
|
273
|
+
inputSchema: {
|
|
274
|
+
episodeKey: z.string().min(1),
|
|
275
|
+
contextKey: z.string().min(1),
|
|
276
|
+
authorizedDecisionId: z.string().min(1),
|
|
277
|
+
policyVersionId: z.string().optional(),
|
|
278
|
+
externalEffect: z.boolean().optional(),
|
|
279
|
+
},
|
|
280
|
+
outputSchema,
|
|
281
|
+
annotations: mutationAnnotations,
|
|
282
|
+
}, protectedTool(logger, (input) => lifecycle.openEpisode(input, actor)));
|
|
283
|
+
server.registerTool("record_execution_receipt", {
|
|
284
|
+
title: "Record T2K execution receipt",
|
|
285
|
+
description: "Record connector evidence, reconciliation state, and rollback contract for an open episode.",
|
|
286
|
+
inputSchema: {
|
|
287
|
+
episodeId: z.string().min(1),
|
|
288
|
+
receiptKey: z.string().min(1),
|
|
289
|
+
idempotencyKey: z.string().min(1),
|
|
290
|
+
connectorRef: z.string().min(1),
|
|
291
|
+
externalTransactionId: z.string().nullable().optional(),
|
|
292
|
+
outcome: z.enum(["succeeded", "failed", "unknown"]),
|
|
293
|
+
requestHash: z.string().min(1),
|
|
294
|
+
responseHash: z.string().min(1),
|
|
295
|
+
response: jsonObjectSchema.optional(),
|
|
296
|
+
error: jsonObjectSchema.optional(),
|
|
297
|
+
rollbackContract: jsonObjectSchema.optional(),
|
|
298
|
+
reconciliationStatus: z.enum(["pending", "reconciled", "mismatch"]),
|
|
299
|
+
receivedAt: z.string().optional(),
|
|
300
|
+
},
|
|
301
|
+
outputSchema,
|
|
302
|
+
annotations: mutationAnnotations,
|
|
303
|
+
}, protectedTool(logger, (input) => lifecycle.recordExecutionReceipt(input.episodeId, {
|
|
304
|
+
receiptKey: input.receiptKey,
|
|
305
|
+
idempotencyKey: input.idempotencyKey,
|
|
306
|
+
connectorRef: input.connectorRef,
|
|
307
|
+
externalTransactionId: input.externalTransactionId,
|
|
308
|
+
outcome: input.outcome,
|
|
309
|
+
requestHash: input.requestHash,
|
|
310
|
+
responseHash: input.responseHash,
|
|
311
|
+
response: input.response ? asJsonObject(input.response) : undefined,
|
|
312
|
+
error: input.error ? asJsonObject(input.error) : undefined,
|
|
313
|
+
rollbackContract: input.rollbackContract
|
|
314
|
+
? asJsonObject(input.rollbackContract)
|
|
315
|
+
: undefined,
|
|
316
|
+
reconciliationStatus: input.reconciliationStatus,
|
|
317
|
+
receivedAt: input.receivedAt,
|
|
318
|
+
}, actor)));
|
|
319
|
+
server.registerTool("record_observation", {
|
|
320
|
+
title: "Record T2K observation",
|
|
321
|
+
description: "Attach provenance-bearing outcome evidence to an open decision episode.",
|
|
322
|
+
inputSchema: {
|
|
323
|
+
episodeId: z.string().min(1),
|
|
324
|
+
measureRef: z.string().min(1),
|
|
325
|
+
observedValue: z.unknown(),
|
|
326
|
+
baselineValue: z.unknown().nullable().optional(),
|
|
327
|
+
unit: z.string().nullable().optional(),
|
|
328
|
+
observationWindow: z.string().min(1),
|
|
329
|
+
sourceRefs: z.array(z.string().min(1)).optional(),
|
|
330
|
+
provenance: jsonObjectSchema.optional(),
|
|
331
|
+
attributionConfidence: z.number().min(0).max(1).nullable().optional(),
|
|
332
|
+
observedAt: z.string().min(1),
|
|
333
|
+
},
|
|
334
|
+
outputSchema,
|
|
335
|
+
annotations: mutationAnnotations,
|
|
336
|
+
}, protectedTool(logger, (input) => lifecycle.recordObservation(input.episodeId, {
|
|
337
|
+
measureRef: input.measureRef,
|
|
338
|
+
observedValue: input.observedValue,
|
|
339
|
+
baselineValue: input.baselineValue,
|
|
340
|
+
unit: input.unit,
|
|
341
|
+
observationWindow: input.observationWindow,
|
|
342
|
+
sourceRefs: input.sourceRefs,
|
|
343
|
+
provenance: input.provenance
|
|
344
|
+
? asJsonObject(input.provenance)
|
|
345
|
+
: undefined,
|
|
346
|
+
attributionConfidence: input.attributionConfidence,
|
|
347
|
+
observedAt: input.observedAt,
|
|
348
|
+
}, actor)));
|
|
349
|
+
server.registerTool("assess_reward", {
|
|
350
|
+
title: "Assess T2K reward",
|
|
351
|
+
description: "Compute the frozen reward contract from recorded observations; the caller cannot provide a verdict.",
|
|
352
|
+
inputSchema: {
|
|
353
|
+
episodeId: z.string().min(1),
|
|
354
|
+
assessmentKey: z.string().min(1),
|
|
355
|
+
attribution: jsonObjectSchema.optional(),
|
|
356
|
+
},
|
|
357
|
+
outputSchema,
|
|
358
|
+
annotations: mutationAnnotations,
|
|
359
|
+
}, protectedTool(logger, (input) => lifecycle.assessReward(input.episodeId, {
|
|
360
|
+
assessmentKey: input.assessmentKey,
|
|
361
|
+
attribution: input.attribution
|
|
362
|
+
? asJsonObject(input.attribution)
|
|
363
|
+
: undefined,
|
|
364
|
+
}, actor)));
|
|
365
|
+
server.registerTool("propose_learning_candidate", {
|
|
366
|
+
title: "Propose T2K learning candidate",
|
|
367
|
+
description: "Propose a policy candidate from closed training episodes. Evaluation and promotion remain human-only outside MCP.",
|
|
368
|
+
inputSchema: {
|
|
369
|
+
candidateKey: z.string().min(1),
|
|
370
|
+
policyKey: z.string().min(1),
|
|
371
|
+
sourcePolicyVersionId: z.string().min(1),
|
|
372
|
+
proposedPolicyVersion: z.string().min(1),
|
|
373
|
+
proposedSpecification: jsonObjectSchema,
|
|
374
|
+
proposedRewardSpec: z.array(z.unknown()).min(1).optional(),
|
|
375
|
+
trainingEpisodeIds: z.array(z.string().min(1)).min(1),
|
|
376
|
+
rationale: z.string().min(1),
|
|
377
|
+
},
|
|
378
|
+
outputSchema,
|
|
379
|
+
annotations: mutationAnnotations,
|
|
380
|
+
}, protectedTool(logger, (input) => lifecycle.createCandidate({
|
|
381
|
+
candidateKey: input.candidateKey,
|
|
382
|
+
policyKey: input.policyKey,
|
|
383
|
+
sourcePolicyVersionId: input.sourcePolicyVersionId,
|
|
384
|
+
proposedPolicyVersion: input.proposedPolicyVersion,
|
|
385
|
+
proposedSpecification: asJsonObject(input.proposedSpecification),
|
|
386
|
+
proposedRewardSpec: input.proposedRewardSpec,
|
|
387
|
+
trainingEpisodeIds: input.trainingEpisodeIds,
|
|
388
|
+
rationale: input.rationale,
|
|
389
|
+
}, actor)));
|
|
390
|
+
}
|
|
391
|
+
export async function createT2kMcpRuntime(options = {}) {
|
|
392
|
+
if (options.lifecycle && options.connectionString) {
|
|
393
|
+
throw new Error("Provide lifecycle or connectionString, not both.");
|
|
394
|
+
}
|
|
395
|
+
const allowMutations = options.allowMutations ?? false;
|
|
396
|
+
const actorId = options.actorId?.trim();
|
|
397
|
+
const hasLifecycleConfiguration = Boolean(options.lifecycle || options.connectionString);
|
|
398
|
+
if (allowMutations && !hasLifecycleConfiguration) {
|
|
399
|
+
throw new Error("Mutation tools require a configured Postgres lifecycle.");
|
|
400
|
+
}
|
|
401
|
+
if (allowMutations && !actorId) {
|
|
402
|
+
throw new Error("Mutation tools require a fixed actorId.");
|
|
403
|
+
}
|
|
404
|
+
if (options.autoMigrate && !hasLifecycleConfiguration) {
|
|
405
|
+
throw new Error("autoMigrate requires a configured Postgres lifecycle.");
|
|
406
|
+
}
|
|
407
|
+
const logger = options.logger ?? (() => undefined);
|
|
408
|
+
const ownsLifecycle = Boolean(options.connectionString);
|
|
409
|
+
const lifecycle = options.lifecycle ??
|
|
410
|
+
(options.connectionString
|
|
411
|
+
? new PostgresReferenceLifecycle({
|
|
412
|
+
connectionString: options.connectionString,
|
|
413
|
+
applicationName: "t2k-mcp",
|
|
414
|
+
})
|
|
415
|
+
: undefined);
|
|
416
|
+
if (options.autoMigrate && lifecycle) {
|
|
417
|
+
try {
|
|
418
|
+
await lifecycle.migrate();
|
|
419
|
+
}
|
|
420
|
+
catch (error) {
|
|
421
|
+
if (ownsLifecycle) {
|
|
422
|
+
try {
|
|
423
|
+
await lifecycle.close();
|
|
424
|
+
}
|
|
425
|
+
catch (closeError) {
|
|
426
|
+
logger("T2K MCP could not close its failed migration pool.", closeError);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
throw error;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
const actor = allowMutations
|
|
433
|
+
? {
|
|
434
|
+
actorType: "agent",
|
|
435
|
+
actorId: requireTrimmed(actorId, "actorId"),
|
|
436
|
+
}
|
|
437
|
+
: null;
|
|
438
|
+
const tools = [
|
|
439
|
+
...SEMANTIC_TOOL_NAMES,
|
|
440
|
+
...(lifecycle ? LIFECYCLE_READ_TOOL_NAMES : []),
|
|
441
|
+
...(allowMutations ? LIFECYCLE_MUTATION_TOOL_NAMES : []),
|
|
442
|
+
];
|
|
443
|
+
const capabilities = {
|
|
444
|
+
mode: allowMutations
|
|
445
|
+
? "agent-mutation"
|
|
446
|
+
: lifecycle
|
|
447
|
+
? "lifecycle-read-only"
|
|
448
|
+
: "semantic-only",
|
|
449
|
+
transport: "stdio",
|
|
450
|
+
databaseConfigured: Boolean(lifecycle),
|
|
451
|
+
mutationToolsEnabled: allowMutations,
|
|
452
|
+
actor,
|
|
453
|
+
tools: [...tools],
|
|
454
|
+
omittedHumanGovernanceOperations: [
|
|
455
|
+
...T2K_MCP_HUMAN_GOVERNANCE_OPERATIONS,
|
|
456
|
+
],
|
|
457
|
+
};
|
|
458
|
+
const server = new McpServer({
|
|
459
|
+
name: options.serverName ?? "t2k-mcp",
|
|
460
|
+
version: options.serverVersion ?? T2K_MCP_VERSION,
|
|
461
|
+
});
|
|
462
|
+
server.registerResource("t2k-capabilities", "t2k://capabilities", {
|
|
463
|
+
title: "T2K MCP capabilities",
|
|
464
|
+
description: "The enabled server mode, tools, configured agent identity, and deliberately omitted human-governance operations.",
|
|
465
|
+
mimeType: "application/json",
|
|
466
|
+
}, async (uri) => ({
|
|
467
|
+
contents: [
|
|
468
|
+
{
|
|
469
|
+
uri: uri.href,
|
|
470
|
+
mimeType: "application/json",
|
|
471
|
+
text: JSON.stringify(capabilities, null, 2),
|
|
472
|
+
},
|
|
473
|
+
],
|
|
474
|
+
}));
|
|
475
|
+
if (lifecycle) {
|
|
476
|
+
server.registerResource("t2k-lifecycle-snapshot", "t2k://lifecycle/snapshot", {
|
|
477
|
+
title: "T2K lifecycle snapshot",
|
|
478
|
+
description: "Current local reference lifecycle state and event-chain verification.",
|
|
479
|
+
mimeType: "application/json",
|
|
480
|
+
}, async (uri) => {
|
|
481
|
+
let body;
|
|
482
|
+
try {
|
|
483
|
+
body = await lifecycle.snapshot();
|
|
484
|
+
}
|
|
485
|
+
catch (error) {
|
|
486
|
+
logger("T2K MCP lifecycle resource read failed.", error);
|
|
487
|
+
body = { error: safeErrorMessage(error) };
|
|
488
|
+
}
|
|
489
|
+
return {
|
|
490
|
+
contents: [
|
|
491
|
+
{
|
|
492
|
+
uri: uri.href,
|
|
493
|
+
mimeType: "application/json",
|
|
494
|
+
text: JSON.stringify(body, null, 2),
|
|
495
|
+
},
|
|
496
|
+
],
|
|
497
|
+
};
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
registerSemanticTools(server, logger);
|
|
501
|
+
if (lifecycle)
|
|
502
|
+
registerLifecycleReadTools(server, lifecycle, logger);
|
|
503
|
+
if (lifecycle && actor) {
|
|
504
|
+
registerLifecycleMutationTools(server, lifecycle, actor, logger);
|
|
505
|
+
}
|
|
506
|
+
let closed = false;
|
|
507
|
+
return {
|
|
508
|
+
server,
|
|
509
|
+
capabilities,
|
|
510
|
+
async close() {
|
|
511
|
+
if (closed)
|
|
512
|
+
return;
|
|
513
|
+
closed = true;
|
|
514
|
+
try {
|
|
515
|
+
await server.close();
|
|
516
|
+
}
|
|
517
|
+
finally {
|
|
518
|
+
if (ownsLifecycle && lifecycle)
|
|
519
|
+
await lifecycle.close();
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE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I;wBACb,QAAQ,EAAE,kBAAkB;wBAC5B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;qBACpC;iBACF;aACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAED,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,IAAI,SAAS;QAAE,0BAA0B,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACrE,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;QACvB,8BAA8B,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,OAAO;QACL,MAAM;QACN,YAAY;QACZ,KAAK,CAAC,KAAK;YACT,IAAI,MAAM;gBAAE,OAAO;YACnB,MAAM,GAAG,IAAI,CAAC;YACd,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;YACvB,CAAC;oBAAS,CAAC;gBACT,IAAI,aAAa,IAAI,SAAS;oBAAE,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;YAC1D,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@t2kai/mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A safe local MCP adapter for the open T2K governed-decision runtime.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"mcp",
|
|
8
|
+
"ontology",
|
|
9
|
+
"decision-intelligence",
|
|
10
|
+
"ai-agents",
|
|
11
|
+
"governance"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://t2k.ai/developers/",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/sigaihealth/t2k-core.git",
|
|
17
|
+
"directory": "packages/mcp"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/sigaihealth/t2k-core/issues"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20.10.0"
|
|
26
|
+
},
|
|
27
|
+
"bin": {
|
|
28
|
+
"t2k-mcp": "dist/cli.js"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js",
|
|
39
|
+
"default": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
"types": "./dist/index.d.ts",
|
|
44
|
+
"scripts": {
|
|
45
|
+
"prebuild": "npm run build --workspace @t2kai/core",
|
|
46
|
+
"build": "rm -rf dist && tsc -p tsconfig.json",
|
|
47
|
+
"prepack": "npm run build",
|
|
48
|
+
"pretypecheck": "npm run build --workspace @t2kai/core",
|
|
49
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
50
|
+
"pretest": "npm run build --workspace @t2kai/core",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"pack:check": "npm pack --dry-run",
|
|
53
|
+
"smoke:package": "node scripts/smoke-package.mjs",
|
|
54
|
+
"release:verify": "node scripts/verify-release-tag.mjs"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
58
|
+
"@t2kai/core": "^0.2.0",
|
|
59
|
+
"zod": "^4.4.3"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/node": "^25.3.5",
|
|
63
|
+
"typescript": "^5.9.3",
|
|
64
|
+
"vitest": "^4.1.10"
|
|
65
|
+
},
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public",
|
|
68
|
+
"provenance": true
|
|
69
|
+
}
|
|
70
|
+
}
|