Introduction¶
In DSH plugin development, handling complex mathematical visualizations usually requires introducing heavyweight rendering libraries. xby-mathematical-visualization is a JSXGraph-based MCP protocol server designed to provide agents with ready-to-use mathematical plotting capabilities. It provides 13 tools that cover needs from basic function plotting to vector field analysis, and is suitable for educational mathematics, engineering, and scientific applications.
Core Features¶
The plugin provides the following six core features:
- set_xby_apikey: Set the API key in chat. The key is automatically persisted and remains valid after restarting the DSH process.
- generate_function_graph: Function plotting tool. Supports rendering one or more functions, with configurable colors, labels, and domain, and includes features such as tangents, derivative traces, and integral bands.
- generate_parametric_curve: Parametric curve tool. Used to plot curves defined by x(t) and y(t), such as circles, cycloids, Lissajous figures, or paths describing parametric motion.
- generate_geometry_diagram: Generates interactive geometry diagrams. Supports creating points, lines, circles, polygons, angles, and vectors, and is suitable for visualizing geometric concepts, theorems, and constructions (such as triangles, perpendicular lines, and angle bisectors).
- generate_vector_field: Generates a vector field visualization. Displays arrows on a 2D plane to show direction and magnitude, with support for streamlines, singular points, and color-coded magnitudes. It is commonly used to visualize gradient fields, flow fields, or electromagnetic fields.
- generate_linear_system: Linear system tool. Used to plot linear equations and inequalities, automatically mark intersection points, shade inequality regions, or mark the optimal solution of an objective function.
Key Type Requirements¶
When calling the features above, the type requirements must be strictly followed; otherwise, rendering will fail:
- Numeric Types:
points[].x,points[].y,domain[],integralBounds[],tMin,tMax,startX,startY,fieldFunction.dx,fieldFunction.dymust be numbers (for example,3.14159) and must not be strings. - String Types:
lines[].point1,lines[].point2,polygons[].vertices,angles[].point1,angles[].vertex,angles[].point2must be strings (for example,"A") and must not be coordinate arrays.
Typical Usage¶
The following are invocation examples based on generate_function_graph and generate_geometry_diagram.
1. Plot a Basic Function
{
"functions": [
{ "expression": "x^2" }
]
}
2. Plot a Parametric Curve (Unit Circle)
{
"curves": [
{
"xExpression": "Math.cos(t)",
"yExpression": "Math.sin(t)",
"tMin": 0,
"tMax": 6.283185307179586
}
]
}
3. Generate a Triangle with Labeled Vertices
{
"points": [
{ "x": 0, "y": 0, "name": "A" },
{ "x": 3, "y": 0, "name": "B" },
{ "x": 1.5, "y": 2.6, "name": "C" }
],
"lines": [
{ "point1": "A", "point2": "B" },
{ "point1": "B", "point2": "C" },
{ "point1": "C", "point2": "A" }
],
"polygons": [
{ "vertices": ["A", "B", "C"], "fillOpacity": 0.2 }
]
}
4. Plot a Vector Field
{
"fieldFunction": {
"dx": "-y",
"dy": "x"
},
"streamlines": [
{ "startX": 0, "startY": 0 }
]
}
Use Cases and Notes¶
- Use Cases: This plugin is well suited for educators, mathematical modelers, and developers who need to quickly visualize mathematical concepts. Whether plotting tangents or integral regions in calculus, or vector fields in physics, it can provide intuitive interactive diagrams.
- Notes: Because the plugin runs with the permissions of the current DSH process, be sure to review the source code and license (MIT) before installing it. When passing parameters, strictly distinguish between numeric types (coordinate values) and string types (point names) to avoid plotting issues caused by type errors.
Summary¶
xby-mathematical-visualization is a lightweight mathematical visualization toolkit. With it, developers can invoke plotting capabilities directly without integrating the complex JSXGraph library into DSH plugins.