@atrib/recall 0.2.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 +190 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +200 -0
- package/dist/index.js.map +1 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
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 made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
48
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
51
|
+
or written communication sent to the Licensor or its representatives,
|
|
52
|
+
including but not limited to communication on electronic mailing lists,
|
|
53
|
+
source code control systems, and issue tracking systems that are managed
|
|
54
|
+
by, or on behalf of, the Licensor for the purpose of discussing and
|
|
55
|
+
improving the Work, but excluding communication that is conspicuously
|
|
56
|
+
marked or otherwise designated in writing by the copyright owner as
|
|
57
|
+
"Not a Contribution."
|
|
58
|
+
|
|
59
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
60
|
+
whom a Contribution has been received by the Licensor and subsequently
|
|
61
|
+
incorporated within the Work.
|
|
62
|
+
|
|
63
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
68
|
+
Work and such Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
(except as stated in this section) patent license to make, have made,
|
|
74
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
75
|
+
where such license applies only to those patent claims licensable
|
|
76
|
+
by such Contributor that are necessarily infringed by their
|
|
77
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
78
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
79
|
+
institute patent litigation against any entity (including a cross-claim
|
|
80
|
+
or counterclaim in a lawsuit) alleging that the Work or a Contribution
|
|
81
|
+
incorporated within the Work constitutes direct or contributory patent
|
|
82
|
+
infringement, then any patent licenses granted to You under this License
|
|
83
|
+
for that Work shall terminate as of the date such litigation is filed.
|
|
84
|
+
|
|
85
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
86
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
87
|
+
modifications, and in Source or Object form, provided that You
|
|
88
|
+
meet the following conditions:
|
|
89
|
+
|
|
90
|
+
(a) You must give any other recipients of the Work or Derivative Works
|
|
91
|
+
a copy of this License; and
|
|
92
|
+
|
|
93
|
+
(b) You must cause any modified files to carry prominent notices
|
|
94
|
+
stating that You changed the files; and
|
|
95
|
+
|
|
96
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
97
|
+
that You distribute, all copyright, patent, trademark, and
|
|
98
|
+
attribution notices from the Source form of the Work,
|
|
99
|
+
excluding those notices that do not pertain to any part of
|
|
100
|
+
the Derivative Works; and
|
|
101
|
+
|
|
102
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
103
|
+
distribution, You must include a readable copy of the attribution
|
|
104
|
+
notices contained within such NOTICE file, in at least one
|
|
105
|
+
of the following places: within a NOTICE text file distributed
|
|
106
|
+
as part of the Derivative Works; within the Source form or
|
|
107
|
+
documentation, if provided along with the Derivative Works; or,
|
|
108
|
+
within a display generated by the Derivative Works, if and
|
|
109
|
+
wherever such third-party notices normally appear. The contents
|
|
110
|
+
of the NOTICE file are for informational purposes only and
|
|
111
|
+
do not modify the License. You may add Your own attribution
|
|
112
|
+
notices within Derivative Works that You distribute, alongside
|
|
113
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
114
|
+
that such additional attribution notices cannot be construed
|
|
115
|
+
as modifying the License.
|
|
116
|
+
|
|
117
|
+
You may add Your own license statement for Your modifications and
|
|
118
|
+
may provide additional grant of rights to use, modify, or distribute
|
|
119
|
+
those modifications in accordance with this License.
|
|
120
|
+
|
|
121
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
122
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
123
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
124
|
+
this License, without any additional terms or conditions.
|
|
125
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
126
|
+
the terms of any separate license agreement you may have executed
|
|
127
|
+
with Licensor regarding such Contributions.
|
|
128
|
+
|
|
129
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
130
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
131
|
+
except as required for reasonable and customary use in describing the
|
|
132
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
133
|
+
|
|
134
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
135
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
136
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
137
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
138
|
+
implied, including, without limitation, any warranties or conditions
|
|
139
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
140
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
141
|
+
appropriateness of using or reproducing the Work and assume any
|
|
142
|
+
risks associated with Your exercise of permissions under this License.
|
|
143
|
+
|
|
144
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
145
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
146
|
+
unless required by applicable law (such as deliberate and grossly
|
|
147
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
148
|
+
liable to You for damages, including any direct, indirect, special,
|
|
149
|
+
incidental, or exemplary damages of any character arising as a
|
|
150
|
+
result of this License or out of the use or inability to use the
|
|
151
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
152
|
+
work stoppage, computer failure or malfunction, or all other
|
|
153
|
+
commercial damages or losses), even if such Contributor has been
|
|
154
|
+
advised of the possibility of such damages.
|
|
155
|
+
|
|
156
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
157
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
158
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
159
|
+
or other liability obligations and/or rights consistent with this
|
|
160
|
+
License. However, in accepting such obligations, You may act only
|
|
161
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
162
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
163
|
+
defend, and hold each Contributor harmless for any liability
|
|
164
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
165
|
+
of your accepting any such warranty or additional liability.
|
|
166
|
+
|
|
167
|
+
END OF TERMS AND CONDITIONS
|
|
168
|
+
|
|
169
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
170
|
+
|
|
171
|
+
To apply the Apache License to your work, attach the following
|
|
172
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
173
|
+
replaced with your own identifying information. (Don't include
|
|
174
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
175
|
+
comment syntax for the file format in question. Also, an optional
|
|
176
|
+
"Statement of Purpose" appears after the copyright notice.
|
|
177
|
+
|
|
178
|
+
Copyright 2025-2026 Atrib contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
189
|
+
implied. See the License for the specific language governing
|
|
190
|
+
permissions and limitations under the License.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import type { AtribRecord } from '@atrib/mcp';
|
|
3
|
+
export declare function loadRecords(path: string): AtribRecord[];
|
|
4
|
+
interface RecallArgs {
|
|
5
|
+
context_id?: string;
|
|
6
|
+
event_type?: 'tool_call' | 'transaction';
|
|
7
|
+
limit?: number;
|
|
8
|
+
offset?: number;
|
|
9
|
+
/**
|
|
10
|
+
* When true (the default), the response omits signature/content_id/
|
|
11
|
+
* chain_root/spec_version. Set verbose=true to include them.
|
|
12
|
+
*/
|
|
13
|
+
compact?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* When true (the default), the response includes only records whose
|
|
16
|
+
* Ed25519 signature verified locally. Set include_unverified=true to also
|
|
17
|
+
* include tampered/unverified records (always with signature_verified=false
|
|
18
|
+
* so the agent can decide).
|
|
19
|
+
*/
|
|
20
|
+
include_unverified?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The shape returned to the agent. Each record is annotated with
|
|
24
|
+
* signature_verified — true if the local Ed25519 signature check passed.
|
|
25
|
+
* In compact mode the heavy fields (signature, content_id, chain_root,
|
|
26
|
+
* spec_version) are dropped; the verified status is preserved.
|
|
27
|
+
*/
|
|
28
|
+
type RecallRecordCompact = {
|
|
29
|
+
event_type: AtribRecord['event_type'];
|
|
30
|
+
context_id: string;
|
|
31
|
+
creator_key: string;
|
|
32
|
+
timestamp: number;
|
|
33
|
+
signature_verified: boolean;
|
|
34
|
+
session_token?: string;
|
|
35
|
+
};
|
|
36
|
+
type RecallRecordFull = AtribRecord & {
|
|
37
|
+
signature_verified: boolean;
|
|
38
|
+
};
|
|
39
|
+
export interface RecallResult {
|
|
40
|
+
total: number;
|
|
41
|
+
returned: number;
|
|
42
|
+
/**
|
|
43
|
+
* Count of records dropped because their Ed25519 signature did not verify.
|
|
44
|
+
* Always 0 when include_unverified=true was passed.
|
|
45
|
+
*/
|
|
46
|
+
filtered_out_by_verification: number;
|
|
47
|
+
record_file: string;
|
|
48
|
+
log_origin: string;
|
|
49
|
+
pagination_caveat: string;
|
|
50
|
+
records: RecallRecordFull[] | RecallRecordCompact[];
|
|
51
|
+
}
|
|
52
|
+
export declare function recall(args: RecallArgs, recordFile?: string): Promise<RecallResult>;
|
|
53
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* @atrib/recall — recall_my_attribution_history MCP server.
|
|
5
|
+
*
|
|
6
|
+
* Exposes a single tool to the host agent: recall_my_attribution_history.
|
|
7
|
+
* The tool reads the local signed-record jsonl mirror that an @atrib/mcp-wrap
|
|
8
|
+
* wrapper persists (~/.atrib/records/<wrapper-name>-<agent>.jsonl per spec §5.9
|
|
9
|
+
* D062), VERIFIES the Ed25519 signature on each record before returning it,
|
|
10
|
+
* and tags every entry with signature_verified so the agent can distinguish
|
|
11
|
+
* provable past from tampered or partial mirror state.
|
|
12
|
+
*
|
|
13
|
+
* Trust scope: signature verification is local-only. A passing signature_verified
|
|
14
|
+
* proves the record was signed by the named creator_key; it does NOT prove the
|
|
15
|
+
* record was committed to log.atrib.dev. To confirm log inclusion, the caller
|
|
16
|
+
* should fetch the inclusion proof from the log API.
|
|
17
|
+
*
|
|
18
|
+
* Configuration via environment variables:
|
|
19
|
+
* ATRIB_RECORD_FILE — path to the jsonl mirror.
|
|
20
|
+
* Default: ~/.atrib/records/mcp-wrap-claude-code.jsonl
|
|
21
|
+
* ATRIB_LOG_ORIGIN — origin used in human-readable messages.
|
|
22
|
+
* Default: log.atrib.dev
|
|
23
|
+
*/
|
|
24
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
25
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
26
|
+
import { verifyRecord, EVENT_TYPE_TOOL_CALL_URI, EVENT_TYPE_TRANSACTION_URI, } from '@atrib/mcp';
|
|
27
|
+
// Short-form event_type names accepted by the recall MCP schema map onto
|
|
28
|
+
// their atrib-normative URI form (spec §1.2.4). Records sign the URI form
|
|
29
|
+
// per §1.4.5 + isValidEventTypeUri; without this mapping, a recall caller
|
|
30
|
+
// passing `event_type: 'tool_call'` would silently get zero results because
|
|
31
|
+
// the raw equality compare against `r.event_type` would never match the URI.
|
|
32
|
+
const EVENT_TYPE_SHORT_TO_URI = {
|
|
33
|
+
tool_call: EVENT_TYPE_TOOL_CALL_URI,
|
|
34
|
+
transaction: EVENT_TYPE_TRANSACTION_URI,
|
|
35
|
+
};
|
|
36
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
37
|
+
import { homedir } from 'node:os';
|
|
38
|
+
import { join } from 'node:path';
|
|
39
|
+
import { z } from 'zod';
|
|
40
|
+
const ATRIB_RECORD_FILE = process.env.ATRIB_RECORD_FILE ?? join(homedir(), '.atrib', 'records', 'mcp-wrap-claude-code.jsonl');
|
|
41
|
+
const ATRIB_LOG_ORIGIN = process.env.ATRIB_LOG_ORIGIN ?? 'log.atrib.dev';
|
|
42
|
+
export function loadRecords(path) {
|
|
43
|
+
if (!existsSync(path))
|
|
44
|
+
return [];
|
|
45
|
+
const out = [];
|
|
46
|
+
const raw = readFileSync(path, 'utf8');
|
|
47
|
+
for (const line of raw.split('\n')) {
|
|
48
|
+
const trimmed = line.trim();
|
|
49
|
+
if (!trimmed)
|
|
50
|
+
continue;
|
|
51
|
+
try {
|
|
52
|
+
const parsed = JSON.parse(trimmed);
|
|
53
|
+
// Light shape check: require the load-bearing fields. Anything missing
|
|
54
|
+
// these is malformed jsonl from an older wrapper version; skip silently.
|
|
55
|
+
if (parsed.spec_version &&
|
|
56
|
+
parsed.event_type &&
|
|
57
|
+
parsed.context_id &&
|
|
58
|
+
parsed.creator_key &&
|
|
59
|
+
parsed.chain_root &&
|
|
60
|
+
parsed.signature) {
|
|
61
|
+
out.push(parsed);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// Malformed line; skip.
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
async function annotateVerification(records) {
|
|
71
|
+
return Promise.all(records.map(async (r) => {
|
|
72
|
+
let ok = false;
|
|
73
|
+
try {
|
|
74
|
+
ok = await verifyRecord(r);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
ok = false;
|
|
78
|
+
}
|
|
79
|
+
return { ...r, signature_verified: ok };
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
function compactify(records) {
|
|
83
|
+
return records.map((r) => {
|
|
84
|
+
const out = {
|
|
85
|
+
event_type: r.event_type,
|
|
86
|
+
context_id: r.context_id,
|
|
87
|
+
creator_key: r.creator_key,
|
|
88
|
+
timestamp: r.timestamp,
|
|
89
|
+
signature_verified: r.signature_verified,
|
|
90
|
+
};
|
|
91
|
+
if (r.session_token)
|
|
92
|
+
out.session_token = r.session_token;
|
|
93
|
+
return out;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
export async function recall(args, recordFile = ATRIB_RECORD_FILE) {
|
|
97
|
+
// Defaults: compact=true (small responses) and include_unverified=false
|
|
98
|
+
// (no tampered records). The verbose+include-tampered combo is opt-in.
|
|
99
|
+
// Rationale: a poorly-written agent that doesn't check signature_verified
|
|
100
|
+
// would otherwise treat tampered records as provable. Default to safe.
|
|
101
|
+
const compact = args.compact !== false;
|
|
102
|
+
const includeUnverified = args.include_unverified === true;
|
|
103
|
+
const all = loadRecords(recordFile);
|
|
104
|
+
let filtered = all;
|
|
105
|
+
if (args.context_id)
|
|
106
|
+
filtered = filtered.filter((r) => r.context_id === args.context_id);
|
|
107
|
+
if (args.event_type) {
|
|
108
|
+
// Schema accepts short form ('tool_call'|'transaction'); records carry
|
|
109
|
+
// the URI form. Normalize before comparison; pass URIs through as-is so
|
|
110
|
+
// a forward-compatible caller passing the URI directly still matches.
|
|
111
|
+
const targetUri = EVENT_TYPE_SHORT_TO_URI[args.event_type] ?? args.event_type;
|
|
112
|
+
filtered = filtered.filter((r) => r.event_type === targetUri);
|
|
113
|
+
}
|
|
114
|
+
// Newest first — the agent typically wants its most-recent provable
|
|
115
|
+
// actions, not the genesis of the log.
|
|
116
|
+
filtered.sort((a, b) => b.timestamp - a.timestamp);
|
|
117
|
+
const offset = Math.max(0, args.offset ?? 0);
|
|
118
|
+
const limit = Math.max(1, Math.min(200, args.limit ?? 25));
|
|
119
|
+
const page = filtered.slice(offset, offset + limit);
|
|
120
|
+
let verified = await annotateVerification(page);
|
|
121
|
+
// Apply verification filter post-paging so `total` reflects the unfiltered
|
|
122
|
+
// count (matches user expectation of "how many records exist that match
|
|
123
|
+
// your context_id+event_type filters?"). filtered_out distinguishes the
|
|
124
|
+
// verification-rejection count.
|
|
125
|
+
let filteredOutByVerification = 0;
|
|
126
|
+
if (!includeUnverified) {
|
|
127
|
+
const before = verified.length;
|
|
128
|
+
verified = verified.filter((r) => r.signature_verified === true);
|
|
129
|
+
filteredOutByVerification = before - verified.length;
|
|
130
|
+
}
|
|
131
|
+
const records = compact ? compactify(verified) : verified;
|
|
132
|
+
return {
|
|
133
|
+
total: filtered.length,
|
|
134
|
+
returned: verified.length,
|
|
135
|
+
filtered_out_by_verification: filteredOutByVerification,
|
|
136
|
+
record_file: recordFile,
|
|
137
|
+
log_origin: ATRIB_LOG_ORIGIN,
|
|
138
|
+
pagination_caveat: 'offset is not stable when new records are appended. For consistent paging, capture the' +
|
|
139
|
+
' first-page timestamps and re-page using a context_id or event_type filter instead.',
|
|
140
|
+
records,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const server = new McpServer({
|
|
144
|
+
name: 'atrib-recall',
|
|
145
|
+
version: '0.3.0',
|
|
146
|
+
});
|
|
147
|
+
server.registerTool('recall_my_attribution_history', {
|
|
148
|
+
description: "Return signed atrib records from the local mirror — the agent's own past, with each record's " +
|
|
149
|
+
'Ed25519 signature verified locally. By default the response is compact (no signature bytes) and ' +
|
|
150
|
+
'includes only records that passed signature verification — both can be opted out of with ' +
|
|
151
|
+
'compact=false and include_unverified=true respectively. Local signature verification proves ' +
|
|
152
|
+
'"this record was signed by that creator_key"; it does NOT prove log inclusion (fetch a log ' +
|
|
153
|
+
'inclusion proof to confirm). Filter by context_id (specific trace) or event_type ' +
|
|
154
|
+
'(tool_call|transaction); omit filters for cross-trace history. Results are sorted newest-first. ' +
|
|
155
|
+
'Pagination uses offset; new records appended between calls invalidate offset stability — see ' +
|
|
156
|
+
'the pagination_caveat in the response. The filtered_out_by_verification field reports how many ' +
|
|
157
|
+
'records were dropped due to signature failures (always 0 when include_unverified=true).',
|
|
158
|
+
inputSchema: {
|
|
159
|
+
context_id: z
|
|
160
|
+
.string()
|
|
161
|
+
.optional()
|
|
162
|
+
.describe('Optional trace identifier (32 hex chars). Limits results to records signed within this trace. ' +
|
|
163
|
+
'Omit for cross-trace recall.'),
|
|
164
|
+
event_type: z
|
|
165
|
+
.enum(['tool_call', 'transaction'])
|
|
166
|
+
.optional()
|
|
167
|
+
.describe('Optional filter to a single event kind. Most calls leave this unset.'),
|
|
168
|
+
limit: z.number().optional().describe('Page size, default 25, max 200.'),
|
|
169
|
+
offset: z
|
|
170
|
+
.number()
|
|
171
|
+
.optional()
|
|
172
|
+
.describe('Pagination offset, default 0. Note: not stable when new records land between calls — see ' +
|
|
173
|
+
'pagination_caveat in the response.'),
|
|
174
|
+
compact: z
|
|
175
|
+
.boolean()
|
|
176
|
+
.optional()
|
|
177
|
+
.describe('Default true. When true, omit signature/content_id/chain_root/spec_version fields. ' +
|
|
178
|
+
'signature_verified is still included. Set to false (or use the equivalent verbose=true) ' +
|
|
179
|
+
'when you need the full record bytes for re-verification or downstream processing.'),
|
|
180
|
+
include_unverified: z
|
|
181
|
+
.boolean()
|
|
182
|
+
.optional()
|
|
183
|
+
.describe('Default false. When false, records with signature_verified=false are dropped from the ' +
|
|
184
|
+
'response (their count is reported in filtered_out_by_verification). Set to true to ' +
|
|
185
|
+
'include them — useful when investigating tampered or partial mirror state.'),
|
|
186
|
+
},
|
|
187
|
+
}, async (args) => {
|
|
188
|
+
const result = await recall(args);
|
|
189
|
+
return {
|
|
190
|
+
content: [
|
|
191
|
+
{
|
|
192
|
+
type: 'text',
|
|
193
|
+
text: JSON.stringify(result, null, 2),
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
};
|
|
197
|
+
});
|
|
198
|
+
const transport = new StdioServerTransport();
|
|
199
|
+
await server.connect(transport);
|
|
200
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,sCAAsC;AAEtC;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EACL,YAAY,EACZ,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,YAAY,CAAA;AAGnB,yEAAyE;AACzE,0EAA0E;AAC1E,0EAA0E;AAC1E,4EAA4E;AAC5E,6EAA6E;AAC7E,MAAM,uBAAuB,GAA2B;IACtD,SAAS,EAAE,wBAAwB;IACnC,WAAW,EAAE,0BAA0B;CACxC,CAAA;AACD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,CAAC,E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AkB,EAAE,CAAC;aAClB,OAAO,EAAE;aACT,QAAQ,EAAE;aACV,QAAQ,CACP,wFAAwF;YACtF,qFAAqF;YACrF,4EAA4E,CAC/E;KACJ;CACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;IACb,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAkB,CAAC,CAAA;IAC/C,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;aACtC;SACF;KACF,CAAA;AACH,CAAC,CACF,CAAA;AAED,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAA;AAC5C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atrib/recall",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "MCP server for atrib. Lets agents query their own provable past from the local signed-record mirror with per-record signature verification.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"atrib-recall": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
12
|
+
"zod": "^4.3.6",
|
|
13
|
+
"@atrib/mcp": "0.4.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^22.0.0",
|
|
17
|
+
"typescript": "^5.7.0",
|
|
18
|
+
"vitest": "^4.1.5"
|
|
19
|
+
},
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"dev": "tsc --watch",
|
|
30
|
+
"start": "node dist/index.js",
|
|
31
|
+
"test": "vitest run"
|
|
32
|
+
}
|
|
33
|
+
}
|