ctxjev-mcp 0.1.3 → 0.1.5
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/dist/server.js +8 -1
- package/dist/server.js.map +1 -1
- package/dist/tools.d.ts +7 -3
- package/dist/tools.js +3 -17
- package/dist/tools.js.map +1 -1
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
1
4
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
5
|
import { pruneHistoryInput, scoreRelevanceInput } from './schemas.js';
|
|
3
6
|
import { pruneHistoryTool, scoreRelevanceTool } from './tools.js';
|
|
7
|
+
// Read from this package's own package.json rather than a hardcoded constant, so the version
|
|
8
|
+
// reported to MCP clients can't silently go stale after the next release the way a literal
|
|
9
|
+
// string would (ctxjev-cli's --version had exactly this bug — see CHANGELOG 0.1.2).
|
|
10
|
+
const VERSION = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '../package.json'), 'utf8')).version;
|
|
4
11
|
export function createServer() {
|
|
5
|
-
const server = new McpServer({ name: 'ctxjev', version:
|
|
12
|
+
const server = new McpServer({ name: 'ctxjev', version: VERSION });
|
|
6
13
|
server.registerTool('score_relevance', {
|
|
7
14
|
description: "Score a batch of AI agent history entries for relevance to a goal, using Jev. Doesn't decide what to do about it — see prune_history for that.",
|
|
8
15
|
inputSchema: scoreRelevanceInput,
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AACrE,OAAO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AAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;IAC/E,CAAC,CACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { type Entry
|
|
1
|
+
import { type Entry } from 'ctxjev-core';
|
|
2
|
+
/**
|
|
3
|
+
* Plain functions wrapping ctxjev-core, kept independent of the MCP framework so they're
|
|
4
|
+
* testable without spinning up a server. src/server.ts adapts these into MCP tool handlers.
|
|
5
|
+
*/
|
|
2
6
|
export type ScoreRelevanceArgs = {
|
|
3
7
|
goal: string;
|
|
4
8
|
entries: Entry[];
|
|
@@ -6,7 +10,7 @@ export type ScoreRelevanceArgs = {
|
|
|
6
10
|
};
|
|
7
11
|
export declare function scoreRelevanceTool({ goal, entries, recencyWeight }: ScoreRelevanceArgs): Promise<{
|
|
8
12
|
scored: import("ctxjev-core").ScoredEntry[];
|
|
9
|
-
usage: JevUsage;
|
|
13
|
+
usage: import("ctxjev-core").JevUsage;
|
|
10
14
|
}>;
|
|
11
15
|
export type PruneHistoryArgs = ScoreRelevanceArgs & {
|
|
12
16
|
dropBelow?: number;
|
|
@@ -15,5 +19,5 @@ export type PruneHistoryArgs = ScoreRelevanceArgs & {
|
|
|
15
19
|
export declare function pruneHistoryTool({ goal, entries, recencyWeight, dropBelow, summarizeBelow }: PruneHistoryArgs): Promise<{
|
|
16
20
|
decisions: import("ctxjev-core").PruneDecision[];
|
|
17
21
|
savings: import("ctxjev-core").SavingsReport;
|
|
18
|
-
usage: JevUsage;
|
|
22
|
+
usage: import("ctxjev-core").JevUsage;
|
|
19
23
|
}>;
|
package/dist/tools.js
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
import { DEFAULT_POLICY, pruneContext, scoreEntries, summarizeSavings } from 'ctxjev-core';
|
|
2
|
-
/**
|
|
3
|
-
* Plain functions wrapping ctxjev-core, kept independent of the MCP framework so they're
|
|
4
|
-
* testable without spinning up a server. src/server.ts adapts these into MCP tool handlers.
|
|
5
|
-
*/
|
|
6
|
-
function newUsageAccumulator() {
|
|
7
|
-
const usage = { inputTokens: 0, outputTokens: 0 };
|
|
8
|
-
return {
|
|
9
|
-
usage,
|
|
10
|
-
onUsage: (u) => {
|
|
11
|
-
usage.inputTokens += u.inputTokens;
|
|
12
|
-
usage.outputTokens += u.outputTokens;
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
}
|
|
1
|
+
import { DEFAULT_POLICY, createUsageAccumulator, pruneContext, scoreEntries, summarizeSavings } from 'ctxjev-core';
|
|
16
2
|
export async function scoreRelevanceTool({ goal, entries, recencyWeight }) {
|
|
17
|
-
const { usage, onUsage } =
|
|
3
|
+
const { usage, onUsage } = createUsageAccumulator();
|
|
18
4
|
const scored = await scoreEntries(entries, goal, recencyWeight ?? DEFAULT_POLICY.recencyWeight, { onUsage });
|
|
19
5
|
return { scored, usage };
|
|
20
6
|
}
|
|
@@ -24,7 +10,7 @@ export async function pruneHistoryTool({ goal, entries, recencyWeight, dropBelow
|
|
|
24
10
|
summarizeBelow: summarizeBelow ?? DEFAULT_POLICY.summarizeBelow,
|
|
25
11
|
recencyWeight: recencyWeight ?? DEFAULT_POLICY.recencyWeight,
|
|
26
12
|
};
|
|
27
|
-
const { usage, onUsage } =
|
|
13
|
+
const { usage, onUsage } = createUsageAccumulator();
|
|
28
14
|
const decisions = await pruneContext(entries, goal, policy, { onUsage });
|
|
29
15
|
const savings = summarizeSavings(entries, decisions);
|
|
30
16
|
return { decisions, savings, usage };
|
package/dist/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mapp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posing ctxjev's Jev-based context scoring/pruning as tools for any MCP-capable agent host.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
42
42
|
"zod": "^4.6.5",
|
|
43
|
-
"ctxjev-core": "0.1.
|
|
43
|
+
"ctxjev-core": "0.1.5"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "^22",
|