sympy_expand_complex
Expand a symbolic expression into its complex expanded form, distributing products and sums for simplification.
Instructions
Expand complex.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expr | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/mcp_sympy/tools.py:2439-2441 (handler)The tool handler function for 'sympy_expand_complex'. It takes a string expression, converts it to a SymPy object via _sympify, applies expand_complex, and returns the result as a string.
def sympy_expand_complex(expr: str) -> str: """Expand complex.""" return str(expand_complex(_sympify(expr))) - src/mcp_sympy/tools.py:2439-2439 (schema)The function signature defines the schema: takes a single string parameter 'expr' and returns a string. The @mcp.tool() decorator registers it as an MCP tool.
def sympy_expand_complex(expr: str) -> str: - src/mcp_sympy/tools.py:2439-2439 (registration)The tool is registered as an MCP tool via the @mcp.tool() decorator on line 2438. 'mcp' is a FastMCP instance defined on line 119.
def sympy_expand_complex(expr: str) -> str: - src/mcp_sympy/tools.py:114-116 (helper)The _sympify helper converts a string expression to a SymPy object (sympy.Basic), used by the tool handler.
def _sympify(expr: str) -> sympy.Basic: """Convert string expression to SymPy object.""" return sympy.sympify(expr) - src/mcp_sympy/tools.py:66-67 (helper)The expand_complex function is imported from sympy on line 66, which is the core operation used in the tool handler.
expand_complex, expand_log,