sympy_factorint
Factorize an integer into its prime factors. Input an integer to obtain its prime factorization output.
Instructions
Integer factorization.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | Yes | Integer |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/mcp_sympy/tools.py:1634-1647 (handler)The handler function for the sympy_factorint tool. Takes an integer as string, calls sympy.factorint(int(n)) to compute prime factorization, and returns the result as a string.
def sympy_factorint(n: str) -> str: """Integer factorization. Args: n: Integer Returns: Prime factorization as string Example: >>> sympy_factorint("12") "{2: 2, 3: 1}" """ return str(sympy.factorint(int(n))) - src/mcp_sympy/tools.py:1633-1633 (registration)The @mcp.tool() decorator that registers sympy_factorint as an MCP tool on the FastMCP server instance.
@mcp.tool() - src/mcp_sympy/tools.py:114-116 (helper)The _sympify helper function used by other tools (though sympy_factorint uses int() directly for parsing).
def _sympify(expr: str) -> sympy.Basic: """Convert string expression to SymPy object.""" return sympy.sympify(expr) - src/mcp_sympy/tools.py:1635-1646 (schema)The docstring serves as the schema/interface definition: expects a string argument 'n' representing an integer, returns a string representation of the prime factorization dict.
"""Integer factorization. Args: n: Integer Returns: Prime factorization as string Example: >>> sympy_factorint("12") "{2: 2, 3: 1}" """