sympy_complement
Compute the complement of a subset within a universal set, returning elements in set2 not present in set1.
Instructions
Compute complement of set1 in set2.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| set1 | Yes | Subset | |
| set2 | Yes | Universal set |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/mcp_sympy/tools.py:975-992 (handler)The main handler function for the sympy_complement tool. Takes two string sets, converts them to SymPy objects via _sympify, computes their set complement using SymPy's Complement, and returns the result as a string.
@mcp.tool() def sympy_complement(set1: str, set2: str) -> str: """Compute complement of set1 in set2. Args: set1: Subset set2: Universal set Returns: Complement as string Example: >>> sympy_complement("{1,2}", "{1,2,3,4}") "{3, 4}" """ s1 = _sympify(set1) s2 = _sympify(set2) return str(Complement(s1, s2)) - src/mcp_sympy/tools.py:975-975 (registration)Registration of sympy_complement via the @mcp.tool() decorator on the FastMCP instance 'mcp', which registers it as an MCP tool.
@mcp.tool() - src/mcp_sympy/tools.py:114-116 (helper)Helper function that converts a string expression to a SymPy object using sympy.sympify. Used by sympy_complement to parse the string set arguments.
def _sympify(expr: str) -> sympy.Basic: """Convert string expression to SymPy object.""" return sympy.sympify(expr) - src/mcp_sympy/tools.py:10-10 (schema)Import of SymPy's Complement class, which is used in the function to compute the set complement.
Complement, - src/mcp_sympy/tools.py:119-119 (registration)The FastMCP instance that provides the @mcp.tool() decorator for registering tools.
mcp = fastmcp.FastMCP("mcp-sympy")