@opennous/mcp 0.44.0 → 0.44.2
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 +216 -0
- package/package.json +3 -3
- package/src/client.js +2 -2
- package/src/index.js +4 -4
- package/src/server.js +127 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
203
|
+
|
|
204
|
+
Copyright 2026 Nous
|
|
205
|
+
|
|
206
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
207
|
+
you may not use this file except in compliance with the License.
|
|
208
|
+
You may obtain a copy of the License at
|
|
209
|
+
|
|
210
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
211
|
+
|
|
212
|
+
Unless required by applicable law or agreed to in writing, software
|
|
213
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
214
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
215
|
+
See the License for the specific language governing permissions and
|
|
216
|
+
limitations under the License.
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opennous/mcp",
|
|
3
|
-
"version": "0.44.
|
|
3
|
+
"version": "0.44.2",
|
|
4
4
|
"description": "Nous — the Context Graph for AI Agents.",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/NousC/
|
|
8
|
+
"url": "git+https://github.com/NousC/opennous.git",
|
|
9
9
|
"directory": "apps/mcp"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
package/src/client.js
CHANGED
|
@@ -71,8 +71,8 @@ function currentApiUrl() {
|
|
|
71
71
|
export function validateConfig() {
|
|
72
72
|
if (!resolvedEnv("NOUS_API_KEY") && !fileApiKey()) {
|
|
73
73
|
throw new Error(
|
|
74
|
-
"No Nous API key found. Run
|
|
75
|
-
"or set NOUS_API_KEY."
|
|
74
|
+
"No Nous API key found. Run `npx @opennous/cli login` to sign in (or `npx @opennous/cli init` " +
|
|
75
|
+
"to set up from scratch), or set NOUS_API_KEY."
|
|
76
76
|
);
|
|
77
77
|
}
|
|
78
78
|
}
|
package/src/index.js
CHANGED
|
@@ -17,10 +17,10 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
17
17
|
import { validateConfig } from "./client.js";
|
|
18
18
|
import { createServer } from "./server.js";
|
|
19
19
|
|
|
20
|
-
// Advisory only — don't hard-exit if there's no key yet. The user may
|
|
21
|
-
// the
|
|
22
|
-
// key (resolved per-call from env or ~/.nous/config.json)
|
|
23
|
-
// restart.
|
|
20
|
+
// Advisory only — don't hard-exit if there's no key yet. The user may register
|
|
21
|
+
// the MCP first and sign in after (`npx @opennous/cli login`); the server must
|
|
22
|
+
// already be running so the key (resolved per-call from env or ~/.nous/config.json)
|
|
23
|
+
// is picked up without a restart.
|
|
24
24
|
try {
|
|
25
25
|
validateConfig();
|
|
26
26
|
} catch (err) {
|
package/src/server.js
CHANGED
|
@@ -89,9 +89,10 @@ const pct = (c) => `${Math.round((c ?? 0) * 100)}%`;
|
|
|
89
89
|
// Gong/Granola). Returned by get_routing_preferences; the agent writes it into
|
|
90
90
|
// the user's CLAUDE.md (Claude Code) or the user pastes it into claude.ai org
|
|
91
91
|
// preferences. Mirrors the Install page's "short" version.
|
|
92
|
-
const ROUTING_PREFERENCES = `# Nous is this workspace's
|
|
92
|
+
const ROUTING_PREFERENCES = `# Nous is this workspace's Revenue Context Layer
|
|
93
93
|
|
|
94
|
-
Nous is our
|
|
94
|
+
Nous is our Revenue Context Layer for GTM: the pre-computed context every agent reads
|
|
95
|
+
before it acts. Underneath, a context graph resolves every person, conversation, and
|
|
95
96
|
touchpoint across our GTM tool stack into one account record, with each fact's
|
|
96
97
|
confidence and freshness, the full interaction timeline, a 0-100 ICP fit score on
|
|
97
98
|
every account, plus our own ICP, positioning, and pricing. Agents read engineered
|
|
@@ -283,6 +284,19 @@ export function createServer() {
|
|
|
283
284
|
for (const f of rec.facts) lines.push(` [${f.category}] ${f.content}${f.date ? ` (${relAge(f.date)})` : ""}`);
|
|
284
285
|
lines.push("");
|
|
285
286
|
}
|
|
287
|
+
const docs = rec.documents ?? [];
|
|
288
|
+
if (docs.length) {
|
|
289
|
+
// Saved briefs / notes / transcripts kept on the contact — previews only.
|
|
290
|
+
// The agent needs to KNOW these exist so it never reports "no brief on
|
|
291
|
+
// file" when one is saved; the full body is read with search_notes.
|
|
292
|
+
lines.push(`DOCUMENTS (${docs.length} — saved notes & meeting records, read with search_notes):`);
|
|
293
|
+
for (const d of docs) {
|
|
294
|
+
const when = d.date ? ` (${relAge(d.date)})` : "";
|
|
295
|
+
lines.push(` ${d.type.replace(/_/g, " ")}${d.title ? ` · ${d.title}` : ""}${when}`);
|
|
296
|
+
if (d.snippet) lines.push(` ${d.snippet}`);
|
|
297
|
+
}
|
|
298
|
+
lines.push("");
|
|
299
|
+
}
|
|
286
300
|
const claims = Object.values(rec.claims ?? {});
|
|
287
301
|
if (claims.length) {
|
|
288
302
|
lines.push(`ATTRIBUTES (${claims.length}):`);
|
|
@@ -526,6 +540,99 @@ export function createServer() {
|
|
|
526
540
|
}
|
|
527
541
|
);
|
|
528
542
|
|
|
543
|
+
// ===========================================================================
|
|
544
|
+
// TOOL: score — POST /v2/score
|
|
545
|
+
// The thin scoring verb an external list (spreadsheet, Clay column, agent)
|
|
546
|
+
// calls to get Nous's judgment on a row and have it land in the graph. The
|
|
547
|
+
// list stays wherever the user built it; Nous owns the score. Read-mostly:
|
|
548
|
+
// returns the live ICP fit + intent, bootstrap-staking a known-but-unscored
|
|
549
|
+
// row on demand. Cheaper and leaner than get_context on purpose.
|
|
550
|
+
// ===========================================================================
|
|
551
|
+
const scoreOne = (r) => {
|
|
552
|
+
if (!r.resolved) {
|
|
553
|
+
if (r.reason === "ambiguous") {
|
|
554
|
+
const names = (r.candidates || []).map(c => c.name || c.entity_id).join(", ");
|
|
555
|
+
return `ambiguous — several people match${names ? `: ${names}` : ""}. Score by email or LinkedIn URL instead.`;
|
|
556
|
+
}
|
|
557
|
+
return "not in the graph yet — enrich this account first (signals/firmographics), then score.";
|
|
558
|
+
}
|
|
559
|
+
if (!r.scored) return `known, but awaiting enrichment — no scoreable claims yet (${r.entity_id}).`;
|
|
560
|
+
const tier = (r.icp.tier || "").replace(/_/g, " ") || "untiered";
|
|
561
|
+
return `ICP ${r.icp.score}/100 (${tier})${r.icp.fit ? " ✓fit" : ""} · intent ${r.intent.score}/100 ${r.intent.band}` +
|
|
562
|
+
(r.icp.reason ? `\n ${r.icp.reason}` : "");
|
|
563
|
+
};
|
|
564
|
+
server.tool(
|
|
565
|
+
"score",
|
|
566
|
+
"Score a lead against our live ICP model and intent axis, and write the judgment into the graph so " +
|
|
567
|
+
"every other agent reads the same number. This is for scoring a list the user built ELSEWHERE (a " +
|
|
568
|
+
"Google Sheet, a Clay column, a CRM export): the list stays where it is, Nous returns the score. " +
|
|
569
|
+
"Give an email, domain, LinkedIn URL, or entity UUID (or up to 100 at once via `identifiers`). " +
|
|
570
|
+
"Returns ICP fit 0-100 + tier (tier_1/2/3/not_icp, which drives the play) and decaying intent " +
|
|
571
|
+
"0-100 + band. It reads the live score (staking one on demand for a known-but-unscored account); " +
|
|
572
|
+
"the score keeps evolving on its own afterwards. If a row isn't in the graph yet it comes back " +
|
|
573
|
+
"`unknown_identifier` — enrich that account first (signal-scan / a lead-builder), then score.",
|
|
574
|
+
{
|
|
575
|
+
identifier: z.string().optional().describe("One lead — an email, domain, LinkedIn URL, or entity UUID."),
|
|
576
|
+
identifiers: z.array(z.string()).optional().describe("A batch of leads (max 100 per call; loop for a larger list)."),
|
|
577
|
+
intent: z.string().optional().describe("Optional hint about why you're scoring (recorded, does not change the score)."),
|
|
578
|
+
},
|
|
579
|
+
async ({ identifier, identifiers, intent }) => {
|
|
580
|
+
if (Array.isArray(identifiers) && identifiers.length) {
|
|
581
|
+
const r = await post("/v2/score", { identifiers, intent });
|
|
582
|
+
const lines = (r.results || []).map(x => ` ${x.identifier} — ${scoreOne(x)}`);
|
|
583
|
+
const scored = (r.results || []).filter(x => x.scored).length;
|
|
584
|
+
return { content: [{ type: "text", text: `Scored ${scored}/${(r.results || []).length}:\n${lines.join("\n")}` }] };
|
|
585
|
+
}
|
|
586
|
+
const r = await post("/v2/score", { identifier, intent });
|
|
587
|
+
return { content: [{ type: "text", text: `${identifier} — ${scoreOne(r)}` }] };
|
|
588
|
+
}
|
|
589
|
+
);
|
|
590
|
+
|
|
591
|
+
// ===========================================================================
|
|
592
|
+
// TOOL: attach_list — POST /v2/lead-lists/attach
|
|
593
|
+
// Batch-score a list the user built ELSEWHERE (a Google Sheet, a CRM export, a
|
|
594
|
+
// Clay table). One call: create/reuse a Nous list, ingest the rows (entities
|
|
595
|
+
// resolved+deduped), score every row into the graph. The list stays where it
|
|
596
|
+
// is; Nous keeps the roster so the scores stay fresh and agents can read them.
|
|
597
|
+
// ===========================================================================
|
|
598
|
+
server.tool(
|
|
599
|
+
"attach_list",
|
|
600
|
+
"Score a whole list the user built somewhere ELSE — a Google Sheet, a CRM export, a Clay table — " +
|
|
601
|
+
"in one call. Give the rows and Nous creates a lead list, resolves each row to a person/company " +
|
|
602
|
+
"(deduped against everything already in the graph), and scores every one against the live ICP model " +
|
|
603
|
+
"+ intent axis so the judgment lands in the graph for other agents. The spreadsheet stays the user's; " +
|
|
604
|
+
"Nous just owns the score and keeps it fresh. Each row needs an email OR a LinkedIn URL. Rows we don't " +
|
|
605
|
+
"know enough about yet come back `awaiting_enrichment` — run signal-scan / a lead-builder on them, then " +
|
|
606
|
+
"re-attach. Pass `lead_list_id` instead of `name` to add to an existing list. Max 200 rows per call — " +
|
|
607
|
+
"loop for a bigger sheet.",
|
|
608
|
+
{
|
|
609
|
+
name: z.string().optional().describe("Name for the new list (e.g. 'Q3 sheet — inbound'). Omit only when passing lead_list_id."),
|
|
610
|
+
lead_list_id: z.string().optional().describe("Add to an existing list instead of creating one."),
|
|
611
|
+
source: z.string().optional().describe("Where the list came from, e.g. 'google_sheet', 'crm_export' (default 'external')."),
|
|
612
|
+
rows: z.array(z.object({
|
|
613
|
+
email: z.string().optional(),
|
|
614
|
+
linkedin_url: z.string().optional(),
|
|
615
|
+
domain: z.string().optional(),
|
|
616
|
+
company: z.string().optional(),
|
|
617
|
+
name: z.string().optional(),
|
|
618
|
+
}).passthrough()).describe("The list rows. Each needs an email or a linkedin_url."),
|
|
619
|
+
import_duplicates: z.boolean().optional().describe("Force-insert rows already in this list (default false — deduped)."),
|
|
620
|
+
},
|
|
621
|
+
async ({ name, lead_list_id, source, rows, import_duplicates }) => {
|
|
622
|
+
const r = await post("/v2/lead-lists/attach", { name, lead_list_id, source, rows, import_duplicates });
|
|
623
|
+
const head = `Attached ${rows.length} rows to list ${r.lead_list_id} — ` +
|
|
624
|
+
`${r.inserted} new, ${r.duplicate_skipped} already in list. ` +
|
|
625
|
+
`Scored ${r.scored}; ${r.awaiting_enrichment} awaiting enrichment; ${r.unresolved} unresolved.`;
|
|
626
|
+
const top = (r.results || [])
|
|
627
|
+
.filter(x => x.scored)
|
|
628
|
+
.sort((a, b) => (b.icp?.score ?? 0) - (a.icp?.score ?? 0))
|
|
629
|
+
.slice(0, 10)
|
|
630
|
+
.map(x => ` ${x.identifier} — ICP ${x.icp.score} (${(x.icp.tier || "").replace(/_/g, " ")}) · intent ${x.intent.score} ${x.intent.band}`);
|
|
631
|
+
const tail = r.awaiting_enrichment ? `\n\n${r.awaiting_enrichment} rows need enrichment before they can score — run signal-scan or a lead-builder on the list, then re-attach.` : "";
|
|
632
|
+
return { content: [{ type: "text", text: `${head}${top.length ? `\n\nTop scored:\n${top.join("\n")}` : ""}${tail}` }] };
|
|
633
|
+
}
|
|
634
|
+
);
|
|
635
|
+
|
|
529
636
|
// ===========================================================================
|
|
530
637
|
// TOOL: attention — GET /v2/attention
|
|
531
638
|
// What to look at: accounts gone quiet, key facts decayed.
|
|
@@ -757,7 +864,10 @@ export function createServer() {
|
|
|
757
864
|
const lines = [`Documents matching "${question}":`, ""];
|
|
758
865
|
for (const d of r.documents) {
|
|
759
866
|
const when = d.date ? ` [${relAge(d.date)}]` : "";
|
|
760
|
-
|
|
867
|
+
// similarity is null for recency-matched hits (a note too fresh to be
|
|
868
|
+
// embedded yet) — label those "recent" instead of a bogus 0%.
|
|
869
|
+
const match = d.similarity == null ? "recent" : pct(d.similarity);
|
|
870
|
+
lines.push(` ${d.type.replace(/_/g, " ")}${d.title ? ` · ${d.title}` : ""} (${match})${when}`);
|
|
761
871
|
if (d.snippet) lines.push(` ${d.snippet}`);
|
|
762
872
|
lines.push(` (entity_id: ${d.entity_id})`);
|
|
763
873
|
}
|
|
@@ -1046,6 +1156,12 @@ export function createServer() {
|
|
|
1046
1156
|
...imp.map((s) => ` • ${s.section}${s.source_path ? ` ← ${s.source_path}` : ""}`),
|
|
1047
1157
|
];
|
|
1048
1158
|
if (r.skipped?.length) lines.push("", `Skipped (unknown/empty): ${r.skipped.join(", ")}`);
|
|
1159
|
+
// Section-check nudges from the server — the ICP file synced but is missing
|
|
1160
|
+
// canonical sections (buyer, fit, triggers, …). Surface them so the agent
|
|
1161
|
+
// rounds the file out and re-syncs, instead of the gaps passing silently.
|
|
1162
|
+
for (const w of (r.warnings ?? [])) {
|
|
1163
|
+
lines.push("", `⚠ ${w.message}`);
|
|
1164
|
+
}
|
|
1049
1165
|
const sig = r.signals ?? [];
|
|
1050
1166
|
if (r.model_status === "created" && sig.length) {
|
|
1051
1167
|
lines.push("", `Built the ICP scoring model — ${sig.length} signal${sig.length === 1 ? "" : "s"}.`);
|
|
@@ -1095,9 +1211,15 @@ export function createServer() {
|
|
|
1095
1211
|
"No ICP scoring model yet. Sync the user's ICP file with sync_icp first (or build one with " +
|
|
1096
1212
|
"build_icp_model / train_icp_model), then call this to write it back." }] };
|
|
1097
1213
|
}
|
|
1098
|
-
|
|
1214
|
+
// Lift can only be learned from WINS, so a win-less cohort (losses only) is
|
|
1215
|
+
// still seed estimates — don't claim it's "trained on real closed deals".
|
|
1216
|
+
const wonCount = r.calibration?.won ?? 0;
|
|
1217
|
+
const lostCount = r.calibration?.lost ?? 0;
|
|
1218
|
+
const note = wonCount > 0
|
|
1099
1219
|
? "This model is trained on real closed deals (lift + calibration shown)."
|
|
1100
|
-
:
|
|
1220
|
+
: lostCount > 0
|
|
1221
|
+
? `Still seed estimates — ${lostCount} closed-lost recorded but no closed-won yet to learn lift from. Add closed-won with train_icp_model to sharpen it.`
|
|
1222
|
+
: "This model is seeded from the ICP only — add closed deals with train_icp_model to sharpen it.";
|
|
1101
1223
|
return { content: [{ type: "text", text:
|
|
1102
1224
|
`Write the block below into ${r.target_path} with your file editor — replace any existing block ` +
|
|
1103
1225
|
`between the nous:icp markers, or append it if there's none (create the file/section if absent). ` +
|