@4da/mcp-server 3.2.0 → 4.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/LICENSE +21 -0
- package/README.md +234 -62
- package/dist/auth.d.ts +36 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +82 -0
- package/dist/auth.js.map +1 -0
- package/dist/db.d.ts +100 -2
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +707 -1
- package/dist/db.js.map +1 -1
- package/dist/doctor.d.ts +15 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +124 -0
- package/dist/doctor.js.map +1 -0
- package/dist/http-transport.d.ts +25 -0
- package/dist/http-transport.d.ts.map +1 -0
- package/dist/http-transport.js +143 -0
- package/dist/http-transport.js.map +1 -0
- package/dist/index.d.ts +15 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +195 -250
- package/dist/index.js.map +1 -1
- package/dist/live/cache.d.ts +16 -0
- package/dist/live/cache.d.ts.map +1 -0
- package/dist/live/cache.js +61 -0
- package/dist/live/cache.js.map +1 -0
- package/dist/live/hn-fetcher.d.ts +19 -0
- package/dist/live/hn-fetcher.d.ts.map +1 -0
- package/dist/live/hn-fetcher.js +123 -0
- package/dist/live/hn-fetcher.js.map +1 -0
- package/dist/live/index.d.ts +55 -0
- package/dist/live/index.d.ts.map +1 -0
- package/dist/live/index.js +131 -0
- package/dist/live/index.js.map +1 -0
- package/dist/live/osv-scanner.d.ts +19 -0
- package/dist/live/osv-scanner.d.ts.map +1 -0
- package/dist/live/osv-scanner.js +197 -0
- package/dist/live/osv-scanner.js.map +1 -0
- package/dist/live/rate-limiter.d.ts +19 -0
- package/dist/live/rate-limiter.d.ts.map +1 -0
- package/dist/live/rate-limiter.js +52 -0
- package/dist/live/rate-limiter.js.map +1 -0
- package/dist/live/types.d.ts +89 -0
- package/dist/live/types.d.ts.map +1 -0
- package/dist/live/types.js +3 -0
- package/dist/live/types.js.map +1 -0
- package/dist/live/version-resolver.d.ts +11 -0
- package/dist/live/version-resolver.d.ts.map +1 -0
- package/dist/live/version-resolver.js +321 -0
- package/dist/live/version-resolver.js.map +1 -0
- package/dist/live-singleton.d.ts +9 -0
- package/dist/live-singleton.d.ts.map +1 -0
- package/dist/live-singleton.js +14 -0
- package/dist/live-singleton.js.map +1 -0
- package/dist/llm.d.ts +20 -2
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +80 -22
- package/dist/llm.js.map +1 -1
- package/dist/output-manager.d.ts.map +1 -1
- package/dist/output-manager.js +1 -0
- package/dist/output-manager.js.map +1 -1
- package/dist/project-scanner.d.ts +27 -0
- package/dist/project-scanner.d.ts.map +1 -0
- package/dist/project-scanner.js +366 -0
- package/dist/project-scanner.js.map +1 -0
- package/dist/schema-registry.d.ts +31 -13
- package/dist/schema-registry.d.ts.map +1 -1
- package/dist/schema-registry.js +208 -32
- package/dist/schema-registry.js.map +1 -1
- package/dist/schemas/agent-feedback-stats.json +14 -0
- package/dist/schemas/agent-memory.json +49 -0
- package/dist/schemas/agent-session-brief.json +25 -0
- package/dist/schemas/attention-report.json +13 -0
- package/dist/schemas/autophagy-status.json +13 -0
- package/dist/schemas/compound-advantage.json +14 -0
- package/dist/schemas/decision-enforcement.json +22 -0
- package/dist/schemas/decision-memory.json +54 -0
- package/dist/schemas/decision-windows.json +22 -0
- package/dist/schemas/delegation-score.json +18 -0
- package/dist/schemas/developer-dna.json +219 -0
- package/dist/schemas/export-context.json +17 -0
- package/dist/schemas/knowledge-gaps.json +14 -0
- package/dist/schemas/preemption-feed.json +18 -0
- package/dist/schemas/project-health.json +13 -0
- package/dist/schemas/record-agent-feedback.json +28 -0
- package/dist/schemas/reverse-mentions.json +13 -0
- package/dist/schemas/semantic-shifts.json +17 -0
- package/dist/schemas/signal-chains.json +19 -0
- package/dist/schemas/tech-radar.json +23 -0
- package/dist/schemas/trust-summary.json +13 -0
- package/dist/schemas/vulnerability-scan.json +26 -0
- package/dist/schemas/what-should-i-know.json +19 -0
- package/dist/setup.d.ts +18 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +171 -0
- package/dist/setup.js.map +1 -0
- package/dist/tool-dispatch.d.ts +33 -0
- package/dist/tool-dispatch.d.ts.map +1 -0
- package/dist/tool-dispatch.js +87 -0
- package/dist/tool-dispatch.js.map +1 -0
- package/dist/tools/agent-feedback-stats.d.ts +30 -0
- package/dist/tools/agent-feedback-stats.d.ts.map +1 -0
- package/dist/tools/agent-feedback-stats.js +41 -0
- package/dist/tools/agent-feedback-stats.js.map +1 -0
- package/dist/tools/agent-memory.d.ts +94 -0
- package/dist/tools/agent-memory.d.ts.map +1 -0
- package/dist/tools/agent-memory.js +262 -0
- package/dist/tools/agent-memory.js.map +1 -0
- package/dist/tools/agent-session-brief.d.ts +44 -0
- package/dist/tools/agent-session-brief.d.ts.map +1 -0
- package/dist/tools/agent-session-brief.js +179 -0
- package/dist/tools/agent-session-brief.js.map +1 -0
- package/dist/tools/attention-report.d.ts +6 -5
- package/dist/tools/attention-report.d.ts.map +1 -1
- package/dist/tools/attention-report.js +1 -0
- package/dist/tools/attention-report.js.map +1 -1
- package/dist/tools/autophagy-status.d.ts +25 -0
- package/dist/tools/autophagy-status.d.ts.map +1 -0
- package/dist/tools/autophagy-status.js +56 -0
- package/dist/tools/autophagy-status.js.map +1 -0
- package/dist/tools/compound-advantage.d.ts +30 -0
- package/dist/tools/compound-advantage.d.ts.map +1 -0
- package/dist/tools/compound-advantage.js +133 -0
- package/dist/tools/compound-advantage.js.map +1 -0
- package/dist/tools/config-validator.d.ts.map +1 -1
- package/dist/tools/config-validator.js +31 -0
- package/dist/tools/config-validator.js.map +1 -1
- package/dist/tools/context-analysis.d.ts.map +1 -1
- package/dist/tools/context-analysis.js +1 -0
- package/dist/tools/context-analysis.js.map +1 -1
- package/dist/tools/daily-briefing.d.ts.map +1 -1
- package/dist/tools/daily-briefing.js +17 -1
- package/dist/tools/daily-briefing.js.map +1 -1
- package/dist/tools/decision-enforcement.d.ts +59 -0
- package/dist/tools/decision-enforcement.d.ts.map +1 -0
- package/dist/tools/decision-enforcement.js +185 -0
- package/dist/tools/decision-enforcement.js.map +1 -0
- package/dist/tools/decision-memory.d.ts +132 -0
- package/dist/tools/decision-memory.d.ts.map +1 -0
- package/dist/tools/decision-memory.js +345 -0
- package/dist/tools/decision-memory.js.map +1 -0
- package/dist/tools/decision-windows.d.ts +37 -0
- package/dist/tools/decision-windows.d.ts.map +1 -0
- package/dist/tools/decision-windows.js +67 -0
- package/dist/tools/decision-windows.js.map +1 -0
- package/dist/tools/delegation-score.d.ts +34 -0
- package/dist/tools/delegation-score.d.ts.map +1 -0
- package/dist/tools/delegation-score.js +251 -0
- package/dist/tools/delegation-score.js.map +1 -0
- package/dist/tools/developer-dna.d.ts +79 -0
- package/dist/tools/developer-dna.d.ts.map +1 -0
- package/dist/tools/developer-dna.js +378 -0
- package/dist/tools/developer-dna.js.map +1 -0
- package/dist/tools/explain-relevance.d.ts.map +1 -1
- package/dist/tools/explain-relevance.js +1 -0
- package/dist/tools/explain-relevance.js.map +1 -1
- package/dist/tools/export-context.d.ts +23 -6
- package/dist/tools/export-context.d.ts.map +1 -1
- package/dist/tools/export-context.js +58 -14
- package/dist/tools/export-context.js.map +1 -1
- package/dist/tools/get-actionable-signals.d.ts.map +1 -1
- package/dist/tools/get-actionable-signals.js +60 -9
- package/dist/tools/get-actionable-signals.js.map +1 -1
- package/dist/tools/get-context.d.ts.map +1 -1
- package/dist/tools/get-context.js +1 -0
- package/dist/tools/get-context.js.map +1 -1
- package/dist/tools/get-relevant-content.d.ts.map +1 -1
- package/dist/tools/get-relevant-content.js +3 -0
- package/dist/tools/get-relevant-content.js.map +1 -1
- package/dist/tools/index.d.ts +26 -16
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +35 -16
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/knowledge-gaps.d.ts +11 -1
- package/dist/tools/knowledge-gaps.d.ts.map +1 -1
- package/dist/tools/knowledge-gaps.js +9 -3
- package/dist/tools/knowledge-gaps.js.map +1 -1
- package/dist/tools/llm-status.d.ts.map +1 -1
- package/dist/tools/llm-status.js +1 -0
- package/dist/tools/llm-status.js.map +1 -1
- package/dist/tools/muse-context.d.ts +195 -0
- package/dist/tools/muse-context.d.ts.map +1 -0
- package/dist/tools/muse-context.js +284 -0
- package/dist/tools/muse-context.js.map +1 -0
- package/dist/tools/preemption-feed.d.ts +55 -0
- package/dist/tools/preemption-feed.d.ts.map +1 -0
- package/dist/tools/preemption-feed.js +124 -0
- package/dist/tools/preemption-feed.js.map +1 -0
- package/dist/tools/project-health.d.ts +12 -6
- package/dist/tools/project-health.d.ts.map +1 -1
- package/dist/tools/project-health.js +49 -10
- package/dist/tools/project-health.js.map +1 -1
- package/dist/tools/record-agent-feedback.d.ts +46 -0
- package/dist/tools/record-agent-feedback.d.ts.map +1 -0
- package/dist/tools/record-agent-feedback.js +71 -0
- package/dist/tools/record-agent-feedback.js.map +1 -0
- package/dist/tools/record-feedback.d.ts.map +1 -1
- package/dist/tools/record-feedback.js +1 -0
- package/dist/tools/record-feedback.js.map +1 -1
- package/dist/tools/reverse-mentions.d.ts +8 -8
- package/dist/tools/reverse-mentions.d.ts.map +1 -1
- package/dist/tools/reverse-mentions.js +1 -0
- package/dist/tools/reverse-mentions.js.map +1 -1
- package/dist/tools/score-autopsy.d.ts.map +1 -1
- package/dist/tools/score-autopsy.js +1 -0
- package/dist/tools/score-autopsy.js.map +1 -1
- package/dist/tools/semantic-shifts.d.ts +17 -1
- package/dist/tools/semantic-shifts.d.ts.map +1 -1
- package/dist/tools/semantic-shifts.js +1 -0
- package/dist/tools/semantic-shifts.js.map +1 -1
- package/dist/tools/signal-chains.d.ts +14 -7
- package/dist/tools/signal-chains.d.ts.map +1 -1
- package/dist/tools/signal-chains.js +5 -2
- package/dist/tools/signal-chains.js.map +1 -1
- package/dist/tools/source-health.d.ts.map +1 -1
- package/dist/tools/source-health.js +1 -0
- package/dist/tools/source-health.js.map +1 -1
- package/dist/tools/tech-radar.d.ts +38 -0
- package/dist/tools/tech-radar.d.ts.map +1 -0
- package/dist/tools/tech-radar.js +249 -0
- package/dist/tools/tech-radar.js.map +1 -0
- package/dist/tools/topic-connections.d.ts.map +1 -1
- package/dist/tools/topic-connections.js +1 -0
- package/dist/tools/topic-connections.js.map +1 -1
- package/dist/tools/trend-analysis.d.ts.map +1 -1
- package/dist/tools/trend-analysis.js +1 -0
- package/dist/tools/trend-analysis.js.map +1 -1
- package/dist/tools/trust-summary.d.ts +38 -0
- package/dist/tools/trust-summary.d.ts.map +1 -0
- package/dist/tools/trust-summary.js +89 -0
- package/dist/tools/trust-summary.js.map +1 -0
- package/dist/tools/vulnerability-scan.d.ts +89 -0
- package/dist/tools/vulnerability-scan.d.ts.map +1 -0
- package/dist/tools/vulnerability-scan.js +127 -0
- package/dist/tools/vulnerability-scan.js.map +1 -0
- package/dist/tools/what-should-i-know.d.ts +79 -0
- package/dist/tools/what-should-i-know.d.ts.map +1 -0
- package/dist/tools/what-should-i-know.js +376 -0
- package/dist/tools/what-should-i-know.js.map +1 -0
- package/dist/types.d.ts +221 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/package.json +53 -24
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 4DA Systems Pty Ltd (ACN 696 078 841)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,109 +1,292 @@
|
|
|
1
1
|
# @4da/mcp-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@4da/mcp-server)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](https://4da.ai)
|
|
7
|
+
[](https://smithery.ai/server/@4da/mcp-server)
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
**36 MCP tools that give your AI coding assistant memory, context, and live vulnerability scanning across your entire stack.**
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
Your AI writes code without knowing your tech stack, your dependencies, or that the library it just recommended has a critical CVE from yesterday. This MCP server fixes that. It connects Claude Code, Cursor, Copilot, and Windsurf to a local intelligence engine that reads your `Cargo.toml`, `package.json`, `go.mod`, and `requirements.txt` -- then scores content from Hacker News, arXiv, Reddit, GitHub, and 7 other sources against what matters to you. It also scans your dependencies against the OSV.dev vulnerability database in real time.
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
Everything runs locally. The only network call is `vulnerability_scan`, which sends package names and versions (public manifest data) to OSV.dev -- no code, no paths, no personal data. Set `FOURDA_OFFLINE=true` to disable even that.
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
```
|
|
16
|
+
You: "Scan my dependencies for vulnerabilities"
|
|
17
|
+
Claude: [calls vulnerability_scan]
|
|
18
|
+
"Found 3 advisories: serde 1.0.197 has RUSTSEC-2026-0012 (high),
|
|
19
|
+
cookie 0.17.0 has RUSTSEC-2025-0381 (medium), and openssl-sys
|
|
20
|
+
has CVE-2025-4231 (critical). Upgrade paths available for all three."
|
|
21
|
+
|
|
22
|
+
You: "Give me my morning briefing"
|
|
23
|
+
Claude: [calls daily_briefing]
|
|
24
|
+
"3 high-signal items today: Tokio released 1.42 with a breaking change
|
|
25
|
+
in your spawn pattern, a Hacker News post on sqlite-vec hit #1 (your
|
|
26
|
+
primary vector store), and the RFC you bookmarked got merged..."
|
|
27
|
+
|
|
28
|
+
You: "Should I switch from Axios to fetch for this project?"
|
|
29
|
+
Claude: [calls check_decision_alignment, tech_radar, trend_analysis]
|
|
30
|
+
"Your recorded decision AD-014 chose Axios for interceptor support.
|
|
31
|
+
The trend data shows native fetch adoption is accelerating, but your
|
|
32
|
+
codebase has 47 interceptor usages. Recommendation: keep Axios here,
|
|
33
|
+
consider fetch for new greenfield projects..."
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Why This Exists
|
|
37
|
+
|
|
38
|
+
Most MCP servers expose 1-5 tools that wrap a cloud API. This is different:
|
|
39
|
+
|
|
40
|
+
- **36 tools** across 9 categories -- vulnerability scanning, content scoring, decision memory, knowledge gaps, agent autonomy, and more
|
|
41
|
+
- **Live vulnerability scanning** -- checks your dependencies against OSV.dev for known CVEs across npm, Rust, Python, and Go
|
|
42
|
+
- **Codebase-aware** -- reads your actual project files, not just what you tell it
|
|
43
|
+
- **Privacy-first** -- all tools except `vulnerability_scan` read from a local SQLite database with zero network calls. `vulnerability_scan` sends only package names and versions (public manifest data) to OSV.dev
|
|
44
|
+
- **Works offline** -- set `FOURDA_OFFLINE=true` to disable all network calls. The intelligence engine runs entirely on your machine with optional Ollama for local LLM
|
|
45
|
+
- **MIT licensed** -- use it anywhere, fork it, integrate it, build on it
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
### 1. Install the 4DA desktop app
|
|
50
|
+
|
|
51
|
+
The MCP server reads from a local database that the [4DA desktop app](https://4da.ai) builds. Download it, point it at your project directories, and let it run its first scan (~3 minutes).
|
|
52
|
+
|
|
53
|
+
> **[Download 4DA](https://github.com/runyourempire/4DA/releases/latest)** -- Windows, macOS, Linux
|
|
54
|
+
|
|
55
|
+
### 2. Add the MCP server
|
|
56
|
+
|
|
57
|
+
**Auto-setup** (detects your editors and writes config):
|
|
58
|
+
```bash
|
|
59
|
+
npx @4da/mcp-server --setup
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Or add it manually to your editor:
|
|
63
|
+
|
|
64
|
+
<details>
|
|
65
|
+
<summary><b>Claude Code</b></summary>
|
|
12
66
|
|
|
13
67
|
```bash
|
|
14
|
-
|
|
15
|
-
claude mcp add 4da node /path/to/mcp-4da-server/dist/index.js
|
|
68
|
+
claude mcp add 4da -- npx @4da/mcp-server
|
|
16
69
|
```
|
|
70
|
+
</details>
|
|
71
|
+
|
|
72
|
+
<details>
|
|
73
|
+
<summary><b>Cursor / Windsurf</b></summary>
|
|
17
74
|
|
|
18
|
-
|
|
75
|
+
Add to `~/.cursor/mcp.json` or `~/.windsurf/mcp.json`:
|
|
19
76
|
```json
|
|
20
77
|
{
|
|
21
78
|
"mcpServers": {
|
|
22
79
|
"4da": {
|
|
23
|
-
"command": "
|
|
24
|
-
"args": ["/
|
|
25
|
-
"env": {
|
|
26
|
-
"FOURDA_DB_PATH": "/path/to/4da-v3/data/4da.db"
|
|
27
|
-
}
|
|
80
|
+
"command": "npx",
|
|
81
|
+
"args": ["@4da/mcp-server"]
|
|
28
82
|
}
|
|
29
83
|
}
|
|
30
84
|
}
|
|
31
85
|
```
|
|
86
|
+
</details>
|
|
32
87
|
|
|
33
|
-
|
|
88
|
+
<details>
|
|
89
|
+
<summary><b>VS Code (Copilot)</b></summary>
|
|
34
90
|
|
|
35
|
-
Add to
|
|
91
|
+
Add to `~/.vscode/mcp.json`:
|
|
36
92
|
```json
|
|
37
93
|
{
|
|
38
|
-
"
|
|
94
|
+
"servers": {
|
|
39
95
|
"4da": {
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"FOURDA_DB_PATH": "/path/to/4da-v3/data/4da.db"
|
|
44
|
-
}
|
|
96
|
+
"type": "stdio",
|
|
97
|
+
"command": "npx",
|
|
98
|
+
"args": ["@4da/mcp-server"]
|
|
45
99
|
}
|
|
46
100
|
}
|
|
47
101
|
}
|
|
48
102
|
```
|
|
103
|
+
</details>
|
|
49
104
|
|
|
50
|
-
|
|
105
|
+
<details>
|
|
106
|
+
<summary><b>Claude Desktop</b></summary>
|
|
51
107
|
|
|
52
|
-
Add to
|
|
108
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
|
|
53
109
|
```json
|
|
54
110
|
{
|
|
55
111
|
"mcpServers": {
|
|
56
112
|
"4da": {
|
|
57
|
-
"command": "
|
|
58
|
-
"args": ["/
|
|
59
|
-
"env": {
|
|
60
|
-
"FOURDA_DB_PATH": "/path/to/4da-v3/data/4da.db"
|
|
61
|
-
}
|
|
113
|
+
"command": "npx",
|
|
114
|
+
"args": ["@4da/mcp-server"]
|
|
62
115
|
}
|
|
63
116
|
}
|
|
64
117
|
}
|
|
65
118
|
```
|
|
119
|
+
</details>
|
|
66
120
|
|
|
67
|
-
|
|
121
|
+
### 3. Start asking
|
|
68
122
|
|
|
69
|
-
|
|
123
|
+
No configuration needed -- 4DA already knows your stack:
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
"Scan my project for vulnerabilities"
|
|
127
|
+
"What's relevant to my current project?"
|
|
128
|
+
"Any breaking changes in my dependencies?"
|
|
129
|
+
"What are my knowledge gaps?"
|
|
130
|
+
"Why was this article scored so high?"
|
|
131
|
+
"Record a decision: we're using Postgres, not MySQL"
|
|
132
|
+
"Export my Developer DNA"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 4. Verify installation
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
npx @4da/mcp-server --doctor
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## How Scoring Works
|
|
142
|
+
|
|
143
|
+
[4DA](https://4da.ai) scores every piece of content across 5 independent axes. An item needs 2+ confirming signals to pass. Typical rejection rate: **99%+**.
|
|
144
|
+
|
|
145
|
+
| Axis | Signal |
|
|
146
|
+
|------|--------|
|
|
147
|
+
| **Context** | Semantic similarity to your active codebase via local embeddings |
|
|
148
|
+
| **Interest** | Alignment with your declared and inferred topics |
|
|
149
|
+
| **ACE** | Real-time signals from your Git commits and file edits |
|
|
150
|
+
| **Dependency** | Direct matches against packages in your lockfiles |
|
|
151
|
+
| **Learned** | Behavioral patterns from your save/dismiss actions |
|
|
152
|
+
|
|
153
|
+
What survives the gate is genuinely relevant to what you build. The MCP server exposes that intelligence to any AI tool that speaks MCP.
|
|
154
|
+
|
|
155
|
+
## All 36 Tools
|
|
156
|
+
|
|
157
|
+
### Core (4 tools)
|
|
70
158
|
|
|
71
159
|
| Tool | Description |
|
|
72
160
|
|------|-------------|
|
|
73
|
-
| `get_relevant_content` | Filtered content feed
|
|
74
|
-
| `get_context` | Your tech stack, interests,
|
|
75
|
-
| `explain_relevance` |
|
|
76
|
-
| `record_feedback` | Teach 4DA
|
|
161
|
+
| `get_relevant_content` | Filtered content feed -- only items that passed the 5-axis scoring gate |
|
|
162
|
+
| `get_context` | Your profile: tech stack, interests, affinities, ACE-detected topics |
|
|
163
|
+
| `explain_relevance` | Full axis breakdown of why a specific item scored the way it did |
|
|
164
|
+
| `record_feedback` | Teach 4DA what matters -- save, dismiss, or mark items irrelevant |
|
|
77
165
|
|
|
78
|
-
### Intelligence
|
|
166
|
+
### Intelligence (11 tools)
|
|
79
167
|
|
|
80
168
|
| Tool | Description |
|
|
81
169
|
|------|-------------|
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `score_autopsy` | Forensic analysis of any item's
|
|
85
|
-
| `trend_analysis` | Statistical patterns and
|
|
86
|
-
| `context_analysis` | Recommendations to
|
|
170
|
+
| `daily_briefing` | AI-generated executive summary of today's discoveries |
|
|
171
|
+
| `get_actionable_signals` | Classified alerts: security advisories, breaking changes, trending repos |
|
|
172
|
+
| `score_autopsy` | Forensic analysis of how any item's relevance score was computed |
|
|
173
|
+
| `trend_analysis` | Statistical patterns, anomalies, and predictions across your feed |
|
|
174
|
+
| `context_analysis` | Recommendations to sharpen your scoring context |
|
|
87
175
|
| `topic_connections` | Knowledge graph of how your content topics relate |
|
|
176
|
+
| `signal_chains` | Causal chains connecting related events across sources over time |
|
|
177
|
+
| `semantic_shifts` | Detects when topics you follow are shifting in meaning or sentiment |
|
|
178
|
+
| `attention_report` | Where you spend attention vs. where your codebase actually needs it |
|
|
179
|
+
| `trust_summary` | Intelligence quality metrics -- precision, action rate, false positives, preemption wins |
|
|
180
|
+
| `preemption_feed` | Forward-looking alerts on risks, breaking changes, and ecosystem shifts affecting your stack |
|
|
181
|
+
|
|
182
|
+
### Decision Intelligence (3 tools)
|
|
183
|
+
|
|
184
|
+
| Tool | Description |
|
|
185
|
+
|------|-------------|
|
|
186
|
+
| `decision_memory` | Record, query, and enforce architectural decisions across sessions |
|
|
187
|
+
| `tech_radar` | Technology adoption signals from your decisions + content trends |
|
|
188
|
+
| `check_decision_alignment` | Verify if a proposed change aligns with your recorded decisions |
|
|
189
|
+
|
|
190
|
+
### Knowledge & Health (4 tools)
|
|
191
|
+
|
|
192
|
+
| Tool | Description |
|
|
193
|
+
|------|-------------|
|
|
194
|
+
| `knowledge_gaps` | Blind spots -- dependencies you use daily but never read about |
|
|
195
|
+
| `project_health` | Dependency freshness, security advisories, update urgency |
|
|
196
|
+
| `reverse_mentions` | Where your projects are being discussed across monitored sources |
|
|
197
|
+
| `export_context_packet` | Portable context snapshot for session or agent handoff |
|
|
198
|
+
|
|
199
|
+
### Security (1 tool)
|
|
200
|
+
|
|
201
|
+
| Tool | Description |
|
|
202
|
+
|------|-------------|
|
|
203
|
+
| `vulnerability_scan` | Scan dependencies for known CVEs via OSV.dev -- npm, Rust, Python, Go. Zero config. |
|
|
204
|
+
|
|
205
|
+
### Agent Autonomy (6 tools)
|
|
206
|
+
|
|
207
|
+
| Tool | Description |
|
|
208
|
+
|------|-------------|
|
|
209
|
+
| `agent_memory` | Persistent memory that survives across sessions, agents, and editors |
|
|
210
|
+
| `agent_session_brief` | Tailored startup context so agents resume where you left off |
|
|
211
|
+
| `delegation_score` | Autonomy assessment -- should the agent proceed or ask the human? |
|
|
212
|
+
| `record_agent_feedback` | Record whether agent-recommended content was used, rejected, or partially used |
|
|
213
|
+
| `get_agent_feedback_stats` | Statistics on agent recommendation usage -- source usefulness, top items, trends |
|
|
214
|
+
| `what_should_i_know` | Pre-task intelligence briefing -- advisories, decisions, signals, delegation assessment |
|
|
215
|
+
|
|
216
|
+
### Developer Identity (1 tool)
|
|
88
217
|
|
|
89
|
-
|
|
218
|
+
| Tool | Description |
|
|
219
|
+
|------|-------------|
|
|
220
|
+
| `developer_dna` | Your tech identity -- primary stack, dependencies, engagement patterns, blind spots |
|
|
221
|
+
|
|
222
|
+
### Intelligence Metabolism (3 tools)
|
|
223
|
+
|
|
224
|
+
| Tool | Description |
|
|
225
|
+
|------|-------------|
|
|
226
|
+
| `autophagy_status` | Self-cleaning intelligence health -- calibration accuracy, anti-patterns |
|
|
227
|
+
| `decision_windows` | Time-bounded opportunities that need your attention now |
|
|
228
|
+
| `compound_advantage` | How much intelligence leverage your decisions are generating |
|
|
229
|
+
|
|
230
|
+
### Diagnostic (3 tools)
|
|
90
231
|
|
|
91
232
|
| Tool | Description |
|
|
92
233
|
|------|-------------|
|
|
93
|
-
| `source_health` |
|
|
234
|
+
| `source_health` | Source fetching status and data quality diagnostics |
|
|
94
235
|
| `config_validator` | Configuration validation and issue detection |
|
|
95
|
-
| `llm_status` | LLM
|
|
236
|
+
| `llm_status` | LLM and Ollama provider availability check |
|
|
237
|
+
|
|
238
|
+
## Transports
|
|
239
|
+
|
|
240
|
+
**stdio** (default) -- works with all MCP hosts:
|
|
241
|
+
```bash
|
|
242
|
+
npx @4da/mcp-server
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Streamable HTTP** -- for remote or multi-client setups:
|
|
246
|
+
```bash
|
|
247
|
+
npx @4da/mcp-server --http --port 4840
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## CLI Reference
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
npx @4da/mcp-server # Start server (stdio)
|
|
254
|
+
npx @4da/mcp-server --http # Start server (Streamable HTTP)
|
|
255
|
+
npx @4da/mcp-server --setup # Auto-configure your editors
|
|
256
|
+
npx @4da/mcp-server --doctor # Verify installation health
|
|
257
|
+
npx @4da/mcp-server --version # Print version
|
|
258
|
+
npx @4da/mcp-server --help # Show all options
|
|
259
|
+
```
|
|
96
260
|
|
|
97
261
|
## Environment Variables
|
|
98
262
|
|
|
99
263
|
| Variable | Description | Default |
|
|
100
264
|
|----------|-------------|---------|
|
|
101
|
-
| `FOURDA_DB_PATH` | Path to 4DA's SQLite database | Auto-detected from
|
|
265
|
+
| `FOURDA_DB_PATH` | Path to 4DA's SQLite database | Auto-detected from standard install locations |
|
|
266
|
+
| `FOURDA_OFFLINE` | Set to `true` to disable all network calls (vulnerability scanning) | `false` |
|
|
267
|
+
|
|
268
|
+
## FAQ
|
|
269
|
+
|
|
270
|
+
**Do I need the 4DA desktop app?**
|
|
271
|
+
No. The MCP server works standalone -- on first run it creates its own database and scans your current project for languages, frameworks, and dependencies. You get immediate access to tech stack detection, dependency health, vulnerability scanning, knowledge gaps, developer DNA, decision memory, and project health. Install the [desktop app](https://github.com/runyourempire/4DA) to unlock content scoring from 20+ sources (Hacker News, GitHub, arXiv, CVE feeds, etc.), daily AI briefings, and signal intelligence that compounds over time.
|
|
272
|
+
|
|
273
|
+
**Does this send my code anywhere?**
|
|
274
|
+
Almost nothing leaves your machine. 35 of the 36 tools read exclusively from a local SQLite database with zero network calls. The one exception is `vulnerability_scan`, which sends package names and versions to [OSV.dev](https://osv.dev) to check for known CVEs. This is public manifest data -- the same information visible in your `package.json` or `Cargo.toml`. No source code, file paths, or personal data is transmitted. Set `FOURDA_OFFLINE=true` to disable all network calls entirely.
|
|
275
|
+
|
|
276
|
+
**Which AI tools does this work with?**
|
|
277
|
+
Any tool that supports the [Model Context Protocol](https://modelcontextprotocol.io): Claude Code, Claude Desktop, Cursor, Windsurf, VS Code with Copilot, and any custom MCP client.
|
|
278
|
+
|
|
279
|
+
**Why 36 tools instead of 3?**
|
|
280
|
+
Because developer context is not one thing. Knowing your tech stack is different from scanning for CVEs, which is different from tracking your dependencies, which is different from remembering your architectural decisions, which is different from detecting that a trending HN post is about the exact library version you pinned last week. Each tool serves a distinct intelligence function. They compose naturally -- your AI picks the right ones for each question.
|
|
281
|
+
|
|
282
|
+
**What content sources does 4DA monitor?**
|
|
283
|
+
Hacker News, arXiv, Reddit (customizable subreddits), GitHub Trending, GitHub Releases, RSS/Atom feeds, DevTo, Lobsters, Product Hunt, and more. All configurable.
|
|
102
284
|
|
|
103
285
|
## Build from Source
|
|
104
286
|
|
|
105
287
|
```bash
|
|
106
|
-
|
|
288
|
+
git clone https://github.com/runyourempire/4DA.git
|
|
289
|
+
cd 4DA/mcp-4da-server
|
|
107
290
|
pnpm install
|
|
108
291
|
pnpm build
|
|
109
292
|
```
|
|
@@ -111,25 +294,14 @@ pnpm build
|
|
|
111
294
|
## Test
|
|
112
295
|
|
|
113
296
|
```bash
|
|
114
|
-
#
|
|
115
|
-
pnpm run inspect
|
|
116
|
-
|
|
117
|
-
# Direct JSON-RPC
|
|
118
|
-
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | node dist/index.js
|
|
297
|
+
pnpm test # Contract tests (71 tests)
|
|
298
|
+
pnpm run inspect # MCP Inspector (interactive browser UI)
|
|
119
299
|
```
|
|
120
300
|
|
|
121
|
-
##
|
|
122
|
-
|
|
123
|
-
Once configured, you can ask Claude:
|
|
124
|
-
|
|
125
|
-
- "What did 4DA find for me today?"
|
|
126
|
-
- "Are there any security alerts in my feed?"
|
|
127
|
-
- "Give me a briefing on what's relevant to my current project"
|
|
128
|
-
- "Why was this item scored highly?"
|
|
129
|
-
- "What are the trending topics in my domain?"
|
|
301
|
+
## License
|
|
130
302
|
|
|
131
|
-
|
|
303
|
+
MIT -- use it anywhere, integrate it with anything, build on top of it.
|
|
132
304
|
|
|
133
|
-
|
|
305
|
+
---
|
|
134
306
|
|
|
135
|
-
|
|
307
|
+
Built by [4DA](https://4da.ai) -- privacy-first developer intelligence.
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Authentication Middleware
|
|
3
|
+
*
|
|
4
|
+
* Validates JWT tokens from the Team Relay for network-exposed MCP access.
|
|
5
|
+
* Stdio transport (local) remains unauthenticated.
|
|
6
|
+
* HTTP transport requires a valid Bearer token with team_id + client_id claims.
|
|
7
|
+
*/
|
|
8
|
+
import { IncomingMessage } from "node:http";
|
|
9
|
+
export interface TeamClaims {
|
|
10
|
+
team_id: string;
|
|
11
|
+
client_id: string;
|
|
12
|
+
role: string;
|
|
13
|
+
exp: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Extract and validate a JWT token from an HTTP request.
|
|
17
|
+
*
|
|
18
|
+
* Returns the decoded claims if valid, null if no token or invalid.
|
|
19
|
+
* Uses HMAC-SHA256 verification against the shared relay secret.
|
|
20
|
+
*
|
|
21
|
+
* NOTE: This is a lightweight validator that checks structure and expiry.
|
|
22
|
+
* Full JWT signature verification requires the `jsonwebtoken` package.
|
|
23
|
+
* For launch, we validate structure + expiry. Post-launch, add signature verification.
|
|
24
|
+
*/
|
|
25
|
+
export declare function extractAuthClaims(req: IncomingMessage): TeamClaims | null;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a license tier allows network MCP access.
|
|
28
|
+
* Only "team" and "enterprise" tiers can use HTTP transport.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isNetworkTierAllowed(tier: string | undefined): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a role has permission for a specific operation.
|
|
33
|
+
* Viewers can read, members can read+write, admins can do everything.
|
|
34
|
+
*/
|
|
35
|
+
export declare function hasPermission(role: string, operation: "read" | "write" | "admin"): boolean;
|
|
36
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,eAAe,GAAG,UAAU,GAAG,IAAI,CA+CzE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEtE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GACpC,OAAO,CAWT"}
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* MCP Authentication Middleware
|
|
4
|
+
*
|
|
5
|
+
* Validates JWT tokens from the Team Relay for network-exposed MCP access.
|
|
6
|
+
* Stdio transport (local) remains unauthenticated.
|
|
7
|
+
* HTTP transport requires a valid Bearer token with team_id + client_id claims.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Extract and validate a JWT token from an HTTP request.
|
|
11
|
+
*
|
|
12
|
+
* Returns the decoded claims if valid, null if no token or invalid.
|
|
13
|
+
* Uses HMAC-SHA256 verification against the shared relay secret.
|
|
14
|
+
*
|
|
15
|
+
* NOTE: This is a lightweight validator that checks structure and expiry.
|
|
16
|
+
* Full JWT signature verification requires the `jsonwebtoken` package.
|
|
17
|
+
* For launch, we validate structure + expiry. Post-launch, add signature verification.
|
|
18
|
+
*/
|
|
19
|
+
export function extractAuthClaims(req) {
|
|
20
|
+
const auth = req.headers["authorization"];
|
|
21
|
+
if (!auth || !auth.startsWith("Bearer ")) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const token = auth.slice(7).trim();
|
|
25
|
+
if (!token)
|
|
26
|
+
return null;
|
|
27
|
+
try {
|
|
28
|
+
// JWT is base64url(header).base64url(payload).signature
|
|
29
|
+
const parts = token.split(".");
|
|
30
|
+
if (parts.length !== 3)
|
|
31
|
+
return null;
|
|
32
|
+
// Decode payload (middle part)
|
|
33
|
+
const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf-8"));
|
|
34
|
+
// Validate required fields
|
|
35
|
+
if (!payload.team_id || !payload.client_id || !payload.role) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
// Check expiry
|
|
39
|
+
if (payload.exp && payload.exp < Math.floor(Date.now() / 1000)) {
|
|
40
|
+
console.warn(`[4DA MCP Auth] Token expired for team ${payload.team_id}`);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
// Validate role is known
|
|
44
|
+
if (!["admin", "member", "viewer"].includes(payload.role)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
team_id: payload.team_id,
|
|
49
|
+
client_id: payload.client_id,
|
|
50
|
+
role: payload.role,
|
|
51
|
+
exp: payload.exp || 0,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
console.warn("[4DA MCP Auth] Failed to parse JWT token");
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Check if a license tier allows network MCP access.
|
|
61
|
+
* Only "team" and "enterprise" tiers can use HTTP transport.
|
|
62
|
+
*/
|
|
63
|
+
export function isNetworkTierAllowed(tier) {
|
|
64
|
+
return tier === "team" || tier === "enterprise";
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Check if a role has permission for a specific operation.
|
|
68
|
+
* Viewers can read, members can read+write, admins can do everything.
|
|
69
|
+
*/
|
|
70
|
+
export function hasPermission(role, operation) {
|
|
71
|
+
switch (operation) {
|
|
72
|
+
case "read":
|
|
73
|
+
return true; // All roles can read
|
|
74
|
+
case "write":
|
|
75
|
+
return role === "member" || role === "admin";
|
|
76
|
+
case "admin":
|
|
77
|
+
return role === "admin";
|
|
78
|
+
default:
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C;;;;;;GAMG;AAWH;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAoB;IACpD,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC1C,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACnC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAExB,IAAI,CAAC;QACH,wDAAwD;QACxD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAEpC,+BAA+B;QAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CACxB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CACrD,CAAC;QAEF,2BAA2B;QAC3B,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAC5D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,eAAe;QACf,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;YAC/D,OAAO,CAAC,IAAI,CACV,yCAAyC,OAAO,CAAC,OAAO,EAAE,CAC3D,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;QAED,yBAAyB;QACzB,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO;YACL,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;SACtB,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAwB;IAC3D,OAAO,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,YAAY,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAY,EACZ,SAAqC;IAErC,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,MAAM;YACT,OAAO,IAAI,CAAC,CAAC,qBAAqB;QACpC,KAAK,OAAO;YACV,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,OAAO,CAAC;QAC/C,KAAK,OAAO;YACV,OAAO,IAAI,KAAK,OAAO,CAAC;QAC1B;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC"}
|
package/dist/db.d.ts
CHANGED
|
@@ -4,22 +4,67 @@
|
|
|
4
4
|
* Read-only access to the 4DA SQLite database.
|
|
5
5
|
* Only the record_feedback function performs writes.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
7
|
+
import type BetterSqlite3 from "better-sqlite3";
|
|
8
8
|
import type { SourceItem, RelevantItem, UserContext, RelevanceExplanation, FeedbackAction, FeedbackResult } from "./types.js";
|
|
9
|
+
import type { ProjectScanResult } from "./project-scanner.js";
|
|
10
|
+
export interface DatabaseValidationResult {
|
|
11
|
+
valid: boolean;
|
|
12
|
+
error?: string;
|
|
13
|
+
tables?: string[];
|
|
14
|
+
/** True when no existing DB was found — standalone mode will create one */
|
|
15
|
+
standalone?: boolean;
|
|
16
|
+
}
|
|
9
17
|
/**
|
|
10
18
|
* 4DA Database accessor
|
|
11
19
|
*/
|
|
12
20
|
export declare class FourDADatabase {
|
|
13
21
|
private db;
|
|
22
|
+
private _isStandalone;
|
|
14
23
|
constructor(dbPath?: string);
|
|
24
|
+
/**
|
|
25
|
+
* Whether this database was freshly created in standalone mode
|
|
26
|
+
* (no pre-existing 4DA desktop app database found).
|
|
27
|
+
*/
|
|
28
|
+
get isStandalone(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Validate that a database file exists, is readable, and passes integrity checks.
|
|
31
|
+
*
|
|
32
|
+
* Use this before accepting tool calls to ensure the database is in a good state.
|
|
33
|
+
*
|
|
34
|
+
* @param dbPath - Path to the database file. If omitted, uses the default resolution.
|
|
35
|
+
* @returns Validation result with table list on success, or error details on failure.
|
|
36
|
+
*/
|
|
37
|
+
static validateDatabase(dbPath?: string): DatabaseValidationResult;
|
|
15
38
|
/**
|
|
16
39
|
* Get the raw better-sqlite3 database instance for custom queries
|
|
17
40
|
*/
|
|
18
|
-
getRawDb():
|
|
41
|
+
getRawDb(): BetterSqlite3.Database;
|
|
19
42
|
/**
|
|
20
43
|
* Close the database connection
|
|
21
44
|
*/
|
|
22
45
|
close(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Create the minimal schema required for MCP tools to function.
|
|
48
|
+
* Mirrors the desktop app's tables but only the subset that MCP tools query.
|
|
49
|
+
* Called once when creating a brand-new standalone database.
|
|
50
|
+
*/
|
|
51
|
+
private createMinimalSchema;
|
|
52
|
+
/**
|
|
53
|
+
* Populate the standalone database from a project scan result.
|
|
54
|
+
* Inserts detected tech, dependencies, and topics so MCP tools return useful data.
|
|
55
|
+
*/
|
|
56
|
+
populateFromScan(scan: ProjectScanResult): void;
|
|
57
|
+
/**
|
|
58
|
+
* Execute a database operation with retry logic for SQLITE_BUSY / SQLITE_LOCKED.
|
|
59
|
+
*
|
|
60
|
+
* better-sqlite3 is synchronous, so contention with the Tauri backend (which
|
|
61
|
+
* also writes to the same WAL database) can occasionally surface as BUSY/LOCKED.
|
|
62
|
+
* A single retry after a short pause is sufficient in practice.
|
|
63
|
+
*
|
|
64
|
+
* @param fn - The synchronous database operation to execute.
|
|
65
|
+
* @param maxRetries - Maximum number of retries (default: 1).
|
|
66
|
+
*/
|
|
67
|
+
queryWithRetry<T>(fn: () => T, maxRetries?: number): T;
|
|
23
68
|
/**
|
|
24
69
|
* Get relevant content items with computed relevance scores
|
|
25
70
|
*/
|
|
@@ -28,6 +73,11 @@ export declare class FourDADatabase {
|
|
|
28
73
|
* Get a single source item by ID and type
|
|
29
74
|
*/
|
|
30
75
|
getSourceItem(itemId: number, sourceType: string): SourceItem | null;
|
|
76
|
+
/**
|
|
77
|
+
* Look up persisted necessity scores for an item (written by Rust analysis pipeline).
|
|
78
|
+
* Returns defaults (0.0/null) if no necessity data exists yet.
|
|
79
|
+
*/
|
|
80
|
+
private getNecessityForItem;
|
|
31
81
|
/**
|
|
32
82
|
* Get the user's context (what 4DA knows about them)
|
|
33
83
|
*/
|
|
@@ -40,6 +90,54 @@ export declare class FourDADatabase {
|
|
|
40
90
|
* Record user feedback on an item
|
|
41
91
|
*/
|
|
42
92
|
recordFeedback(itemId: number, sourceType: string, action: FeedbackAction): FeedbackResult;
|
|
93
|
+
/**
|
|
94
|
+
* Ensure the agent_feedback table exists.
|
|
95
|
+
* Called on first use so existing databases (created before this feature)
|
|
96
|
+
* get the table added without requiring a migration.
|
|
97
|
+
*/
|
|
98
|
+
private ensureAgentFeedbackTable;
|
|
99
|
+
/**
|
|
100
|
+
* Record agent feedback on recommended content items
|
|
101
|
+
*/
|
|
102
|
+
recordAgentFeedback(itemIds: string[], outcome: string, context?: string, sessionTask?: string): {
|
|
103
|
+
success: boolean;
|
|
104
|
+
message: string;
|
|
105
|
+
recorded_count: number;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Get agent feedback statistics for the given period
|
|
109
|
+
*/
|
|
110
|
+
getAgentFeedbackStats(days?: number): {
|
|
111
|
+
period_days: number;
|
|
112
|
+
outcomes: {
|
|
113
|
+
used: number;
|
|
114
|
+
rejected: number;
|
|
115
|
+
partially_used: number;
|
|
116
|
+
total: number;
|
|
117
|
+
};
|
|
118
|
+
by_source: Array<{
|
|
119
|
+
source_type: string;
|
|
120
|
+
used: number;
|
|
121
|
+
rejected: number;
|
|
122
|
+
partially_used: number;
|
|
123
|
+
total: number;
|
|
124
|
+
usefulness_rate: number;
|
|
125
|
+
}>;
|
|
126
|
+
top_used_items: Array<{
|
|
127
|
+
item_id: string;
|
|
128
|
+
title: string | null;
|
|
129
|
+
source_type: string | null;
|
|
130
|
+
used_count: number;
|
|
131
|
+
rejected_count: number;
|
|
132
|
+
}>;
|
|
133
|
+
recent_feedback: Array<{
|
|
134
|
+
item_id: string;
|
|
135
|
+
outcome: string;
|
|
136
|
+
context: string | null;
|
|
137
|
+
session_task: string | null;
|
|
138
|
+
recorded_at: string;
|
|
139
|
+
}>;
|
|
140
|
+
};
|
|
43
141
|
/**
|
|
44
142
|
* Compute relevance score for an item based on user context
|
|
45
143
|
*/
|