sympy_expand_log
Expand logarithmic expressions into a sum of simpler logarithms using symbolic algebra.
Instructions
Expand logarithmic expressions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expr | Yes | String logarithmic expression |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/mcp_sympy/tools.py:259-273 (handler)The handler function for the sympy_expand_log tool. It takes a string expression, converts it to a SymPy object via _sympify (which calls sympy.sympify), then applies sympy.expand_log, and returns the result as a string.
@mcp.tool() def sympy_expand_log(expr: str) -> str: """Expand logarithmic expressions. Args: expr: String logarithmic expression Returns: Expanded expression Example: >>> sympy_expand_log("log(x*y)") "log(x) + log(y)" """ return str(expand_log(_sympify(expr))) - src/mcp_sympy/tools.py:259-259 (registration)The tool is registered via the @mcp.tool() decorator on the FastMCP instance 'mcp' (created at line 119: mcp = fastmcp.FastMCP('mcp-sympy')).
@mcp.tool() - src/mcp_sympy/tools.py:114-116 (helper)Helper function _sympify converts input string to a SymPy object using sympy.sympify, used by the handler.
def _sympify(expr: str) -> sympy.Basic: """Convert string expression to SymPy object.""" return sympy.sympify(expr) - src/mcp_sympy/tools.py:259-273 (schema)Input/output schema is defined by the function signature: takes a string (expr) and returns a string.
@mcp.tool() def sympy_expand_log(expr: str) -> str: """Expand logarithmic expressions. Args: expr: String logarithmic expression Returns: Expanded expression Example: >>> sympy_expand_log("log(x*y)") "log(x) + log(y)" """ return str(expand_log(_sympify(expr)))