sympy_im
Extract the imaginary part of a complex symbolic expression using SymPy. Provide the expression as input to compute its imaginary component.
Instructions
Imaginary part.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"expr": "<expr>"
},
"name": "sympy_im"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expr | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/mcp_sympy/tools.py:2215-2218 (handler)The tool 'sympy_im' is registered via @mcp.tool() decorator and computes the imaginary part of a SymPy expression. The function accepts a string expression, converts it via _sympify(), and returns sympy.im(...) as a string.
@mcp.tool() def sympy_im(expr: str) -> str: """Imaginary part.""" return str(sympy.im(_sympify(expr))) - src/mcp_sympy/tools.py:114-116 (helper)The _sympify() helper converts a string expression into a SymPy object, used by sympy_im to parse input.
def _sympify(expr: str) -> sympy.Basic: """Convert string expression to SymPy object.""" return sympy.sympify(expr) - src/mcp_sympy/tools.py:119-119 (registration)The FastMCP instance 'mcp' is created here; the @mcp.tool() decorator on sympy_im registers it with this MCP server.
mcp = fastmcp.FastMCP("mcp-sympy")