sympy_intersection
Compute the intersection of two symbolic sets, yielding the set of common elements.
Instructions
Compute intersection of two sets.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| set1 | Yes | First set | |
| set2 | Yes | Second set |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/mcp_sympy/tools.py:956-972 (handler)The actual handler function for the 'sympy_intersection' tool. It takes two string-encoded sets, converts them to SymPy objects via _sympify, computes their Intersection, and returns the result as a string.
def sympy_intersection(set1: str, set2: str) -> str: """Compute intersection of two sets. Args: set1: First set set2: Second set Returns: Intersection as string Example: >>> sympy_intersection("{1,2,3}", "{2,3,4}") "{2, 3}" """ s1 = _sympify(set1) s2 = _sympify(set2) return str(Intersection(s1, s2)) - src/mcp_sympy/tools.py:955-955 (registration)The @mcp.tool() decorator that registers sympy_intersection 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 sympy_intersection to convert string expressions to SymPy objects.
def _sympify(expr: str) -> sympy.Basic: """Convert string expression to SymPy object.""" return sympy.sympify(expr)