Symbolic Algebra MCP Server

Symbolic Algebra MCP Server

A Model Context Protocol server that enables LLMs to autonomously perform symbolic mathematics and computer algebra through SymPy's functionality for manipulating mathematical expressions and equations.

Category
访问服务器

Tools

solve_linear_system

Solves a system of linear equations using SymPy's linsolve. Args: expr_keys: The keys of the expressions (previously introduced) forming the system. var_names: The names of the variables to solve for. domain: The domain to solve in (Domain.COMPLEX, Domain.REAL, etc.). Defaults to Domain.COMPLEX. Returns: A LaTeX string representing the solution set. Returns an error message string if issues occur.

solve_nonlinear_system

Solves a system of nonlinear equations using SymPy's nonlinsolve. Args: expr_keys: The keys of the expressions (previously introduced) forming the system. var_names: The names of the variables to solve for. domain: The domain to solve in (Domain.COMPLEX, Domain.REAL, etc.). Defaults to Domain.COMPLEX. Returns: A LaTeX string representing the solution set. Returns an error message string if issues occur.

introduce_function

Introduces a SymPy function variable and stores it. Takes a function name and creates a SymPy Function object for use in defining differential equations. Example: {func_name: "f"} will create the function f(x), f(t), etc. that can be used in expressions Returns: The name of the created function.

create_custom_metric

Creates a custom metric tensor from provided components and symbols.

calculate_gradient

Calculates the gradient of a scalar field using SymPy's gradient function. Args: scalar_field_key: The key of the scalar field expression. Example: # First create a coordinate system create_coordinate_system("R") # Create a scalar field f = x^2 + y^2 + z^2 scalar_field = introduce_expression("R_x**2 + R_y**2 + R_z**2") # Calculate gradient grad_result = calculate_gradient(scalar_field) # Returns (2x, 2y, 2z) Returns: A key for the gradient vector field expression.

substitute_expression

Substitutes a variable in an expression with another expression using SymPy's subs method. Args: expr_key: The key of the expression to perform substitution on. var_name: The name of the variable to substitute. replacement_expr_key: The key of the expression to substitute in place of the variable. Example: # Create variables x and y intro("x", [], []) intro("y", [], []) # Create expressions expr1 = introduce_expression("x**2 + y**2") expr2 = introduce_expression("sin(x)") # Substitute y with sin(x) in x^2 + y^2 result = substitute_expression(expr1, "y", expr2) # Results in x^2 + sin^2(x) Returns: A key for the resulting expression after substitution.

intro

Introduces a sympy variable with specified assumptions and stores it. Takes a variable name and a list of positive and negative assumptions.

intro_many

Introduces multiple sympy variables with specified assumptions and stores them. Takes a list of VariableDefinition objects for the 'variables' parameter. Each object in the list specifies: - var_name: The name of the variable (string). - pos_assumptions: A list of positive assumption strings (e.g., ["real", "positive"]). - neg_assumptions: A list of negative assumption strings (e.g., ["complex"]). The JSON payload for the 'variables' argument should be a direct list of these objects, for example: ```json [ { "var_name": "x", "pos_assumptions": ["real", "positive"], "neg_assumptions": ["complex"] }, { "var_name": "y", "pos_assumptions": [], "neg_assumptions": ["commutative"] } ] ``` The assumptions must be consistent, so a real number is not allowed to be non-commutative. Prefer this over intro() for multiple variables because it's more efficient.

introduce_expression

Parses a sympy expression string using available local variables and stores it. Assigns it to either a temporary name (expr_0, expr_1, etc.) or a user-specified global name. Uses Sympy parse_expr to parse the expression string. Applies default Sympy canonicalization rules unless canonicalize is False. For equations (x^2 = 1) make the input string "Eq(x^2, 1") not "x^2 == 1" Examples: {expr_str: "Eq(x^2 + y^2, 1)"} {expr_str: "Matrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11)))"} {expr_str: "pi+e", "expr_var_name": "z"}

print_latex_expression

Prints a stored expression in LaTeX format, along with variable assumptions.

solve_algebraically

Solves an equation (expression = 0) algebraically for a given variable. Args: expr_key: The key of the expression (previously introduced) to be solved. solve_for_var_name: The name of the variable (previously introduced) to solve for. domain: The domain to solve in: Domain.COMPLEX, Domain.REAL, Domain.INTEGERS, or Domain.NATURALS. Defaults to Domain.COMPLEX. Returns: A LaTeX string representing the set of solutions. Returns an error message string if issues occur.

dsolve_ode

Solves an ordinary differential equation using SymPy's dsolve function. Args: expr_key: The key of the expression (previously introduced) containing the differential equation. func_name: The name of the function (previously introduced) to solve for. hint: Optional solving method from ODEHint enum. If None, SymPy will try to determine the best method. Example: # First introduce a variable and a function intro("x", [Assumption.REAL], []) introduce_function("f") # Create a second-order ODE: f''(x) + 9*f(x) = 0 expr_key = introduce_expression("Derivative(f(x), x, x) + 9*f(x)") # Solve the ODE result = dsolve_ode(expr_key, "f") # Returns solution with sin(3*x) and cos(3*x) terms Returns: A LaTeX string representing the solution. Returns an error message string if issues occur.

