freshcontext-mcp 0.3.19 → 0.3.20
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/FRESHCONTEXT_SPEC.md +317 -0
- package/METHODOLOGY.md +381 -0
- package/README.md +11 -7
- package/dist/adapters/arxiv.js +2 -1
- package/dist/adapters/changelog.js +4 -2
- package/dist/adapters/finance.js +1 -1
- package/dist/adapters/gdelt.js +1 -1
- package/dist/adapters/gebiz.js +1 -1
- package/dist/adapters/reddit.js +11 -4
- package/dist/adapters/repoSearch.js +1 -1
- package/dist/adapters/secFilings.js +1 -1
- package/dist/core/envelope.js +9 -1
- package/dist/security.js +3 -1
- package/dist/server.js +2 -2
- package/dist/tools/evaluateContext.js +19 -0
- package/docs/CLIENT_SETUP.md +166 -0
- package/docs/CODEX_MCP_USAGE.md +2 -2
- package/docs/CORE_API.md +8 -6
- package/docs/FUTURE_LANES.md +42 -19
- package/docs/HA_PRI_V2_DESIGN.md +7 -1
- package/docs/HA_PRI_V2_PRODUCTION_ENFORCEMENT_PLAN.md +414 -0
- package/docs/RELEASE_INTEGRITY.md +1 -1
- package/docs/SIGNAL_CONTRACT.md +213 -17
- package/package-script-guard.mjs +75 -28
- package/package.json +6 -1
- package/server.json +2 -2
|
@@ -8,6 +8,10 @@ const SUPPORTED_INTENTS = [
|
|
|
8
8
|
"business_due_diligence",
|
|
9
9
|
"medical_literature_triage",
|
|
10
10
|
];
|
|
11
|
+
const MAX_CONTEXT_SIGNALS = 100;
|
|
12
|
+
const MAX_SOURCE_CHARS = 2048;
|
|
13
|
+
const MAX_TITLE_CHARS = 1000;
|
|
14
|
+
const MAX_CONTENT_CHARS = 50000;
|
|
11
15
|
export class EvaluateContextInputError extends Error {
|
|
12
16
|
constructor(message) {
|
|
13
17
|
super(message);
|
|
@@ -20,6 +24,12 @@ function isRecord(value) {
|
|
|
20
24
|
function isIntentProfileId(value) {
|
|
21
25
|
return SUPPORTED_INTENTS.includes(value);
|
|
22
26
|
}
|
|
27
|
+
function assertMaxLength(value, field, maxLength, index) {
|
|
28
|
+
if (typeof value === "string" && value.length > maxLength) {
|
|
29
|
+
const prefix = index === undefined ? "" : `signals[${index}].`;
|
|
30
|
+
throw new EvaluateContextInputError(`${prefix}${field} exceeds maximum length of ${maxLength} characters.`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
23
33
|
function validateSignal(value, index) {
|
|
24
34
|
if (!isRecord(value)) {
|
|
25
35
|
throw new EvaluateContextInputError(`signals[${index}] must be an object.`);
|
|
@@ -27,6 +37,9 @@ function validateSignal(value, index) {
|
|
|
27
37
|
if (typeof value.source !== "string" || value.source.trim().length === 0) {
|
|
28
38
|
throw new EvaluateContextInputError(`signals[${index}].source must be a non-empty string.`);
|
|
29
39
|
}
|
|
40
|
+
assertMaxLength(value.source, "source", MAX_SOURCE_CHARS, index);
|
|
41
|
+
assertMaxLength(value.title, "title", MAX_TITLE_CHARS, index);
|
|
42
|
+
assertMaxLength(value.content, "content", MAX_CONTENT_CHARS, index);
|
|
30
43
|
if ((typeof value.title !== "string" || value.title.trim().length === 0)
|
|
31
44
|
&& (typeof value.content !== "string" || value.content.trim().length === 0)) {
|
|
32
45
|
throw new EvaluateContextInputError(`signals[${index}] must include title or content.`);
|
|
@@ -52,6 +65,12 @@ export function evaluateContextInput(input) {
|
|
|
52
65
|
if (input.signals.length === 0) {
|
|
53
66
|
throw new EvaluateContextInputError("signals must contain at least one candidate context item.");
|
|
54
67
|
}
|
|
68
|
+
if (input.signals.length > MAX_CONTEXT_SIGNALS) {
|
|
69
|
+
throw new EvaluateContextInputError(`signals must contain at most ${MAX_CONTEXT_SIGNALS} candidate context items.`);
|
|
70
|
+
}
|
|
71
|
+
if (input.now !== undefined && Number.isNaN(new Date(input.now).getTime())) {
|
|
72
|
+
throw new EvaluateContextInputError("now must be a valid timestamp string when provided.");
|
|
73
|
+
}
|
|
55
74
|
const signals = input.signals.map(validateSignal);
|
|
56
75
|
const options = input.now ? { now: input.now } : {};
|
|
57
76
|
const evaluations = evaluateSignals(signals, options);
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# FreshContext Client Setup
|
|
2
|
+
|
|
3
|
+
FreshContext is live as an MCP stdio package on npm.
|
|
4
|
+
|
|
5
|
+
Use this guide when connecting Claude Desktop, Codex, or another MCP-compatible client to the published package.
|
|
6
|
+
|
|
7
|
+
## What You Should See
|
|
8
|
+
|
|
9
|
+
FreshContext `0.3.19` exposes:
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
22 tools = evaluate_context + 21 read-only reference adapters
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The primary interface is:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
evaluate_context
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Use it when another retriever, agent, database, note parser, PDF extractor, or local script already has candidate context and needs FreshContext to judge what deserves to reach the model.
|
|
22
|
+
|
|
23
|
+
## Claude Desktop: Published Package
|
|
24
|
+
|
|
25
|
+
Add this to your Claude Desktop config, then restart Claude.
|
|
26
|
+
|
|
27
|
+
macOS:
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
~/Library/Application Support/Claude/claude_desktop_config.json
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Windows:
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
%APPDATA%\Claude\claude_desktop_config.json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Config:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"mcpServers": {
|
|
44
|
+
"freshcontext": {
|
|
45
|
+
"command": "npx",
|
|
46
|
+
"args": ["-y", "freshcontext-mcp@latest"]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If you previously installed an older global package, refresh it:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install -g freshcontext-mcp@latest
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Then this config is also valid when the global npm bin path is visible to Claude:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"mcpServers": {
|
|
63
|
+
"freshcontext": {
|
|
64
|
+
"command": "freshcontext-mcp",
|
|
65
|
+
"args": []
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Codex: Local MCP Config
|
|
72
|
+
|
|
73
|
+
For Codex local MCP config, use the published package through `npx`:
|
|
74
|
+
|
|
75
|
+
```toml
|
|
76
|
+
[mcp_servers.freshcontext]
|
|
77
|
+
command = "npx"
|
|
78
|
+
args = ["-y", "freshcontext-mcp@latest"]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
If you prefer a source checkout while developing FreshContext itself:
|
|
82
|
+
|
|
83
|
+
```toml
|
|
84
|
+
[mcp_servers.freshcontext]
|
|
85
|
+
command = "node"
|
|
86
|
+
args = ["C:\\Users\\YOUR_USERNAME\\path\\to\\freshcontext-mcp\\dist\\server.js"]
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Keep local MCP config files out of git. Do not commit machine-specific paths or credentials.
|
|
90
|
+
|
|
91
|
+
## Source Checkout Setup
|
|
92
|
+
|
|
93
|
+
Use this when contributing to FreshContext itself:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
git clone https://github.com/PrinceGabriel-lgtm/freshcontext-mcp
|
|
97
|
+
cd freshcontext-mcp
|
|
98
|
+
npm install
|
|
99
|
+
npm run build
|
|
100
|
+
npm run smoke:stdio
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Expected smoke result:
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"ok": true,
|
|
108
|
+
"package_version": "0.3.19",
|
|
109
|
+
"server_version": "0.3.19",
|
|
110
|
+
"tool_count": 22
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Remote Worker Boundary
|
|
115
|
+
|
|
116
|
+
The repository also declares a remote Streamable HTTP MCP endpoint:
|
|
117
|
+
|
|
118
|
+
```text
|
|
119
|
+
https://freshcontext-mcp.gimmanuel73.workers.dev/mcp
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Some clients can use `mcp-remote`:
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"mcpServers": {
|
|
127
|
+
"freshcontext-remote": {
|
|
128
|
+
"command": "npx",
|
|
129
|
+
"args": ["-y", "mcp-remote", "https://freshcontext-mcp.gimmanuel73.workers.dev/mcp"]
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The npm/local stdio package remains the safest default client path. The hosted Worker endpoint was verified on 2026-06-11 at `0.3.19 / 22 tools` with `evaluate_context` present and returning decision-first output. Because the Worker is a separate deployment surface, re-run remote verification before claiming future package interfaces are live there.
|
|
136
|
+
|
|
137
|
+
## ChatGPT / OpenAI Connector Boundary
|
|
138
|
+
|
|
139
|
+
Claude and Codex MCP paths are documented now.
|
|
140
|
+
|
|
141
|
+
ChatGPT connector compatibility requires a separate search/fetch compatibility audit before being claimed. Do not assume ChatGPT connector support from Claude/Codex MCP compatibility alone.
|
|
142
|
+
|
|
143
|
+
## Quick Test Prompt
|
|
144
|
+
|
|
145
|
+
After connecting a client, ask it to use `evaluate_context` with this candidate context:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"profile": "academic_research",
|
|
150
|
+
"intent": "citation_check",
|
|
151
|
+
"signals": [
|
|
152
|
+
{
|
|
153
|
+
"title": "Fresh research source",
|
|
154
|
+
"content": "A relevant academic source with a reliable publication date.",
|
|
155
|
+
"source": "https://arxiv.org/abs/2605.12345",
|
|
156
|
+
"source_type": "arxiv",
|
|
157
|
+
"published_at": "2026-05-24T12:00:00.000Z",
|
|
158
|
+
"retrieved_at": "2026-05-24T13:00:00.000Z",
|
|
159
|
+
"semantic_score": 0.94,
|
|
160
|
+
"date_confidence": "high"
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Expected result: decision-first output with a decision, meaning, action, warnings, supporting scores, and a structured FreshContext evaluation JSON block.
|
package/docs/CODEX_MCP_USAGE.md
CHANGED
|
@@ -67,7 +67,7 @@ command = "npx"
|
|
|
67
67
|
args = ["-y", "mcp-remote", "https://freshcontext-mcp.gimmanuel73.workers.dev/mcp"]
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
This remote path was
|
|
70
|
+
This remote path was verified on 2026-06-11 as a live Worker MCP endpoint exposing `0.3.19 / 22 tools`, including `evaluate_context`. That confirms Worker availability and MCP tool discovery. It does not by itself claim Codex Cloud support or guarantee every MCP client can use the remote bridge without its own client-specific setup check.
|
|
71
71
|
|
|
72
72
|
## Verification steps
|
|
73
73
|
|
|
@@ -102,7 +102,7 @@ Expected result: no output and exit code 0.
|
|
|
102
102
|
- Do not place secrets, credentials, registry tokens, npm tokens, GitHub tokens, or Cloudflare tokens in Codex MCP config.
|
|
103
103
|
- Do not read, edit, print, or commit local token files, local environment files, registry credentials, Cloudflare local state, or Wrangler state.
|
|
104
104
|
- Do not commit local Codex config or machine-specific paths.
|
|
105
|
-
- Prefer the local stdio path for
|
|
105
|
+
- Prefer the local stdio path for source-checkout compatibility checks because it is verified by `npm run smoke:stdio`.
|
|
106
106
|
- Do not claim Codex Cloud support unless it is separately tested and documented.
|
|
107
107
|
|
|
108
108
|
## Troubleshooting
|
package/docs/CORE_API.md
CHANGED
|
@@ -76,9 +76,9 @@ The demo reads caller-provided JSON with `profile`, `intent`, and `signals`, the
|
|
|
76
76
|
|
|
77
77
|
These types describe the stable envelope and adapter result contract.
|
|
78
78
|
|
|
79
|
-
## Signal Contract v1
|
|
80
|
-
|
|
81
|
-
Signal Contract v1 is the
|
|
79
|
+
## Signal Contract v1
|
|
80
|
+
|
|
81
|
+
Signal Contract v1 is the current FreshContext input standard: the stable shape for candidate context before it is ranked, wrapped, stored, judged by `evaluate_context`, or passed to an agent workflow.
|
|
82
82
|
|
|
83
83
|
Public exports:
|
|
84
84
|
|
|
@@ -90,9 +90,11 @@ Public exports:
|
|
|
90
90
|
- `SignalContractVersion`
|
|
91
91
|
- `SignalNormalizeOptions`
|
|
92
92
|
|
|
93
|
-
`published_at` is the canonical signal timestamp. `content_date` is accepted as an adapter/envelope compatibility alias. Normalization clears invalid or meaningfully future-dated timestamps, marks failed/error-looking content as `status: "failed"`, clamps `semantic_score` into `0..1`, and records normalization reasons.
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
`published_at` is the canonical signal timestamp. `content_date` is accepted as an adapter/envelope compatibility alias. Normalization clears invalid or meaningfully future-dated timestamps, marks failed/error-looking content as `status: "failed"`, clamps `semantic_score` into `0..1`, and records normalization reasons.
|
|
94
|
+
|
|
95
|
+
Future context signals and control signals are optional future metadata layers, not replacements for Signal Contract v1 and not required public input fields today.
|
|
96
|
+
|
|
97
|
+
See [Signal Contract v1](./SIGNAL_CONTRACT.md).
|
|
96
98
|
|
|
97
99
|
## Source Profiles
|
|
98
100
|
|
package/docs/FUTURE_LANES.md
CHANGED
|
@@ -6,15 +6,16 @@ FreshContext is live today as an integrated MCP/Core package. Future work should
|
|
|
6
6
|
|
|
7
7
|
The current package boundary is documented in [Core / MCP Boundary](./CORE_MCP_BOUNDARY.md). Treat MCP as the first live host over FreshContext Core, not as the whole product identity.
|
|
8
8
|
|
|
9
|
-
## Current Live Boundary
|
|
10
|
-
|
|
11
|
-
Live today:
|
|
12
|
-
|
|
13
|
-
- npm package: `freshcontext-mcp@0.3.19`
|
|
14
|
-
- MCP stdio server
|
|
15
|
-
- `evaluate_context` MCP tool for caller-provided candidate context
|
|
16
|
-
-
|
|
17
|
-
-
|
|
9
|
+
## Current Live Boundary
|
|
10
|
+
|
|
11
|
+
Live today:
|
|
12
|
+
|
|
13
|
+
- npm package: `freshcontext-mcp@0.3.19`
|
|
14
|
+
- MCP stdio server
|
|
15
|
+
- `evaluate_context` MCP tool for caller-provided candidate context
|
|
16
|
+
- Signal Contract v1 as the stable candidate-context input shape
|
|
17
|
+
- 21 read-only reference adapters
|
|
18
|
+
- Core signal evaluation
|
|
18
19
|
- Source Profiles
|
|
19
20
|
- Decision Helper
|
|
20
21
|
- adapter registry metadata
|
|
@@ -29,12 +30,32 @@ Not live today:
|
|
|
29
30
|
- automatic local file, folder, or PDF scanning
|
|
30
31
|
- hosted dashboard or billing
|
|
31
32
|
- hard Ha-Pri v2 production enforcement
|
|
32
|
-
- standalone Core SDK package
|
|
33
|
-
- full adapter ingestion
|
|
34
|
-
|
|
35
|
-
##
|
|
36
|
-
|
|
37
|
-
Goal:
|
|
33
|
+
- standalone Core SDK package
|
|
34
|
+
- full adapter ingestion
|
|
35
|
+
|
|
36
|
+
## Phase 0: Stabilize The Signal Contract
|
|
37
|
+
|
|
38
|
+
Goal:
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
Treat Signal Contract v1 as the stable input boundary for FreshContext.
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Current contract:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
title + content + source + source_type + published_at + retrieved_at + semantic_score
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This is live today. It is not the same thing as future context signals or control signals.
|
|
51
|
+
|
|
52
|
+
Tasks in this lane should document examples, invalid-input behavior, and normalization expectations. Do not expand required fields unless tests prove the new metadata improves decisions.
|
|
53
|
+
|
|
54
|
+
Future context signals, control signals, ingestion quality signals, structure preservation signals, and provenance confidence signals belong to later Decision Layer upgrades. They should remain optional metadata, not public required fields.
|
|
55
|
+
|
|
56
|
+
## Lane 1: Client Setup Reliability
|
|
57
|
+
|
|
58
|
+
Goal:
|
|
38
59
|
|
|
39
60
|
```text
|
|
40
61
|
Make Claude, Codex, and MCP-compatible clients connect reliably to the published package.
|
|
@@ -113,15 +134,17 @@ Hard boundary:
|
|
|
113
134
|
Consent-first design. No automatic folder scanning or background file reading.
|
|
114
135
|
```
|
|
115
136
|
|
|
116
|
-
## Lane 6: Decision Layer Upgrade
|
|
117
|
-
|
|
118
|
-
Goal:
|
|
137
|
+
## Lane 6: Decision Layer Upgrade
|
|
138
|
+
|
|
139
|
+
Goal:
|
|
119
140
|
|
|
120
141
|
```text
|
|
121
142
|
Make decisions more useful without silently changing ranking.
|
|
122
143
|
```
|
|
123
144
|
|
|
124
|
-
Possible inputs include context utility, control signal, future context signal, confidence tiers, and source-profile-specific thresholds.
|
|
145
|
+
Possible inputs include context utility, control signal, future context signal, ingestion quality, structure preservation, provenance confidence, confidence tiers, and source-profile-specific thresholds.
|
|
146
|
+
|
|
147
|
+
These are optional future metadata upgrades on top of Signal Contract v1. They should only be exposed when they make decisions clearer without making the caller-facing contract harder to use.
|
|
125
148
|
|
|
126
149
|
Do not make `utility.score` affect ranking by default without a dedicated ranking policy pass.
|
|
127
150
|
|
package/docs/HA_PRI_V2_DESIGN.md
CHANGED
|
@@ -10,7 +10,13 @@ Ha-Pri v2 is an additive provenance-hardening model for FreshContext Store/Ledge
|
|
|
10
10
|
|
|
11
11
|
The goal is to keep Ha-Pri v1 readable while designing a stronger future signature that binds a row to canonical content, semantic identity, source metadata, timestamps, and engine version.
|
|
12
12
|
|
|
13
|
-
Phase 3-B adds pure Core helper functions and deterministic tests for the v2 model. Phase 3-C adds `examples/ha-pri-v2-example.ts`, a deterministic developer fixture showing `calculateHaPriV2` and `verifyHaPriV2` returning valid, invalid, and unknown verification states. Production Store wiring remains future work. This document does not change the D1 schema, change Worker write paths, migrate old rows, add HMAC secrets, or alter production scoring.
|
|
13
|
+
Phase 3-B adds pure Core helper functions and deterministic tests for the v2 model. Phase 3-C adds `examples/ha-pri-v2-example.ts`, a deterministic developer fixture showing `calculateHaPriV2` and `verifyHaPriV2` returning valid, invalid, and unknown verification states. Production Store wiring remains future work. This document does not change the D1 schema, change Worker write paths, migrate old rows, add HMAC secrets, or alter production scoring.
|
|
14
|
+
|
|
15
|
+
Pass 11-J adds golden test vectors for the pure Core helpers. Ha-Pri v2 golden vectors prove deterministic Core provenance behavior: canonicalization, SHA-256 hashes, signing payload construction, signature generation, and verification status are stable and repeatable. They do not mean Ha-Pri v2 is production-enforced on Worker/D1 reads.
|
|
16
|
+
|
|
17
|
+
Plain SHA-256 provides deterministic integrity and audit checks. HMAC or private-key signing would be needed later for stronger origin-authentication guarantees.
|
|
18
|
+
|
|
19
|
+
Pass 11-K adds a design-only production enforcement plan in `docs/HA_PRI_V2_PRODUCTION_ENFORCEMENT_PLAN.md`. That plan covers the future D1/storage, write-path, read/debug verification, compatibility, backfill, threat model, and rollout path. It does not implement Worker/D1 enforcement.
|
|
14
20
|
|
|
15
21
|
## Current Ha-Pri v1 Audit
|
|
16
22
|
|