@arkhe-zero/mcp 1.0.2 → 1.0.3
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/package.json +1 -1
- package/server.mjs +61 -29
package/package.json
CHANGED
package/server.mjs
CHANGED
|
@@ -1,33 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { createHash } from "node:crypto";
|
|
6
|
-
import { readFile } from "node:fs/promises";
|
|
7
|
-
|
|
8
|
-
const BASE = "https://sycro-valdovinos.github.io/ARKHE-ZERO";
|
|
9
|
-
const server = new McpServer({ name: "arkhe-zero", version: "1.0.0" });
|
|
10
|
-
|
|
11
|
-
server.tool("arkhe_get_llms", {}, async () => {
|
|
12
|
-
const r = await fetch(`${BASE}/llms.txt`);
|
|
13
|
-
return { content: [{ type: "text", text: await r.text() }] };
|
|
14
|
-
});
|
|
1
|
+
import { createInterface } from "node:readline";
|
|
15
2
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
// Constantes
|
|
4
|
+
const e = 1.602176634e-19;
|
|
5
|
+
const m_e = 9.1093837e-31;
|
|
6
|
+
const eps0 = 8.8541878128e-12;
|
|
20
7
|
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
}
|
|
8
|
+
function plasma(n_e) {
|
|
9
|
+
const omega_p = Math.sqrt(n_e * e * e / (m_e * eps0));
|
|
10
|
+
const f_p = omega_p / (2 * Math.PI);
|
|
11
|
+
const T = 2 * Math.PI / omega_p;
|
|
12
|
+
return { n_e, omega_p, f_p, T };
|
|
13
|
+
}
|
|
26
14
|
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
function oscillation(n_e, x0 = 1, periods = 3, points = 100) {
|
|
16
|
+
const { omega_p, f_p, T } = plasma(n_e);
|
|
17
|
+
const data = [];
|
|
18
|
+
for (let i = 0; i < points; i++) {
|
|
19
|
+
const t = (i / (points - 1)) * periods * T;
|
|
20
|
+
const x = x0 * Math.cos(omega_p * t);
|
|
21
|
+
const v = -x0 * omega_p * Math.sin(omega_p * t);
|
|
22
|
+
data.push({ t, x, v });
|
|
23
|
+
}
|
|
24
|
+
return { omega_p, f_p, T, x0, data };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout, terminal: false });
|
|
28
|
+
|
|
29
|
+
rl.on("line", (line) => {
|
|
30
|
+
let req;
|
|
31
|
+
try { req = JSON.parse(line); } catch { return; }
|
|
32
|
+
const id = req.id ?? null;
|
|
33
|
+
|
|
34
|
+
const send = (obj) => console.log(JSON.stringify(obj));
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
if (req.method === "initialize") {
|
|
37
|
+
return send({ jsonrpc: "2.0", id, result: {
|
|
38
|
+
protocolVersion: "2024-11-05",
|
|
39
|
+
capabilities: { tools: {} },
|
|
40
|
+
serverInfo: { name: "arkhe-zero", version: "1.0.3" }
|
|
41
|
+
}});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (req.method === "notifications/initialized") return;
|
|
45
|
+
|
|
46
|
+
if (req.method === "tools/list") {
|
|
47
|
+
return send({ jsonrpc: "2.0", id, result: { tools: [
|
|
48
|
+
{ name: "plasma_frequency", description: "Calcula omega_p = sqrt(n_e*e^2 / m_e*eps0)", inputSchema: { type: "object", properties: { n_e: { type: "number", description: "densidad electrones / m3" } }, required: ["n_e"] } },
|
|
49
|
+
{ name: "plasma_oscillation", description: "Simula x(t)=x0*cos(omega_p*t), v(t)=-x0*omega_p*sin(omega_p*t)", inputSchema: { type: "object", properties: { n_e: { type: "number" }, x0: { type: "number" }, periods: { type: "number" }, points: { type: "number" } }, required: ["n_e"] } }
|
|
50
|
+
]}});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (req.method === "tools/call") {
|
|
54
|
+
const name = req.params?.name;
|
|
55
|
+
const args = req.params?.arguments || {};
|
|
56
|
+
let result;
|
|
57
|
+
if (name === "plasma_frequency") result = plasma(args.n_e ?? 1e18);
|
|
58
|
+
else if (name === "plasma_oscillation") result = oscillation(args.n_e ?? 1e18, args.x0 ?? 1, args.periods ?? 3, args.points ?? 20);
|
|
59
|
+
else return send({ jsonrpc: "2.0", id, error: { code: -32601, message: "Tool not found" } });
|
|
60
|
+
|
|
61
|
+
return send({ jsonrpc: "2.0", id, result: { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] } });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return send({ jsonrpc: "2.0", id, result: {} });
|
|
65
|
+
});
|