freshcontext-mcp 0.1.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/.env.example +8 -0
- package/README.md +71 -0
- package/dist/adapters/github.js +41 -0
- package/dist/adapters/hackernews.js +65 -0
- package/dist/adapters/packageTrends.js +75 -0
- package/dist/adapters/repoSearch.js +54 -0
- package/dist/adapters/scholar.js +51 -0
- package/dist/adapters/yc.js +81 -0
- package/dist/server.js +129 -0
- package/dist/tools/freshnessStamp.js +25 -0
- package/dist/types.js +2 -0
- package/package.json +27 -0
- package/src/adapters/github.ts +50 -0
- package/src/adapters/hackernews.ts +93 -0
- package/src/adapters/packageTrends.ts +104 -0
- package/src/adapters/repoSearch.ts +78 -0
- package/src/adapters/scholar.ts +65 -0
- package/src/adapters/yc.ts +99 -0
- package/src/server.ts +179 -0
- package/src/tools/freshnessStamp.ts +33 -0
- package/src/types.ts +22 -0
- package/start-server.bat +2 -0
- package/tsconfig.json +17 -0
- package/worker/package-lock.json +3578 -0
- package/worker/package.json +19 -0
- package/worker/src/worker.ts +162 -0
- package/worker/tsconfig.json +12 -0
- package/worker/wrangler.jsonc +10 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { FreshContext, AdapterResult, ExtractOptions } from "../types.js";
|
|
2
|
+
|
|
3
|
+
export function stampFreshness(
|
|
4
|
+
result: AdapterResult,
|
|
5
|
+
options: ExtractOptions,
|
|
6
|
+
adapter: string
|
|
7
|
+
): FreshContext {
|
|
8
|
+
return {
|
|
9
|
+
content: result.raw.slice(0, options.maxLength ?? 8000),
|
|
10
|
+
source_url: options.url,
|
|
11
|
+
content_date: result.content_date,
|
|
12
|
+
retrieved_at: new Date().toISOString(),
|
|
13
|
+
freshness_confidence: result.freshness_confidence,
|
|
14
|
+
adapter,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function formatForLLM(ctx: FreshContext): string {
|
|
19
|
+
const dateInfo = ctx.content_date
|
|
20
|
+
? `Published: ${ctx.content_date}`
|
|
21
|
+
: "Publish date: unknown";
|
|
22
|
+
|
|
23
|
+
return [
|
|
24
|
+
`[FRESHCONTEXT]`,
|
|
25
|
+
`Source: ${ctx.source_url}`,
|
|
26
|
+
`${dateInfo}`,
|
|
27
|
+
`Retrieved: ${ctx.retrieved_at}`,
|
|
28
|
+
`Confidence: ${ctx.freshness_confidence}`,
|
|
29
|
+
`---`,
|
|
30
|
+
ctx.content,
|
|
31
|
+
`[/FRESHCONTEXT]`,
|
|
32
|
+
].join("\n");
|
|
33
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Core data types for freshcontext-mcp
|
|
2
|
+
|
|
3
|
+
export interface FreshContext {
|
|
4
|
+
content: string;
|
|
5
|
+
source_url: string;
|
|
6
|
+
content_date: string | null; // When the content was originally published
|
|
7
|
+
retrieved_at: string; // When WE fetched it (always now)
|
|
8
|
+
freshness_confidence: "high" | "medium" | "low";
|
|
9
|
+
adapter: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ExtractOptions {
|
|
13
|
+
url: string;
|
|
14
|
+
prompt?: string; // What specifically to look for
|
|
15
|
+
maxLength?: number; // Truncate content to this length
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface AdapterResult {
|
|
19
|
+
raw: string;
|
|
20
|
+
content_date: string | null;
|
|
21
|
+
freshness_confidence: "high" | "medium" | "low";
|
|
22
|
+
}
|
package/start-server.bat
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"rootDir": "src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"resolveJsonModule": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*"],
|
|
16
|
+
"exclude": ["node_modules", "dist", "tests"]
|
|
17
|
+
}
|