|
|
@@ -961,13 +961,87 @@ public class McpServer extends NanoHTTPD {
|
|
|
symja.put("isPrime", "(n) - primality test");
|
|
|
symja.put("fibonacci", "(n) - nth Fibonacci");
|
|
|
symja.put("binomial", "(n,k) - binomial coefficient");
|
|
|
- symja.put("matrix", "{det,inverse,transpose,eigenvalues,rank}");
|
|
|
+ symja.put("limit", "(expr,var,point) - limit of expression");
|
|
|
+ symja.put("series", "(expr,var,point,order) - Taylor series expansion");
|
|
|
+ symja.put("apart", "(expr,var) - partial fraction decomposition");
|
|
|
+ symja.put("together", "(expr) - combine fractions over common denominator");
|
|
|
+ symja.put("trigSimplify", "(expr) - trigonometric simplification");
|
|
|
+ symja.put("sum", "(expr,var,start,end) - summation");
|
|
|
+ symja.put("product", "(expr,var,start,end) - product");
|
|
|
+ symja.put("renderLatex", "(latex) - render LaTeX in console output");
|
|
|
+ JSONObject matrix = new JSONObject();
|
|
|
+ matrix.put("det", "(m)");
|
|
|
+ matrix.put("inverse", "(m)");
|
|
|
+ matrix.put("transpose", "(m)");
|
|
|
+ matrix.put("eigenvalues", "(m)");
|
|
|
+ matrix.put("rank", "(m)");
|
|
|
+ matrix.put("_format", "Matrix format: '{{1,2},{3,4}}'");
|
|
|
+ symja.put("matrix", matrix);
|
|
|
api.put("IJS.Symja", symja);
|
|
|
- api.put("IJS.canvas", "create(w?,h?), getContext(), getSize(), width(), height(), clear(), fill(color), size(w,h), loop(cb), stop() — create() without args auto-fills fullscreen panel");
|
|
|
- api.put("IJS.input", "xy(event) — convert touch event to canvas coords, onTouchStart/Move/End(cb)");
|
|
|
- api.put("IJS.io", "read(filename), write(filename,content), list(), delete(filename)");
|
|
|
- api.put("IJS.audio", "beep(freq,dur,type), playNote(note,oct,dur), playMelody(melody,tempo)");
|
|
|
- api.put("IJS.ui", "close(), setBackground(color)");
|
|
|
+
|
|
|
+ // Expanded sub-object documentations
|
|
|
+ JSONObject canvas = new JSONObject();
|
|
|
+ canvas.put("create", "(w?,h?) — create canvas. No args = auto-fill fullscreen panel. Returns CanvasRenderingContext2D");
|
|
|
+ canvas.put("getContext", "() — get the CanvasRenderingContext2D for direct drawing");
|
|
|
+ canvas.put("width", "() — canvas logical width in CSS pixels (for responsive layout)");
|
|
|
+ canvas.put("height", "() — canvas logical height in CSS pixels");
|
|
|
+ canvas.put("getSize", "() → {width, height} — shorthand for both dimensions");
|
|
|
+ canvas.put("clear", "() — clear entire canvas");
|
|
|
+ canvas.put("fill", "(color) — fill canvas with a solid color, e.g. '#1a1a2e'");
|
|
|
+ canvas.put("size", "(w,h) — resize canvas logical dimensions");
|
|
|
+ canvas.put("loop", "(callback) — start rAF loop, calls callback each frame");
|
|
|
+ canvas.put("stop", "() — cancel animation loop");
|
|
|
+ api.put("IJS.canvas", canvas);
|
|
|
+
|
|
|
+ JSONObject inputObj = new JSONObject();
|
|
|
+ inputObj.put("xy", "(event) → {x,y} — convert touch/client coords to canvas logical coords. ALWAYS use this!");
|
|
|
+ inputObj.put("onTouchStart", "(cb) — register touchstart callback");
|
|
|
+ inputObj.put("onTouchMove", "(cb) — register touchmove callback");
|
|
|
+ inputObj.put("onTouchEnd", "(cb) — register touchend callback, auto-binds DOM events");
|
|
|
+ inputObj.put("_example", "IJS.input.onTouchEnd(function(e) { var p = IJS.input.xy(e); /* p.x, p.y */ })");
|
|
|
+ api.put("IJS.input", inputObj);
|
|
|
+
|
|
|
+ JSONObject ioObj = new JSONObject();
|
|
|
+ ioObj.put("read", "(filename) → string — read file from app data dir, empty string if missing");
|
|
|
+ ioObj.put("write", "(filename, content) → bool — write string to file");
|
|
|
+ ioObj.put("list", "() → [string] — list all filenames in app data dir");
|
|
|
+ ioObj.put("delete", "(filename) → bool — delete file");
|
|
|
+ ioObj.put("_note", "Stored in Android app data directory. Persists across sessions. WebView only.");
|
|
|
+ api.put("IJS.io", ioObj);
|
|
|
+
|
|
|
+ JSONObject audioObj = new JSONObject();
|
|
|
+ audioObj.put("beep", "(freq, duration, type) — play a tone. type: 'sine','square','sawtooth','triangle'");
|
|
|
+ audioObj.put("playNote", "(note, octave, duration) — play a note. note: 'C'..'B', octave: 3-6");
|
|
|
+ audioObj.put("playMelody", "(melody, tempo) — play [{note,octave,dur},...]. 'R'=rest");
|
|
|
+ audioObj.put("_example", "IJS.audio.playMelody([{note:'C',octave:5,dur:1},{note:'E',octave:5,dur:1}], 120)");
|
|
|
+ api.put("IJS.audio", audioObj);
|
|
|
+
|
|
|
+ JSONObject uiObj = new JSONObject();
|
|
|
+ uiObj.put("close", "() — close the fullscreen panel. Override for cleanup on close");
|
|
|
+ uiObj.put("setBackground", "(color) — set panel CSS background color");
|
|
|
+ uiObj.put("_cleanup_pattern", "var orig=IJS.ui.close; IJS.ui.close=function(){stopMusic();orig.call(IJS.ui);}");
|
|
|
+ api.put("IJS.ui", uiObj);
|
|
|
+
|
|
|
+ JSONObject exec = new JSONObject();
|
|
|
+ exec.put("_title", "Execution Environments");
|
|
|
+ exec.put("WebView", "Full API: Symja + canvas + input + io + audio + ui. Libraries (_/Math.seedrandom/Matter) available.");
|
|
|
+ exec.put("Rhino_MCP", "Only IJS.Symja sub-object. Use for pure computation plugins. No DOM, no canvas, no libraries.");
|
|
|
+ exec.put("function_sig", "calculate(inputs, IJS) — inputs is {name:value,...}, IJS is the API namespace object");
|
|
|
+ exec.put("return", "Return a Symja expression string, or 'Null' for print-only (Symja.print) plugins");
|
|
|
+ api.put("execution", exec);
|
|
|
+
|
|
|
+ JSONObject schema = new JSONObject();
|
|
|
+ schema.put("_title", "Plugin JSON Schema");
|
|
|
+ schema.put("id", "string (req)");
|
|
|
+ schema.put("name", "string (req)");
|
|
|
+ schema.put("jsCode", "string (req) — function calculate(inputs, IJS) { ... }");
|
|
|
+ schema.put("mode", "'inline'|'fullscreen' (default:'inline')");
|
|
|
+ schema.put("icon", "string (default:'🔌')");
|
|
|
+ schema.put("command", "string");
|
|
|
+ schema.put("description", "string");
|
|
|
+ schema.put("inputs", "[{name,label,defaultValue,placeholder,type}]");
|
|
|
+ api.put("schema", schema);
|
|
|
+
|
|
|
return api.toString(2);
|
|
|
} catch (Exception e) {
|
|
|
return "{}";
|