pdsolve_pde

Solves a partial differential equation using SymPy's pdsolve function. Args: expr_key: The key of the expression (previously introduced) containing the PDE. If the expression is not an equation (Eq), it will be interpreted as PDE = 0. func_name: The name of the function (previously introduced) to solve for. This should be a function of multiple variables. Example: # First introduce variables and a function intro("x", [Assumption.REAL], []) intro("y", [Assumption.REAL], []) introduce_function("f") # Create a PDE: 1 + 2*(ux/u) + 3*(uy/u) = 0 expr_key = introduce_expression( "Eq(1 + 2*Derivative(f(x, y), x)/f(x, y) + 3*Derivative(f(x, y), y)/f(x, y), 0)" ) # Solve the PDE result = pdsolve_pde(expr_key, "f") # Returns solution with exponential terms and arbitrary function Returns: A LaTeX string representing the solution. Returns an error message string if issues occur.

create_predefined_metric

Creates a predefined spacetime metric.

search_predefined_metrics

Searches for predefined metrics in einsteinpy.symbolic.predefined.

calculate_tensor

Calculates a tensor from a metric using einsteinpy.symbolic.

print_latex_tensor

Prints a stored tensor expression in LaTeX format.

simplify_expression

Simplifies a mathematical expression using SymPy's simplify function. Args: expr_key: The key of the expression (previously introduced) to simplify. Example: # Introduce variables intro("x", [Assumption.REAL], []) intro("y", [Assumption.REAL], []) # Create an expression to simplify: sin(x)^2 + cos(x)^2 expr_key = introduce_expression("sin(x)**2 + cos(x)**2") # Simplify the expression simplified = simplify_expression(expr_key) # Returns 1 Returns: A key for the simplified expression.

integrate_expression

Integrates an expression with respect to a variable using SymPy's integrate function. Args: expr_key: The key of the expression (previously introduced) to integrate. var_name: The name of the variable to integrate with respect to. lower_bound: Optional lower bound for definite integration. upper_bound: Optional upper bound for definite integration. Example: # Introduce a variable intro("x", [Assumption.REAL], []) # Create an expression to integrate: x^2 expr_key = introduce_expression("x**2") # Indefinite integration indefinite_result = integrate_expression(expr_key, "x") # Returns x³/3 # Definite integration from 0 to 1 definite_result = integrate_expression(expr_key, "x", "0", "1") # Returns 1/3 Returns: A key for the integrated expression.

differentiate_expression

Differentiates an expression with respect to a variable using SymPy's diff function. Args: expr_key: The key of the expression (previously introduced) to differentiate. var_name: The name of the variable to differentiate with respect to. order: The order of differentiation (default is 1 for first derivative). Example: # Introduce a variable intro("x", [Assumption.REAL], []) # Create an expression to differentiate: x^3 expr_key = introduce_expression("x**3") # First derivative first_deriv = differentiate_expression(expr_key, "x") # Returns 3x² # Second derivative second_deriv = differentiate_expression(expr_key, "x", 2) # Returns 6x Returns: A key for the differentiated expression.

create_coordinate_system

Creates a 3D coordinate system for vector calculus operations. Args: name: The name for the coordinate system. coord_names: Optional list of coordinate names (3 names for x, y, z). If not provided, defaults to [name+'_x', name+'_y', name+'_z']. Example: # Create a coordinate system coord_sys = create_coordinate_system("R") # Creates a coordinate system R with coordinates R_x, R_y, R_z # Create a coordinate system with custom coordinate names coord_sys = create_coordinate_system("C", ["rho", "phi", "z"]) Returns: The name of the created coordinate system.

create_vector_field

Creates a vector field in the specified coordinate system. Args: coord_sys_name: The name of the coordinate system to use. component_x: String expression for the x-component of the vector field. component_y: String expression for the y-component of the vector field. component_z: String expression for the z-component of the vector field. Example: # First create a coordinate system create_coordinate_system("R") # Create a vector field F = (y, -x, z) vector_field = create_vector_field("R", "R_y", "-R_x", "R_z") Returns: A key for the vector field expression.

calculate_curl

Calculates the curl of a vector field using SymPy's curl function. Args: vector_field_key: The key of the vector field expression. Example: # First create a coordinate system create_coordinate_system("R") # Create a vector field F = (y, -x, 0) vector_field = create_vector_field("R", "R_y", "-R_x", "0") # Calculate curl curl_result = calculate_curl(vector_field) # Returns (0, 0, -2) Returns: A key for the curl expression.

calculate_divergence

Calculates the divergence of a vector field using SymPy's divergence function. Args: vector_field_key: The key of the vector field expression. Example: # First create a coordinate system create_coordinate_system("R") # Create a vector field F = (x, y, z) vector_field = create_vector_field("R", "R_x", "R_y", "R_z") # Calculate divergence div_result = calculate_divergence(vector_field) # Returns 3 Returns: A key for the divergence expression.

convert_to_units

