sympy_match
Matches a symbolic expression against a pattern to determine structural equivalence.
Instructions
Match expression to pattern.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expr | Yes | ||
| pattern | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/mcp_sympy/tools.py:2352-2354 (handler)The handler function that executes the sympy_match tool logic. It takes an expression string and a pattern string, converts both to SymPy objects via _sympify(), and returns the result of calling .match() on the expression against the pattern.
def sympy_match(expr: str, pattern: str) -> str: """Match expression to pattern.""" return str(_sympify(expr).match(_sympify(pattern))) - src/mcp_sympy/tools.py:2351-2351 (registration)The @mcp.tool() decorator registers sympy_match as an MCP tool on the FastMCP server instance.
@mcp.tool() - src/mcp_sympy/tools.py:114-116 (helper)The _sympify helper function converts string expressions to SymPy objects, used by the sympy_match handler.
def _sympify(expr: str) -> sympy.Basic: """Convert string expression to SymPy object.""" return sympy.sympify(expr) - src/mcp_sympy/tools.py:2352-2352 (schema)The function signature defines the schema: expr (str) and pattern (str) parameters, with a str return type.
def sympy_match(expr: str, pattern: str) -> str: