rust-faf-mcp 0.4.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/LICENSE +21 -0
- package/README.md +213 -0
- package/lib/download.js +202 -0
- package/lib/platform.js +35 -0
- package/npm/rust-faf-mcp.js +49 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Wolfe-James
|
|
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
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
<!-- faf: rust-faf-mcp | Rust | mcp-server | RMCP — the Rust-native MCP server for FAF (Foundational AI-context Format). Single binary, stdio transport, 4.3 MB stripped. cargo install rust-faf-mcp. Built on the rmcp Rust MCP SDK + faf-rust-sdk. -->
|
|
2
|
+
<!-- mcp-name: one.faf/rust-faf-mcp -->
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# rust-faf-mcp
|
|
6
|
+
|
|
7
|
+
**Persistent Project Context for Rust MCP clients. Native. Fast. cargo install**
|
|
8
|
+
|
|
9
|
+
**The one.faf Edition (v0.4.0)** — `one.faf/rust-faf-mcp` · **rmcp 3.0.1** (MCP Tier 1 foundation) · solid cargo-native Rust MCP for Rust devs
|
|
10
|
+
|
|
11
|
+
**FAF defines. MD instructs. AI codes.**
|
|
12
|
+
|
|
13
|
+
> Stop re-explaining your project to every AI session. One `.faf` file holds your persistent project context. Every AI reads it once and knows what you're building.
|
|
14
|
+
|
|
15
|
+
[](https://crates.io/crates/rust-faf-mcp)
|
|
16
|
+
[](https://builder.faf.one)
|
|
17
|
+
[](https://github.com/Wolfe-Jam/rust-faf-mcp)
|
|
18
|
+
[](https://www.iana.org/assignments/media-types/application/vnd.faf+yaml)
|
|
19
|
+
[](LICENSE)
|
|
20
|
+
|
|
21
|
+
Rust-native [MCP](https://modelcontextprotocol.io) (Model Context Protocol) server for [FAF](https://faf.one) — structured AI project context in YAML (`application/vnd.faf+yaml`). Single binary, stdio transport, 4.3 MB stripped. Built on [`rmcp`](https://crates.io/crates/rmcp) and [`faf-rust-sdk`](https://crates.io/crates/faf-rust-sdk).
|
|
22
|
+
|
|
23
|
+
## Quickstart
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Rust toolchain:
|
|
27
|
+
cargo install rust-faf-mcp
|
|
28
|
+
|
|
29
|
+
# No Rust (downloads GH Release binary for darwin/linux x64):
|
|
30
|
+
npx rust-faf-mcp
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
Then point any MCP client at it:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Claude Code
|
|
38
|
+
claude mcp add faf rust-faf-mcp
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```jsonc
|
|
42
|
+
// WARP / Cursor / Zed / Claude Desktop — any stdio MCP client
|
|
43
|
+
{
|
|
44
|
+
"mcpServers": {
|
|
45
|
+
"faf": {
|
|
46
|
+
"command": "rust-faf-mcp"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
No flags, no config files, no network listener. Pure stdio JSON-RPC.
|
|
53
|
+
|
|
54
|
+
Or via Homebrew (macOS, pre-built):
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
brew install Wolfe-Jam/faf/rust-faf-mcp
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## One command, done forever
|
|
61
|
+
|
|
62
|
+
`faf_auto` detects your project, creates a `.faf`, enhances it to max score, and syncs `CLAUDE.md` — in one shot:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
faf_auto complete
|
|
66
|
+
━━━━━━━━━━━━━━━━━
|
|
67
|
+
Score: 0% → 85% (+85) ◇ BRONZE
|
|
68
|
+
Steps:
|
|
69
|
+
1. Created project.faf
|
|
70
|
+
2. Second enhancement pass
|
|
71
|
+
3. Created CLAUDE.md
|
|
72
|
+
|
|
73
|
+
Path: /home/user/my-project
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
What it produces:
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
# project.faf — your project, machine-readable
|
|
80
|
+
faf_version: "3.3"
|
|
81
|
+
project:
|
|
82
|
+
name: my-api
|
|
83
|
+
goal: REST API for user management
|
|
84
|
+
main_language: Rust
|
|
85
|
+
version: "0.1.0"
|
|
86
|
+
license: MIT
|
|
87
|
+
instant_context:
|
|
88
|
+
what_building: REST API for user management
|
|
89
|
+
tech_stack: Rust 2024
|
|
90
|
+
key_files:
|
|
91
|
+
- Cargo.toml
|
|
92
|
+
- src/main.rs
|
|
93
|
+
- README.md
|
|
94
|
+
commands:
|
|
95
|
+
build: cargo build
|
|
96
|
+
test: cargo test
|
|
97
|
+
stack:
|
|
98
|
+
backend: Rust
|
|
99
|
+
build_tool: cargo
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Every AI agent reads this once and knows exactly what you're building. No 20-minute onboarding. No wrong assumptions.
|
|
103
|
+
|
|
104
|
+
## Tools
|
|
105
|
+
|
|
106
|
+
### Create & Detect
|
|
107
|
+
|
|
108
|
+
| Tool | What it does |
|
|
109
|
+
|------|-------------|
|
|
110
|
+
| `faf_auto` | Zero to AI context in one command — init, enhance, sync, score, done |
|
|
111
|
+
| `faf_init` | Create or enhance `project.faf` from `Cargo.toml`, `package.json`, `pyproject.toml`, or `go.mod` |
|
|
112
|
+
| `faf_git` | Generate `project.faf` from any GitHub repo URL — no clone needed |
|
|
113
|
+
| `faf_discover` | Walk up the directory tree to find the nearest `project.faf` |
|
|
114
|
+
|
|
115
|
+
### Score & Validate
|
|
116
|
+
|
|
117
|
+
| Tool | What it does |
|
|
118
|
+
|------|-------------|
|
|
119
|
+
| `faf_score` | Score AI-readiness 0-100% with field-level breakdown |
|
|
120
|
+
| `faf_sync` | Sync `project.faf` → `CLAUDE.md` (preserves existing content) |
|
|
121
|
+
|
|
122
|
+
### Optimize
|
|
123
|
+
|
|
124
|
+
| Tool | What it does |
|
|
125
|
+
|------|-------------|
|
|
126
|
+
| `faf_read` | Parse and display `project.faf` contents |
|
|
127
|
+
| `faf_compress` | Compress `.faf` for token-limited contexts (`minimal` / `standard` / `full`) |
|
|
128
|
+
| `faf_tokens` | Estimate token count at each compression level |
|
|
129
|
+
|
|
130
|
+
`faf_init` is iterative — run it again and it fills in what's missing. Score goes up each time.
|
|
131
|
+
|
|
132
|
+
## Architecture
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
src/
|
|
136
|
+
├── main.rs # ~20 lines — tokio entry, rmcp stdio transport
|
|
137
|
+
├── server.rs # FafServer: #[tool_router], ServerHandler, resources
|
|
138
|
+
└── tools.rs # Business logic — all 9 tools, pure functions returning Value
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
- **Runtime**: `tokio` single-threaded (`current_thread`)
|
|
142
|
+
- **HTTP**: `reqwest` async (only used by `faf_git` for GitHub API)
|
|
143
|
+
- **SDK**: `faf-rust-sdk` **1.3** (Cargo pin — parse / validate / compress / discover; foundation **3.x** lives in [faf-rust](https://github.com/Wolfe-Jam/faf-rust))
|
|
144
|
+
- **Server**: **`rmcp` 3.0.1** with `#[tool_router]` / `#[tool_handler]` — JSON-RPC, schema generation, stdio transport (Tier-1 assessed SDK cut)
|
|
145
|
+
|
|
146
|
+
Tools return `serde_json::Value`. The server adapts them to `Result<String, String>` for rmcp's `IntoCallToolResult`.
|
|
147
|
+
|
|
148
|
+
## Testing
|
|
149
|
+
|
|
150
|
+
112 tests across 6 files:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
cargo test # runs all 112
|
|
154
|
+
|
|
155
|
+
# Full ship bar (same gates as GitHub CI — run before push)
|
|
156
|
+
bash scripts/ci.sh
|
|
157
|
+
# Optional: block push on red CI twin
|
|
158
|
+
bash scripts/install-hooks.sh
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
| File | Tests | Coverage |
|
|
162
|
+
|------|-------|----------|
|
|
163
|
+
| `mcp_protocol.rs` | 9 | Init handshake, tools/list, resources, schema validation, ID preservation |
|
|
164
|
+
| `tools_functional.rs` | 25 | All 9 tools — happy path, error paths, language detection |
|
|
165
|
+
| `tier1_security.rs` | 12 | Path traversal, null bytes, shell injection, oversized input, malformed JSON |
|
|
166
|
+
| `tier2_engine.rs` | 35 | Corrupt YAML, sync replacement, pipelines, dual manifests, legacy filenames, direct paths |
|
|
167
|
+
| `tier3_edge_cases.rs` | 10 | Unicode, CJK, score boundaries, unknown fields, GitHub URL parsing |
|
|
168
|
+
| `tier4_aero.rs` | 21 | Manifest structure, version sync, server.json, manifest-server cross-validation |
|
|
169
|
+
|
|
170
|
+
Tests spawn the compiled binary as a subprocess and communicate via stdin/stdout JSON-RPC — true integration tests against the real server.
|
|
171
|
+
|
|
172
|
+
## FAF Ecosystem
|
|
173
|
+
|
|
174
|
+
One format, every AI platform.
|
|
175
|
+
|
|
176
|
+
| Package | Platform | Registry |
|
|
177
|
+
|---------|----------|----------|
|
|
178
|
+
| **rust-faf-mcp** | **Rust** | **crates.io** |
|
|
179
|
+
| [claude-faf-mcp](https://npmjs.com/package/claude-faf-mcp) | Anthropic | npm + MCP #2759 |
|
|
180
|
+
| [gemini-faf-mcp](https://pypi.org/project/gemini-faf-mcp/) | Google | PyPI |
|
|
181
|
+
| [grok-faf-mcp](https://npmjs.com/package/grok-faf-mcp) | xAI | npm |
|
|
182
|
+
| [faf-cli](https://npmjs.com/package/faf-cli) | Universal | npm |
|
|
183
|
+
|
|
184
|
+
## Build from source
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
git clone https://github.com/Wolfe-Jam/rust-faf-mcp
|
|
188
|
+
cd rust-faf-mcp
|
|
189
|
+
cargo build --release
|
|
190
|
+
# Binary at target/release/rust-faf-mcp (4.3 MB)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Edition**: 2024 | **LTO**: enabled | **Strip**: symbols
|
|
194
|
+
|
|
195
|
+
If `rust-faf-mcp` has been useful, consider starring the repo — it helps others find it.
|
|
196
|
+
|
|
197
|
+
## Links
|
|
198
|
+
|
|
199
|
+
- [crates.io/crates/rust-faf-mcp](https://crates.io/crates/rust-faf-mcp)
|
|
200
|
+
- [npmjs.com/package/rust-faf-mcp](https://www.npmjs.com/package/rust-faf-mcp) — `npx rust-faf-mcp` (no Rust toolchain; downloads GH Release binary)
|
|
201
|
+
- [faf-rust-sdk](https://crates.io/crates/faf-rust-sdk) — the parser this depends on
|
|
202
|
+
- [faf.one](https://faf.one) — FAF home
|
|
203
|
+
- [IANA registration](https://www.iana.org/assignments/media-types/application/vnd.faf+yaml) — `application/vnd.faf+yaml`
|
|
204
|
+
- MCP Registry name: `mcp-name: one.faf/rust-faf-mcp`
|
|
205
|
+
- [CHANGELOG](CHANGELOG.md)
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
MIT
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
Built by [@wolfe_jam](https://x.com/wolfe_jam) | [wolfejam.dev](https://wolfejam.dev)
|
package/lib/download.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const https = require("https");
|
|
7
|
+
const http = require("http");
|
|
8
|
+
const { execFileSync } = require("child_process");
|
|
9
|
+
const { resolveTarget } = require("./platform");
|
|
10
|
+
|
|
11
|
+
const OWNER = "Wolfe-Jam";
|
|
12
|
+
const REPO = "rust-faf-mcp";
|
|
13
|
+
const APP = "rust-faf-mcp";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Cache dir for downloaded binaries.
|
|
17
|
+
* @param {string} version
|
|
18
|
+
* @param {string} triple
|
|
19
|
+
*/
|
|
20
|
+
function cacheDir(version, triple) {
|
|
21
|
+
const base =
|
|
22
|
+
process.env.RUST_FAF_MCP_CACHE_DIR ||
|
|
23
|
+
path.join(os.homedir(), ".cache", "rust-faf-mcp");
|
|
24
|
+
return path.join(base, version, triple);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {string} url
|
|
29
|
+
* @param {string} dest
|
|
30
|
+
* @param {number} redirects
|
|
31
|
+
*/
|
|
32
|
+
function downloadFile(url, dest, redirects = 0) {
|
|
33
|
+
if (redirects > 10) {
|
|
34
|
+
throw new Error(`rust-faf-mcp: too many redirects fetching ${url}`);
|
|
35
|
+
}
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
const lib = url.startsWith("https:") ? https : http;
|
|
38
|
+
const req = lib.get(
|
|
39
|
+
url,
|
|
40
|
+
{
|
|
41
|
+
headers: {
|
|
42
|
+
"User-Agent": "rust-faf-mcp-npm-shim",
|
|
43
|
+
Accept: "application/octet-stream",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
(res) => {
|
|
47
|
+
if (
|
|
48
|
+
res.statusCode &&
|
|
49
|
+
res.statusCode >= 300 &&
|
|
50
|
+
res.statusCode < 400 &&
|
|
51
|
+
res.headers.location
|
|
52
|
+
) {
|
|
53
|
+
res.resume();
|
|
54
|
+
downloadFile(res.headers.location, dest, redirects + 1)
|
|
55
|
+
.then(resolve)
|
|
56
|
+
.catch(reject);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (res.statusCode !== 200) {
|
|
60
|
+
res.resume();
|
|
61
|
+
reject(
|
|
62
|
+
new Error(
|
|
63
|
+
`rust-faf-mcp: download failed HTTP ${res.statusCode} for ${url}`
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const tmp = `${dest}.partial`;
|
|
69
|
+
const out = fs.createWriteStream(tmp);
|
|
70
|
+
res.pipe(out);
|
|
71
|
+
out.on("finish", () => {
|
|
72
|
+
out.close(() => {
|
|
73
|
+
fs.renameSync(tmp, dest);
|
|
74
|
+
resolve();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
out.on("error", (err) => {
|
|
78
|
+
try {
|
|
79
|
+
fs.unlinkSync(tmp);
|
|
80
|
+
} catch {
|
|
81
|
+
/* ignore */
|
|
82
|
+
}
|
|
83
|
+
reject(err);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
req.on("error", reject);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param {string} archivePath
|
|
93
|
+
* @param {string} destDir
|
|
94
|
+
*/
|
|
95
|
+
function extractArchive(archivePath, destDir) {
|
|
96
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
97
|
+
execFileSync("tar", ["-xzf", archivePath, "-C", destDir], {
|
|
98
|
+
stdio: "inherit",
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @param {string} root
|
|
104
|
+
* @param {string} binaryName
|
|
105
|
+
*/
|
|
106
|
+
function findBinary(root, binaryName) {
|
|
107
|
+
const direct = path.join(root, binaryName);
|
|
108
|
+
if (fs.existsSync(direct) && fs.statSync(direct).isFile()) {
|
|
109
|
+
return direct;
|
|
110
|
+
}
|
|
111
|
+
/** @type {string[]} */
|
|
112
|
+
const stack = [root];
|
|
113
|
+
while (stack.length) {
|
|
114
|
+
const dir = stack.pop();
|
|
115
|
+
let entries;
|
|
116
|
+
try {
|
|
117
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
118
|
+
} catch {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
for (const ent of entries) {
|
|
122
|
+
const full = path.join(dir, ent.name);
|
|
123
|
+
if (ent.isDirectory()) {
|
|
124
|
+
stack.push(full);
|
|
125
|
+
} else if (ent.name === binaryName) {
|
|
126
|
+
return full;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Ensure native binary is on disk; return absolute path.
|
|
135
|
+
*
|
|
136
|
+
* GH asset naming from release.yml:
|
|
137
|
+
* rust-faf-mcp-${VERSION}-${target}.tar.gz
|
|
138
|
+
* e.g. rust-faf-mcp-0.4.1-aarch64-apple-darwin.tar.gz
|
|
139
|
+
*
|
|
140
|
+
* @param {string} version
|
|
141
|
+
*/
|
|
142
|
+
async function ensureBinary(version) {
|
|
143
|
+
const { triple, binaryName } = resolveTarget();
|
|
144
|
+
const dir = cacheDir(version, triple);
|
|
145
|
+
const binPath = path.join(dir, binaryName);
|
|
146
|
+
|
|
147
|
+
if (fs.existsSync(binPath)) {
|
|
148
|
+
return binPath;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Primary: versioned name from release.yml
|
|
152
|
+
// Fallbacks: unversioned / mcp-better-style layouts if ever added
|
|
153
|
+
const candidates = [
|
|
154
|
+
`${APP}-${version}-${triple}.tar.gz`,
|
|
155
|
+
`${APP}-v${version}-${triple}.tar.gz`,
|
|
156
|
+
`${APP}-${triple}.tar.gz`,
|
|
157
|
+
];
|
|
158
|
+
|
|
159
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
160
|
+
const extractRoot = path.join(dir, "_extract");
|
|
161
|
+
fs.rmSync(extractRoot, { recursive: true, force: true });
|
|
162
|
+
fs.mkdirSync(extractRoot, { recursive: true });
|
|
163
|
+
|
|
164
|
+
let lastErr = null;
|
|
165
|
+
for (const name of candidates) {
|
|
166
|
+
const url = `https://github.com/${OWNER}/${REPO}/releases/download/v${version}/${name}`;
|
|
167
|
+
const archivePath = path.join(dir, name);
|
|
168
|
+
try {
|
|
169
|
+
process.stderr.write(`rust-faf-mcp: downloading ${name}…\n`);
|
|
170
|
+
await downloadFile(url, archivePath);
|
|
171
|
+
extractArchive(archivePath, extractRoot);
|
|
172
|
+
const found = findBinary(extractRoot, binaryName);
|
|
173
|
+
if (!found) {
|
|
174
|
+
throw new Error(`archive ${name} did not contain ${binaryName}`);
|
|
175
|
+
}
|
|
176
|
+
fs.copyFileSync(found, binPath);
|
|
177
|
+
fs.chmodSync(binPath, 0o755);
|
|
178
|
+
try {
|
|
179
|
+
fs.unlinkSync(archivePath);
|
|
180
|
+
} catch {
|
|
181
|
+
/* ignore */
|
|
182
|
+
}
|
|
183
|
+
fs.rmSync(extractRoot, { recursive: true, force: true });
|
|
184
|
+
return binPath;
|
|
185
|
+
} catch (err) {
|
|
186
|
+
lastErr = err;
|
|
187
|
+
try {
|
|
188
|
+
fs.unlinkSync(archivePath);
|
|
189
|
+
} catch {
|
|
190
|
+
/* ignore */
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
throw new Error(
|
|
196
|
+
`rust-faf-mcp: could not download a binary for ${triple} (v${version}). ` +
|
|
197
|
+
`Install Rust and run: cargo install rust-faf-mcp --version ${version}\n` +
|
|
198
|
+
`Last error: ${lastErr && lastErr.message ? lastErr.message : lastErr}`
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
module.exports = { ensureBinary, cacheDir };
|
package/lib/platform.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Map Node process.platform/arch → Rust target triples used by
|
|
5
|
+
* rust-faf-mcp GitHub Release assets (release.yml).
|
|
6
|
+
*
|
|
7
|
+
* Supported matrix today (release.yml): darwin arm/x64 + linux x64 only.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const TARGETS = {
|
|
11
|
+
"darwin-arm64": "aarch64-apple-darwin",
|
|
12
|
+
"darwin-x64": "x86_64-apple-darwin",
|
|
13
|
+
"linux-x64": "x86_64-unknown-linux-gnu",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @returns {{ triple: string, binaryName: string }}
|
|
18
|
+
*/
|
|
19
|
+
function resolveTarget() {
|
|
20
|
+
const key = `${process.platform}-${process.arch}`;
|
|
21
|
+
const triple = TARGETS[key];
|
|
22
|
+
if (!triple) {
|
|
23
|
+
const supported = Object.keys(TARGETS).join(", ");
|
|
24
|
+
throw new Error(
|
|
25
|
+
`rust-faf-mcp: unsupported platform ${key}. Supported npx hosts: ${supported}. ` +
|
|
26
|
+
`Use: cargo install rust-faf-mcp — or install an MCPB package.`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
triple,
|
|
31
|
+
binaryName: "rust-faf-mcp",
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = { resolveTarget, TARGETS };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* npm shim for rust-faf-mcp — zero Rust toolchain required.
|
|
6
|
+
*
|
|
7
|
+
* Identity: one.faf/rust-faf-mcp (FAF product — not io.github).
|
|
8
|
+
* Downloads versioned GitHub Release assets from release.yml naming:
|
|
9
|
+
* rust-faf-mcp-${VERSION}-${target}.tar.gz
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const { spawn } = require("child_process");
|
|
13
|
+
const { ensureBinary } = require("../lib/download");
|
|
14
|
+
|
|
15
|
+
const pkg = require("../package.json");
|
|
16
|
+
const version = pkg.version;
|
|
17
|
+
|
|
18
|
+
async function main() {
|
|
19
|
+
const override = process.env.RUST_FAF_MCP_BIN;
|
|
20
|
+
let bin;
|
|
21
|
+
if (override) {
|
|
22
|
+
bin = override;
|
|
23
|
+
} else {
|
|
24
|
+
bin = await ensureBinary(version);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const child = spawn(bin, process.argv.slice(2), {
|
|
28
|
+
stdio: "inherit",
|
|
29
|
+
windowsHide: true,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
child.on("error", (err) => {
|
|
33
|
+
console.error(`rust-faf-mcp: failed to spawn ${bin}: ${err.message}`);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
child.on("exit", (code, signal) => {
|
|
38
|
+
if (signal) {
|
|
39
|
+
process.kill(process.pid, signal);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
process.exit(code == null ? 1 : code);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
main().catch((err) => {
|
|
47
|
+
console.error(err.message || err);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rust-faf-mcp",
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"mcpName": "one.faf/rust-faf-mcp",
|
|
5
|
+
"description": "Persistent project context — Rust-native MCP server. IANA-registered .faf format. npm shim downloads the native binary from GitHub Releases.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "wolfejam <wolfejam@faf.one>",
|
|
8
|
+
"homepage": "https://faf.one",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Wolfe-Jam/rust-faf-mcp.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Wolfe-Jam/rust-faf-mcp/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"faf",
|
|
18
|
+
"mcp",
|
|
19
|
+
"model-context-protocol",
|
|
20
|
+
"rust",
|
|
21
|
+
"rmcp"
|
|
22
|
+
],
|
|
23
|
+
"bin": {
|
|
24
|
+
"rust-faf-mcp": "npm/rust-faf-mcp.js"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"npm/",
|
|
28
|
+
"lib/",
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"os": [
|
|
36
|
+
"darwin",
|
|
37
|
+
"linux"
|
|
38
|
+
],
|
|
39
|
+
"cpu": [
|
|
40
|
+
"x64",
|
|
41
|
+
"arm64"
|
|
42
|
+
]
|
|
43
|
+
}
|