Converts a quantity to the given target units using sympy.physics.units.convert_to. Args: expr_key: The key of the expression (previously introduced) to convert. target_units: List of unit names as strings (e.g., ["meter", "1/second"]). unit_system: Optional unit system (from UnitSystem enum). Defaults to SI. The following units are available by default: SI base units: meter, second, kilogram, ampere, kelvin, mole, candela Length: kilometer, millimeter Mass: gram Energy: joule Force: newton Pressure: pascal Power: watt Electric: coulomb, volt, ohm, farad, henry Constants: speed_of_light, gravitational_constant, planck IMPORTANT: For compound units like meter/second, you must separate the numerator and denominator into separate units in the list. For example: - For meter/second: use ["meter", "1/second"] - For newton*meter: use ["newton", "meter"] - For kilogram*meter²/second²: use ["kilogram", "meter**2", "1/second**2"] Example: # Convert speed of light to kilometers per hour expr_key = introduce_expression("speed_of_light") result = convert_to_units(expr_key, ["kilometer", "1/hour"]) # Returns approximately 1.08e9 kilometer/hour # Convert gravitational constant to CGS units expr_key = introduce_expression("gravitational_constant") result = convert_to_units(expr_key, ["centimeter**3", "1/gram", "1/second**2"], UnitSystem.CGS) SI prefixes (femto, pico, nano, micro, milli, centi, deci, deca, hecto, kilo, mega, giga, tera) can be used directly with base units. Returns: A key for the converted expression, or an error message.

quantity_simplify_units

Simplifies a quantity with units using sympy's built-in simplify method for Quantity objects. Args: expr_key: The key of the expression (previously introduced) to simplify. unit_system: Optional unit system (from UnitSystem enum). Not used with direct simplify method. The following units are available by default: SI base units: meter, second, kilogram, ampere, kelvin, mole, candela Length: kilometer, millimeter Mass: gram Energy: joule Force: newton Pressure: pascal Power: watt Electric: coulomb, volt, ohm, farad, henry Constants: speed_of_light, gravitational_constant, planck Example: # Simplify force expressed in base units expr_key = introduce_expression("kilogram*meter/second**2") result = quantity_simplify_units(expr_key) # Returns newton (as N = kg·m/s²) # Simplify a complex expression with mixed units expr_key = introduce_expression("joule/(kilogram*meter**2/second**2)") result = quantity_simplify_units(expr_key) # Returns a dimensionless quantity (1) # Simplify electrical power expression expr_key = introduce_expression("volt*ampere") result = quantity_simplify_units(expr_key) # Returns watt Example with Speed of Light: # Introduce the speed of light c_key = introduce_expression("speed_of_light") # Convert to kilometers per hour km_per_hour_key = convert_to_units(c_key, ["kilometer", "1/hour"]) # Simplify to get the numerical value simplified_key = quantity_simplify_units(km_per_hour_key) # Print the result print_latex_expression(simplified_key) # Shows the numeric value of speed of light in km/h Returns: A key for the simplified expression, or an error message.

create_matrix

Creates a SymPy matrix from the provided data. Args: matrix_data: A list of lists representing the rows and columns of the matrix. Each element can be a number or a string expression. matrix_var_name: Optional name for storing the matrix. If not provided, a sequential name will be generated. Example: # Create a 2x2 matrix with numeric values matrix_key = create_matrix([[1, 2], [3, 4]], "M") # Create a matrix with symbolic expressions (assuming x, y are defined) matrix_key = create_matrix([["x", "y"], ["x*y", "x+y"]]) Returns: A key for the stored matrix.

matrix_determinant

Calculates the determinant of a matrix using SymPy's det method. Args: matrix_key: The key of the matrix to calculate the determinant for. Example: # Create a matrix matrix_key = create_matrix([[1, 2], [3, 4]]) # Calculate its determinant det_key = matrix_determinant(matrix_key) # Results in -2 Returns: A key for the determinant expression.

matrix_inverse

Calculates the inverse of a matrix using SymPy's inv method. Args: matrix_key: The key of the matrix to invert. Example: # Create a matrix matrix_key = create_matrix([[1, 2], [3, 4]]) # Calculate its inverse inv_key = matrix_inverse(matrix_key) Returns: A key for the inverted matrix.

matrix_eigenvalues

Calculates the eigenvalues of a matrix using SymPy's eigenvals method. Args: matrix_key: The key of the matrix to calculate eigenvalues for. Example: # Create a matrix matrix_key = create_matrix([[1, 2], [2, 1]]) # Calculate its eigenvalues evals_key = matrix_eigenvalues(matrix_key) Returns: A key for the eigenvalues expression (usually a dictionary mapping eigenvalues to their multiplicities).

matrix_eigenvectors

Calculates the eigenvectors of a matrix using SymPy's eigenvects method. Args: matrix_key: The key of the matrix to calculate eigenvectors for. Example: # Create a matrix matrix_key = create_matrix([[1, 2], [2, 1]]) # Calculate its eigenvectors evecs_key = matrix_eigenvectors(matrix_key) Returns: A key for the eigenvectors expression (usually a list of tuples (eigenvalue, multiplicity, [eigenvectors])).

README

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选