javabytes-mcp 1.0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 markymakes.dev
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,84 @@
1
+ # javabytes-mcp
2
+
3
+ JavaBytes is a general-purpose Java MCP server for filesystem work, MySQL
4
+ analysis, JavaFX, Spring Boot and JavaScript-to-Java migration planning. It
5
+ speaks JSON-RPC over stdio and bundles its shaded jar, so a client only needs
6
+ Node.js and Java.
7
+
8
+ ## Requirements
9
+
10
+ - Node.js 18 or newer
11
+ - Java 21 or newer (`java` on `PATH`, or `JAVA_HOME` set)
12
+
13
+ ## Run
14
+
15
+ ```bash
16
+ npx -y javabytes-mcp
17
+ ```
18
+
19
+ The process reads MCP messages on stdin and writes only protocol messages to
20
+ stdout. Logs go to stderr.
21
+
22
+ ## Agent configuration
23
+
24
+ ```json
25
+ {
26
+ "mcpServers": {
27
+ "javabytes": {
28
+ "command": "npx",
29
+ "args": ["-y", "javabytes-mcp"],
30
+ "env": {
31
+ "JAVABYTES_DB_URL": "jdbc:mysql://localhost:3306/appdb",
32
+ "JAVABYTES_DB_USER": "app",
33
+ "JAVABYTES_DB_PASSWORD": "change-me"
34
+ }
35
+ }
36
+ }
37
+ }
38
+ ```
39
+
40
+ Set `JAVABYTES_ALLOWED_DIRS` to a semicolon-separated allow-list when the
41
+ client does not send MCP roots.
42
+
43
+ ## Environment
44
+
45
+ | Variable | Purpose |
46
+ |---|---|
47
+ | `JAVABYTES_JAR` | Use a specific shaded jar instead of the bundled one |
48
+ | `JAVABYTES_JAVA` | Use a specific `java` executable |
49
+ | `JAVABYTES_JAVA_OPTS` | Extra JVM flags, e.g. `-Xmx512m` |
50
+ | `JAVABYTES_ALLOWED_DIRS` | Fallback filesystem sandbox |
51
+ | `JAVABYTES_DB_URL` | JDBC URL, default `jdbc:mysql://localhost:3306/mydb` |
52
+ | `JAVABYTES_DB_USER` | Database user |
53
+ | `JAVABYTES_DB_PASSWORD` | Database password |
54
+ | `JAVABYTES_ENABLE` | Comma-separated tools/categories to force-enable |
55
+ | `JAVABYTES_DISABLE` | Comma-separated tools/categories to disable |
56
+ | `JAVABYTES_LOG_FILE` | Append protocol/server logs to a file |
57
+
58
+ Database tools are read-only: they accept `SELECT`, `SHOW`, `DESCRIBE`,
59
+ `EXPLAIN`, `WITH` and `TABLE` statements only.
60
+
61
+ ## Local development
62
+
63
+ ```bash
64
+ npm run prepack # copy ../../target/javabytes.jar into jar/
65
+ node bin/javabytes.js # start without npx
66
+ npm test # launcher unit tests
67
+ ```
68
+
69
+ `prepack` also runs automatically on `npm pack` and `npm publish`.
70
+
71
+ ## Publishing
72
+
73
+ 1. `npm login`
74
+ 2. `npm publish --access public`
75
+
76
+ `prepack` copies the shaded jar and the repository `LICENSE` into the package, so
77
+ both ship in the tarball.
78
+
79
+ The package name `javabytes-mcp` was unclaimed on npm at the time of writing;
80
+ re-check with `npm view javabytes-mcp` before publishing.
81
+
82
+ ## License
83
+
84
+ MIT — see [LICENSE](../LICENSE).
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { main } = require("../lib/launcher");
5
+
6
+ main().then((code) => {
7
+ process.exitCode = code;
8
+ });
Binary file
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ const fs = require("node:fs");
4
+ const path = require("node:path");
5
+
6
+ function isFile(candidate) {
7
+ try {
8
+ return fs.statSync(candidate).isFile();
9
+ } catch {
10
+ return false;
11
+ }
12
+ }
13
+
14
+ /**
15
+ * Locate the shaded JavaBytes jar.
16
+ *
17
+ * Order: JAVABYTES_JAR, the jar bundled with the npm package, then the
18
+ * development build in target/.
19
+ */
20
+ function resolveJar(options = {}) {
21
+ const env = options.env || process.env;
22
+ const root = options.root || path.join(__dirname, "..");
23
+
24
+ const candidates = [];
25
+ if (env.JAVABYTES_JAR) {
26
+ candidates.push(path.resolve(env.JAVABYTES_JAR));
27
+ }
28
+ candidates.push(path.join(root, "jar", "javabytes.jar"));
29
+ candidates.push(path.join(root, "..", "target", "javabytes.jar"));
30
+
31
+ return candidates.find(isFile) || null;
32
+ }
33
+
34
+ /**
35
+ * Resolve the java executable. JAVABYTES_JAVA wins, then JAVA_HOME, then PATH.
36
+ */
37
+ function resolveJava(options = {}) {
38
+ const env = options.env || process.env;
39
+ if (env.JAVABYTES_JAVA) {
40
+ return env.JAVABYTES_JAVA;
41
+ }
42
+ if (env.JAVA_HOME) {
43
+ const executable = process.platform === "win32" ? "java.exe" : "java";
44
+ const candidate = path.join(env.JAVA_HOME, "bin", executable);
45
+ if (isFile(candidate)) {
46
+ return candidate;
47
+ }
48
+ }
49
+ return "java";
50
+ }
51
+
52
+ function buildArgs(jar, argv = [], env = process.env) {
53
+ const options = (env.JAVABYTES_JAVA_OPTS || "").trim();
54
+ const jvmArgs = options ? options.split(/\s+/) : [];
55
+ return [...jvmArgs, "-jar", jar, ...argv];
56
+ }
57
+
58
+ /**
59
+ * Spawn the server with inherited stdio so the MCP client owns the pipes.
60
+ * Resolves with the process exit code.
61
+ */
62
+ function main(argv = process.argv.slice(2), env = process.env, root) {
63
+ const jar = resolveJar({ env, root });
64
+ if (!jar) {
65
+ console.error("[javabytes] Cannot find javabytes.jar.");
66
+ console.error("[javabytes] Install a package that bundles the jar, or set JAVABYTES_JAR");
67
+ console.error("[javabytes] to an existing shaded jar (build one with: mvn package).");
68
+ return Promise.resolve(1);
69
+ }
70
+
71
+ const java = resolveJava({ env });
72
+ const { spawn } = require("node:child_process");
73
+ const child = spawn(java, buildArgs(jar, argv, env), {
74
+ stdio: "inherit",
75
+ env,
76
+ windowsHide: true,
77
+ });
78
+
79
+ const forward = (signal) => {
80
+ if (child.exitCode === null && child.signalCode === null) {
81
+ child.kill(signal);
82
+ }
83
+ };
84
+ process.on("SIGINT", () => forward("SIGINT"));
85
+ process.on("SIGTERM", () => forward("SIGTERM"));
86
+
87
+ return new Promise((resolve) => {
88
+ child.on("error", (error) => {
89
+ console.error(`[javabytes] Failed to start '${java}': ${error.message}`);
90
+ if (error.code === "ENOENT") {
91
+ console.error("[javabytes] Install Java 21+ and put it on PATH, or set JAVA_HOME.");
92
+ }
93
+ resolve(127);
94
+ });
95
+ child.on("exit", (code) => {
96
+ resolve(code === null ? 1 : code);
97
+ });
98
+ });
99
+ }
100
+
101
+ module.exports = { resolveJar, resolveJava, buildArgs, main };
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "javabytes-mcp",
3
+ "version": "1.0.0",
4
+ "description": "JavaBytes MCP server: filesystem, MySQL analysis, JavaFX, Spring Boot and JavaScript migration tools over stdio.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/markymakes-dev/javabytes.git",
9
+ "directory": "npm"
10
+ },
11
+ "homepage": "https://github.com/markymakes-dev/javabytes#readme",
12
+ "keywords": [
13
+ "mcp",
14
+ "model-context-protocol",
15
+ "java",
16
+ "mysql",
17
+ "javafx",
18
+ "spring-boot"
19
+ ],
20
+ "bin": {
21
+ "javabytes": "bin/javabytes.js"
22
+ },
23
+ "files": [
24
+ "bin",
25
+ "lib",
26
+ "jar/javabytes.jar",
27
+ "LICENSE",
28
+ "README.md"
29
+ ],
30
+ "scripts": {
31
+ "prepack": "node scripts/copy-jar.js",
32
+ "test": "node --test test/launcher.test.js"
33
+ },
34
+ "engines": {
35
+ "node": ">=18"
36
+ },
37
+ "os": [
38
+ "win32",
39
+ "linux",
40
+ "darwin"
41
+ ]
42
+ }