freshcontext-mcp 0.3.0 → 0.3.1

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/add-cache.cjs ADDED
@@ -0,0 +1,86 @@
1
+ const fs = require('fs');
2
+ let content = fs.readFileSync('./worker/src/worker.ts', 'utf8');
3
+
4
+ // Tools that need withCache wrapping (github already done)
5
+ // For each: find the async handler start and add withCache open
6
+ // Then find the corresponding catch line and add the closing
7
+
8
+ const tools = [
9
+ { name: 'extract_hackernews', adapter: 'hackernews', input: 'url' },
10
+ { name: 'extract_scholar', adapter: 'scholar', input: 'url' },
11
+ { name: 'extract_yc', adapter: 'yc', input: 'url' },
12
+ { name: 'search_repos', adapter: 'reposearch', input: 'query' },
13
+ { name: 'package_trends', adapter: 'packagetrends', input: 'packages' },
14
+ { name: 'extract_reddit', adapter: 'reddit', input: 'url' },
15
+ { name: 'extract_producthunt', adapter: 'producthunt', input: 'url' },
16
+ { name: 'extract_finance', adapter: 'finance', input: 'url' },
17
+ { name: 'search_jobs', adapter: 'jobs', input: 'query' },
18
+ { name: 'extract_landscape', adapter: 'landscape', input: 'topic' },
19
+ ];
20
+
21
+ // We'll work line-by-line for precision
22
+ const lines = content.split('\n');
23
+ const result = [];
24
+ let i = 0;
25
+
26
+ while (i < lines.length) {
27
+ const line = lines[i];
28
+
29
+ // Check if this line closes a tool handler that needs wrapping
30
+ // Pattern: " } catch (err: any) { return ..." followed by " });"
31
+ // We add " }); // end withCache" before the closing });
32
+ if (
33
+ line.match(/^\s+\} catch \(err: any\) \{ return \{ content/) &&
34
+ lines[i + 1] && lines[i + 1].trim() === '});' &&
35
+ !(lines[i + 1].includes('end withCache'))
36
+ ) {
37
+ result.push(line);
38
+ result.push(' }); // end withCache');
39
+ i++;
40
+ continue;
41
+ }
42
+
43
+ result.push(line);
44
+ i++;
45
+ }
46
+
47
+ content = result.join('\n');
48
+
49
+ // Now add the withCache OPEN for each tool
50
+ // Pattern to find: the }, async ({ INPUT }) => {\n try {
51
+ // for each tool, but only if not already wrapped
52
+
53
+ for (const tool of tools) {
54
+ // Build a specific marker string that is unique per tool
55
+ // Look for the line: " }, async ({ url/query/etc }) => {"
56
+ // followed by next non-empty content being " try {"
57
+ // We replace " try {" with " return withCache(...); try {"
58
+
59
+ // Find the tool's registerTool call, then find the first "try {" after it
60
+ const toolMarker = `server.registerTool("${tool.name}"`;
61
+ const idx = content.indexOf(toolMarker);
62
+ if (idx === -1) { console.log('Tool not found: ' + tool.name); continue; }
63
+
64
+ // From that position, find the first " try {" that is NOT already preceded by withCache
65
+ const afterTool = content.slice(idx);
66
+ const tryIdx = afterTool.indexOf('\n try {');
67
+ if (tryIdx === -1) { console.log('No try block for: ' + tool.name); continue; }
68
+
69
+ // Check if withCache is already there (look 200 chars before the try)
70
+ const beforeTry = afterTool.slice(Math.max(0, tryIdx - 200), tryIdx);
71
+ if (beforeTry.includes('withCache')) {
72
+ console.log('Already wrapped: ' + tool.name);
73
+ continue;
74
+ }
75
+
76
+ // Insert the withCache line before " try {"
77
+ const absoluteIdx = idx + tryIdx;
78
+ content = content.slice(0, absoluteIdx) +
79
+ `\n return withCache("${tool.adapter}", ${tool.input}, env.CACHE, async () => {` +
80
+ content.slice(absoluteIdx);
81
+
82
+ console.log('Wrapped: ' + tool.name);
83
+ }
84
+
85
+ fs.writeFileSync('./worker/src/worker.ts', content, 'utf8');
86
+ console.log('\nAll done. Lines: ' + content.split('\n').length);
package/package.json CHANGED
@@ -1,51 +1,51 @@
1
- {
2
- "name": "freshcontext-mcp",
3
- "mcpName": "io.github.PrinceGabriel-lgtm/freshcontext",
4
- "version": "0.3.0",
5
- "description": "Real-time web extraction MCP server with freshness timestamps for AI agents",
6
- "keywords": [
7
- "mcp",
8
- "mcp-server",
9
- "ai-agents",
10
- "llm",
11
- "freshness",
12
- "web-scraping",
13
- "github-analytics",
14
- "hackernews",
15
- "yc",
16
- "typescript",
17
- "context",
18
- "model-context-protocol"
19
- ],
20
- "homepage": "https://github.com/PrinceGabriel-lgtm/freshcontext-mcp",
21
- "repository": {
22
- "type": "git",
23
- "url": "https://github.com/PrinceGabriel-lgtm/freshcontext-mcp.git"
24
- },
25
- "license": "MIT",
26
- "type": "module",
27
- "main": "dist/server.js",
28
- "bin": {
29
- "freshcontext-mcp": "dist/server.js"
30
- },
31
- "scripts": {
32
- "build": "tsc",
33
- "dev": "tsx watch src/server.ts",
34
- "start": "node dist/server.js",
35
- "inspect": "npx @modelcontextprotocol/inspector tsx src/server.ts",
36
- "test": "jest"
37
- },
38
- "dependencies": {
39
- "@modelcontextprotocol/sdk": "^1.0.0",
40
- "playwright": "^1.44.0",
41
- "zod": "^3.23.0",
42
- "dotenv": "^16.4.0"
43
- },
44
- "devDependencies": {
45
- "@types/node": "^20.0.0",
46
- "tsx": "^4.0.0",
47
- "typescript": "^5.4.0",
48
- "jest": "^29.0.0",
49
- "@types/jest": "^29.0.0"
50
- }
51
- }
1
+ {
2
+ "name": "freshcontext-mcp",
3
+ "mcpName": "io.github.PrinceGabriel-lgtm/freshcontext",
4
+ "version": "0.3.1",
5
+ "description": "Real-time web extraction MCP server with freshness timestamps for AI agents",
6
+ "keywords": [
7
+ "mcp",
8
+ "mcp-server",
9
+ "ai-agents",
10
+ "llm",
11
+ "freshness",
12
+ "web-scraping",
13
+ "github-analytics",
14
+ "hackernews",
15
+ "yc",
16
+ "typescript",
17
+ "context",
18
+ "model-context-protocol"
19
+ ],
20
+ "homepage": "https://github.com/PrinceGabriel-lgtm/freshcontext-mcp",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/PrinceGabriel-lgtm/freshcontext-mcp.git"
24
+ },
25
+ "license": "MIT",
26
+ "type": "module",
27
+ "main": "dist/server.js",
28
+ "bin": {
29
+ "freshcontext-mcp": "dist/server.js"
30
+ },
31
+ "scripts": {
32
+ "build": "tsc",
33
+ "dev": "tsx watch src/server.ts",
34
+ "start": "node dist/server.js",
35
+ "inspect": "npx @modelcontextprotocol/inspector tsx src/server.ts",
36
+ "test": "jest"
37
+ },
38
+ "dependencies": {
39
+ "@modelcontextprotocol/sdk": "^1.0.0",
40
+ "playwright": "^1.44.0",
41
+ "zod": "^3.23.0",
42
+ "dotenv": "^16.4.0"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "^20.0.0",
46
+ "tsx": "^4.0.0",
47
+ "typescript": "^5.4.0",
48
+ "jest": "^29.0.0",
49
+ "@types/jest": "^29.0.0"
50
+ }
51
+ }
package/server.json CHANGED
@@ -6,14 +6,14 @@
6
6
  "url": "https://github.com/PrinceGabriel-lgtm/freshcontext-mcp",
7
7
  "source": "github"
8
8
  },
9
- "version": "0.1.7",
9
+ "version": "0.3.1",
10
10
  "website_url": "https://freshcontext-site.pages.dev",
11
11
  "packages": [
12
12
  {
13
13
  "registry_type": "npm",
14
14
  "registry_base_url": "https://registry.npmjs.org",
15
15
  "identifier": "freshcontext-mcp",
16
- "version": "0.1.7",
16
+ "version": "0.3.1",
17
17
  "transport": {
18
18
  "type": "stdio"
19
19
  }