sympy_log_base
Compute the logarithm of a symbolic expression with a specified base.
Instructions
Logarithm with specified base.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expr | Yes | Expression | |
| base | Yes | Logarithm base |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/mcp_sympy/tools.py:1072-1087 (handler)The tool handler function that implements sympy_log_base. It takes string expressions for the value and base, sympifies them, and returns the log via SymPy's log() function with a specified base.
@mcp.tool() def sympy_log_base(expr: str, base: str) -> str: """Logarithm with specified base. Args: expr: Expression base: Logarithm base Returns: log_base(expr) as string Example: >>> sympy_log_base("100", "10") "2" """ return str(log(_sympify(expr), _sympify(base))) - src/mcp_sympy/tools.py:1072-1072 (registration)The @mcp.tool() decorator registers sympy_log_base as an MCP tool on the FastMCP instance.
@mcp.tool() - src/mcp_sympy/tools.py:114-116 (helper)The _sympify helper converts string expressions into SymPy objects, used by sympy_log_base to parse the expr and base arguments.
def _sympify(expr: str) -> sympy.Basic: """Convert string expression to SymPy object.""" return sympy.sympify(expr) - src/mcp_sympy/tools.py:1073-1086 (schema)The function signature and docstring serve as the schema: it accepts two string parameters (expr and base) and returns a string. FastMCP infers the input schema from type hints.
def sympy_log_base(expr: str, base: str) -> str: """Logarithm with specified base. Args: expr: Expression base: Logarithm base Returns: log_base(expr) as string Example: >>> sympy_log_base("100", "10") "2" """