@atrib/annotate 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/README.md +74 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +96 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +15 -0
- package/package.json +35 -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/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# @atrib/annotate
|
|
2
|
+
|
|
3
|
+
MCP server exposing the `atrib-annotate` tool. Marks a past signed record with importance, a one-line summary, and topics, so future recall can surface what mattered without re-scanning every record flat.
|
|
4
|
+
|
|
5
|
+
Closes the producer-side recall-fidelity gap: an agent reading back its own past loses enormous nuance compared to the agent that signed it. An annotation lets the agent at signing time say "future-self: this one is critical, and here's why in one line", and the graph carries that judgment forward.
|
|
6
|
+
|
|
7
|
+
## Tool
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
mcp__atrib-annotate__atrib-annotate({
|
|
11
|
+
annotates: "sha256:<64-hex>", // REQUIRED: target record_hash
|
|
12
|
+
importance: "critical" | "high" | "medium" | "low" | "noise",
|
|
13
|
+
summary: string, // ≤ 2048 chars; one-line gist
|
|
14
|
+
topics?: string[], // up to 16 lowercase-hyphenated tags
|
|
15
|
+
context_id?: "<32-hex>", // defaults to ATRIB_CONTEXT_ID
|
|
16
|
+
informed_by?: ["sha256:<64-hex>", ...] // optional lineage refs
|
|
17
|
+
})
|
|
18
|
+
→ {
|
|
19
|
+
record_hash: "sha256:<64-hex>", // the new annotation record
|
|
20
|
+
log_index: number | null,
|
|
21
|
+
inclusion_proof: ProofBundle["inclusion_proof"] | null,
|
|
22
|
+
context_id: string,
|
|
23
|
+
warnings: string[]
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Writes
|
|
28
|
+
|
|
29
|
+
Signs an `annotation` record per spec [§1.2.4](https://github.com/creatornader/atrib/blob/main/atrib-spec.md#124-event_type-values) (event_type `0x05`, promoted via [D058](https://github.com/creatornader/atrib/blob/main/DECISIONS.md#d058-promote-annotation-to-atrib-normative-event_type-byte-0x05)) and persists it through the same pipeline `@atrib/emit` uses: same key resolution, same chain composition, same JSONL mirror at `ATRIB_MIRROR_FILE`. A verifier cannot distinguish annotation records signed via this tool from annotation records signed via `@atrib/emit`'s polymorphic surface; the wire format is identical.
|
|
30
|
+
|
|
31
|
+
The graph layer derives an ANNOTATES edge from the new record to the `annotates` target per spec [§3.2.4](https://github.com/creatornader/atrib/blob/main/atrib-spec.md#324-edge-derivation-rules) step 8. Recall pipelines that filter or rank by importance can use this edge to surface the annotation alongside its target.
|
|
32
|
+
|
|
33
|
+
## Behaviors
|
|
34
|
+
|
|
35
|
+
- **Required-field enforcement**: `annotates`, `importance`, and `summary` are required. The Zod schema rejects calls missing any of these before the signing pipeline runs.
|
|
36
|
+
- **Spec validators**: `annotates` is rejected on non-annotation event_types per spec [§1.2.7](https://github.com/creatornader/atrib/blob/main/atrib-spec.md#127-annotates) (the underlying `handleEmit` enforces this; the tool's narrow schema prevents it from happening here).
|
|
37
|
+
- **Env-honoring**: `ATRIB_CONTEXT_ID` is honored as the default `context_id` per [D078](https://github.com/creatornader/atrib/blob/main/DECISIONS.md#d078-mcp-servers-honor-atrib_context_id-env-as-context_id-default) when the caller omits the field.
|
|
38
|
+
- **Multi-producer chain composition**: inherits chain state from the mirror or `ATRIB_CHAIN_TAIL_<context_id>` env per [D067](https://github.com/creatornader/atrib/blob/main/DECISIONS.md#d067-multi-producer-chain-composition-precedence-contract), the same way `@atrib/emit` does.
|
|
39
|
+
- **Graceful degradation**: signing failures surface in `warnings`; never throws to the agent per spec [§5.8](https://github.com/creatornader/atrib/blob/main/atrib-spec.md#58-degradation-contract).
|
|
40
|
+
|
|
41
|
+
## Wire-up
|
|
42
|
+
|
|
43
|
+
Add to your MCP host config (e.g. `~/.claude.json` `mcpServers`):
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"atrib-annotate": {
|
|
48
|
+
"command": "node",
|
|
49
|
+
"args": ["/path/to/atrib-annotate/dist/main.js"]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Or run as a one-off subprocess via `pnpm --filter @atrib/annotate start`.
|
|
55
|
+
|
|
56
|
+
### Env vars (inherited from `@atrib/emit`)
|
|
57
|
+
|
|
58
|
+
- `ATRIB_PRIVATE_KEY` / `ATRIB_KEY_FILE` / macOS Keychain `atrib-creator-<ATRIB_AGENT>` / `ATRIB_OP_REFERENCE`: key resolution chain.
|
|
59
|
+
- `ATRIB_MIRROR_FILE`: JSONL mirror destination (where the signed annotation persists).
|
|
60
|
+
- `ATRIB_AUTOCHAIN_SOURCE`: optional cross-producer chain inheritance source.
|
|
61
|
+
- `ATRIB_LOG_ENDPOINT`: log.atrib.dev override (e.g. for self-hosted log nodes).
|
|
62
|
+
- `ATRIB_CONTEXT_ID`: default context_id per [D078](https://github.com/creatornader/atrib/blob/main/DECISIONS.md#d078-mcp-servers-honor-atrib_context_id-env-as-context_id-default).
|
|
63
|
+
|
|
64
|
+
## Relationship to @atrib/emit
|
|
65
|
+
|
|
66
|
+
`@atrib/annotate` depends on `@atrib/emit` per the package layering documented in [D079](https://github.com/creatornader/atrib/blob/main/DECISIONS.md#d079-the-six-core-cognitive-primitives--atribs-agent-facing-surface). Each is a monomorphic agent-facing tool with one narrow purpose, but the underlying signing, chain composition, and mirror-writing pipeline is shared via `@atrib/emit`'s `handleEmit` export. When the canonical write pipeline evolves (chain-composition fixes, env-honoring extensions, cross-attestation), `@atrib/annotate` inherits the change automatically.
|
|
67
|
+
|
|
68
|
+
## Status
|
|
69
|
+
|
|
70
|
+
Initial scaffold (v0.2.0). Cognitive primitive #2 per [D079](https://github.com/creatornader/atrib/blob/main/DECISIONS.md#d079-the-six-core-cognitive-primitives--atribs-agent-facing-surface). Builds clean against `@atrib/mcp` and `@atrib/emit`'s public exports introduced in `@atrib/emit@0.8.0`. The companion specialized writer `@atrib/revise` covers the contradiction-handling primitive (revision event_type).
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
Apache-2.0.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { type ResolvedKey } from '@atrib/emit';
|
|
3
|
+
export interface AtribAnnotateServer {
|
|
4
|
+
/** Underlying McpServer; expose for testing or composition. */
|
|
5
|
+
mcp: McpServer;
|
|
6
|
+
/** Drain pending submissions (for tests/shutdown). */
|
|
7
|
+
flush(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export interface CreateAtribAnnotateServerOptions {
|
|
10
|
+
/** Override the resolved key (primarily for testing). */
|
|
11
|
+
key?: ResolvedKey;
|
|
12
|
+
/** Override the log endpoint (defaults to env or @atrib/mcp default). */
|
|
13
|
+
logEndpoint?: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Wire up the atrib-annotate MCP server with one `atrib-annotate` tool.
|
|
17
|
+
* Per D079: this is a specialized form of @atrib/emit; the underlying
|
|
18
|
+
* signing pipeline is shared via handleEmit so annotation records are
|
|
19
|
+
* byte-identical regardless of which tool produced them.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createAtribAnnotateServer(options?: CreateAtribAnnotateServerOptions): Promise<AtribAnnotateServer>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// @atrib/annotate MCP server: cognitive primitive #2 of D079.
|
|
2
|
+
//
|
|
3
|
+
// Specialized form of @atrib/emit that narrows the schema to the annotation
|
|
4
|
+
// event_type (spec §1.2.7 / D058). Per D079's package layering: depends on
|
|
5
|
+
// @atrib/emit as the canonical record-signing surface and wraps handleEmit
|
|
6
|
+
// with a narrow Zod schema enforcing the annotation-specific required fields
|
|
7
|
+
// (annotates + importance + summary). The signing + chain composition path
|
|
8
|
+
// is byte-identical to atrib-emit's; a verifier MUST NOT distinguish
|
|
9
|
+
// annotation records signed via this tool from those signed via emit's
|
|
10
|
+
// polymorphic surface.
|
|
11
|
+
//
|
|
12
|
+
// Scope:
|
|
13
|
+
// - One tool: atrib-annotate
|
|
14
|
+
// - Narrow input schema: REQUIRES annotates (sha256:<64-hex>), importance, summary
|
|
15
|
+
// - One key per process (same identity as the wrapper + atrib-emit)
|
|
16
|
+
// - Persists to the same JSONL mirror convention as atrib-emit
|
|
17
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
import { handleEmit, resolveKey, } from '@atrib/emit';
|
|
20
|
+
import { createSubmissionQueue, EVENT_TYPE_ANNOTATION_URI, } from '@atrib/mcp';
|
|
21
|
+
const SHA256_REF_PATTERN = /^sha256:[0-9a-f]{64}$/;
|
|
22
|
+
const HEX_32_PATTERN = /^[0-9a-f]{32}$/;
|
|
23
|
+
const Importance = z.enum(['critical', 'high', 'medium', 'low', 'noise']);
|
|
24
|
+
const AnnotateInput = z.object({
|
|
25
|
+
annotates: z.string().regex(SHA256_REF_PATTERN).describe("'sha256:<64-hex>' record_hash this annotation describes per spec §1.2.7 / D058. " +
|
|
26
|
+
'REQUIRED. The target record can be any prior record (yours or another agent\'s).'),
|
|
27
|
+
importance: Importance.describe('Felt importance for future-self recall ranking. ' +
|
|
28
|
+
"'critical' (load-bearing decisions, identity claims), " +
|
|
29
|
+
"'high' (worth surfacing in default recall), " +
|
|
30
|
+
"'medium' (general signal), " +
|
|
31
|
+
"'low' (background noting), " +
|
|
32
|
+
"'noise' (deliberately deprioritized for recall)."),
|
|
33
|
+
summary: z.string().min(1).max(2048).describe('One-line semantic gist of the annotation. The recall pipeline reads this verbatim ' +
|
|
34
|
+
'for snippet display; keep it under ~120 chars when possible. ' +
|
|
35
|
+
'Distinct from the annotated record\'s own content — this summary captures what ' +
|
|
36
|
+
'future-you should know about why this record matters.'),
|
|
37
|
+
topics: z.array(z.string().min(1).max(128)).max(16).optional().describe('Optional topic tags. Used by recall_my_attribution_history\'s topics filter. ' +
|
|
38
|
+
'Lowercase-hyphenated convention (e.g. "bug-fix", "design-decision").'),
|
|
39
|
+
context_id: z.string().regex(HEX_32_PATTERN).optional().describe('32-hex context_id. Defaults to process.env.ATRIB_CONTEXT_ID per D078 when omitted; ' +
|
|
40
|
+
'falls back to a fresh genesis context_id if neither is set.'),
|
|
41
|
+
informed_by: z.array(z.string().regex(SHA256_REF_PATTERN)).optional().describe("Array of 'sha256:<64-hex>' record_hashes that informed this annotation. " +
|
|
42
|
+
'Sorted lexicographically before signing per §1.2.5. The `annotates` reference ' +
|
|
43
|
+
'is separate from `informed_by` and need not be duplicated here.'),
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Wire up the atrib-annotate MCP server with one `atrib-annotate` tool.
|
|
47
|
+
* Per D079: this is a specialized form of @atrib/emit; the underlying
|
|
48
|
+
* signing pipeline is shared via handleEmit so annotation records are
|
|
49
|
+
* byte-identical regardless of which tool produced them.
|
|
50
|
+
*/
|
|
51
|
+
export async function createAtribAnnotateServer(options = {}) {
|
|
52
|
+
const key = options.key ?? (await resolveKey());
|
|
53
|
+
const logEndpoint = options.logEndpoint ?? process.env['ATRIB_LOG_ENDPOINT'];
|
|
54
|
+
const queue = createSubmissionQueue(logEndpoint);
|
|
55
|
+
const mcp = new McpServer({ name: 'atrib-annotate', version: '0.1.0' });
|
|
56
|
+
mcp.registerTool('atrib-annotate', {
|
|
57
|
+
description: 'Mark a past record\'s importance and meaning without superseding it. ' +
|
|
58
|
+
'Cognitive primitive #2 of D079; produces a signed annotation event ' +
|
|
59
|
+
'(spec §1.2.7 / D058) that adds an ANNOTATES graph edge to the target. ' +
|
|
60
|
+
'Use when you want future-self or other agents to read back this past ' +
|
|
61
|
+
'record with weighted importance and a one-line gist.',
|
|
62
|
+
inputSchema: AnnotateInput.shape,
|
|
63
|
+
}, async (rawInput) => {
|
|
64
|
+
const input = AnnotateInput.parse(rawInput);
|
|
65
|
+
const result = await handleEmit({
|
|
66
|
+
input: {
|
|
67
|
+
event_type: EVENT_TYPE_ANNOTATION_URI,
|
|
68
|
+
content: {
|
|
69
|
+
annotates: input.annotates,
|
|
70
|
+
importance: input.importance,
|
|
71
|
+
summary: input.summary,
|
|
72
|
+
...(input.topics ? { topics: input.topics } : {}),
|
|
73
|
+
},
|
|
74
|
+
annotates: input.annotates,
|
|
75
|
+
...(input.context_id ? { context_id: input.context_id } : {}),
|
|
76
|
+
...(input.informed_by ? { informed_by: input.informed_by } : {}),
|
|
77
|
+
},
|
|
78
|
+
key,
|
|
79
|
+
queue,
|
|
80
|
+
});
|
|
81
|
+
const out = {
|
|
82
|
+
record_hash: result.record_hash,
|
|
83
|
+
log_index: result.log_index,
|
|
84
|
+
inclusion_proof: result.inclusion_proof,
|
|
85
|
+
context_id: result.context_id,
|
|
86
|
+
warnings: result.warnings,
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
content: [{ type: 'text', text: JSON.stringify(out, null, 2) }],
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
mcp,
|
|
94
|
+
flush: () => queue.flush(),
|
|
95
|
+
};
|
|
96
|
+
}
|
package/dist/main.d.ts
ADDED
package/dist/main.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// atrib-annotate standalone binary. Wires the McpServer to a stdio transport
|
|
3
|
+
// so it can be launched as a subprocess by an MCP host (Claude Code,
|
|
4
|
+
// Claude Desktop, etc.).
|
|
5
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
6
|
+
import { createAtribAnnotateServer } from './index.js';
|
|
7
|
+
async function main() {
|
|
8
|
+
const { mcp } = await createAtribAnnotateServer();
|
|
9
|
+
const transport = new StdioServerTransport();
|
|
10
|
+
await mcp.connect(transport);
|
|
11
|
+
}
|
|
12
|
+
main().catch((e) => {
|
|
13
|
+
console.error('atrib-annotate: fatal', e instanceof Error ? e.stack ?? e.message : String(e));
|
|
14
|
+
process.exit(1);
|
|
15
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atrib/annotate",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "MCP server for atrib. Lets agents mark a past record's importance and meaning. Adds an ANNOTATES graph edge so recall surfaces weighted annotations ahead of flat scans.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"bin": {
|
|
9
|
+
"atrib-annotate": "./dist/main.js"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
13
|
+
"zod": "^3.25.76",
|
|
14
|
+
"@atrib/emit": "0.8.0",
|
|
15
|
+
"@atrib/mcp": "0.6.2"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^22.19.17",
|
|
19
|
+
"tsx": "^4.21.0",
|
|
20
|
+
"typescript": "^5.9.3",
|
|
21
|
+
"vitest": "^3.2.4"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "rm -rf dist && tsc",
|
|
31
|
+
"start": "node dist/main.js",
|
|
32
|
+
"dev": "tsx src/main.ts",
|
|
33
|
+
"test": "vitest run"
|
|
34
|
+
}
|
|
35
|
+
}
|