Skip to content

Commit 85e5eb0

Browse files
committed
fix(mcp): render full detailed recall metadata
1 parent 01ccfa1 commit 85e5eb0

3 files changed

Lines changed: 6 additions & 13 deletions

File tree

‎docs/METADATA_BEHAVIOR.md‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ on memories. It is intentionally a product/runtime spec, not an experiment note.
2323
on the caller path.
2424
- The MCP server's `json` recall format passes the raw response through, so it
2525
exposes the full metadata object. The MCP `detailed` format renders a
26-
size-capped `Metadata:` line (single-line JSON truncated to 300 characters
27-
with a trailing ellipsis) plus an `Updated:` line when present, and omits the
28-
metadata line entirely for empty or missing metadata. The `text` and `items`
29-
formats do not include metadata.
26+
full `Metadata:` line as single-line JSON plus an `Updated:` line when
27+
present, and omits the metadata line entirely for empty or missing metadata.
28+
The `text` and `items` formats do not include metadata.
3029
- Final scoring can use metadata terms as weak evidence for candidates that are
3130
already present from another channel.
3231

‎mcp-sse-server/server.js‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const DEFAULT_UPSTREAM_MAX_RETRIES = 2;
1919
const DEFAULT_HEALTH_TIMEOUT_MS = 5000;
2020
const DEFAULT_HEALTH_PROBE_INTERVAL_MS = 30000;
2121
const TRANSIENT_STATUS_CODES = new Set([408, 429, 502, 503, 504]);
22-
const DETAILED_METADATA_MAX_CHARS = 300;
2322

2423
function readIntEnv(name, fallback) {
2524
const raw = process.env[name];
@@ -391,10 +390,7 @@ export function formatRecallAsItems(results, { detailed = false } = {}) {
391390
metaJson = '';
392391
}
393392
if (metaJson && metaJson !== '{}') {
394-
const capped = metaJson.length > DETAILED_METADATA_MAX_CHARS
395-
? `${metaJson.slice(0, DETAILED_METADATA_MAX_CHARS)}…`
396-
: metaJson;
397-
lines.push(`Metadata: ${capped}`);
393+
lines.push(`Metadata: ${metaJson}`);
398394
}
399395
}
400396
if (score !== undefined) lines.push(`Score: ${score.toFixed(3)}`);

‎mcp-sse-server/test/server.test.js‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ test("formatRecallAsItems supports detailed output including relations", () => {
125125
assert.ok(!compact.includes("Metadata:"));
126126
});
127127

128-
test("formatRecallAsItems detailed output caps metadata size and omits empty metadata", () => {
128+
test("formatRecallAsItems detailed output renders full metadata and omits empty metadata", () => {
129129
const bigMetadata = { notes: "x".repeat(400) };
130130
const results = [
131131
{
@@ -144,9 +144,7 @@ test("formatRecallAsItems detailed output caps metadata size and omits empty met
144144
const metadataLine = big.split("\n").find(line => line.startsWith("Metadata: "));
145145
assert.ok(metadataLine, "expected a Metadata line for oversized metadata");
146146
const rendered = metadataLine.slice("Metadata: ".length);
147-
assert.ok(rendered.endsWith("…"));
148-
assert.equal(rendered.length, 301); // 300 chars + ellipsis
149-
assert.equal(rendered.slice(0, 300), JSON.stringify(bigMetadata).slice(0, 300));
147+
assert.equal(rendered, JSON.stringify(bigMetadata));
150148

151149
assert.ok(!empty.includes("Metadata:"));
152150
assert.ok(!none.includes("Metadata:"));

0 commit comments

Comments
 (0)