sympy_zeta
Compute the Riemann zeta function of a symbolic expression, providing exact algebraic results.
Instructions
Riemann zeta function.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| s | Yes | Expression |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/mcp_sympy/tools.py:1398-1412 (handler)Handler function for the sympy_zeta tool. Converts input string to a SymPy expression and evaluates the Riemann zeta function, returning the result as a string.
@mcp.tool() def sympy_zeta(s: str) -> str: """Riemann zeta function. Args: s: Expression Returns: zeta(s) as string Example: >>> sympy_zeta("2") "pi**2/6" """ return str(zeta(_sympify(s))) - src/mcp_sympy/tools.py:1398-1398 (registration)Registration of sympy_zeta as an MCP tool via the @mcp.tool() decorator on the FastMCP instance.
@mcp.tool() - src/mcp_sympy/tools.py:114-116 (helper)Helper function used by sympy_zeta to convert string input to a SymPy expression.
def _sympify(expr: str) -> sympy.Basic: """Convert string expression to SymPy object.""" return sympy.sympify(expr) - src/mcp_sympy/tools.py:110-110 (schema)The zeta function is imported from sympy and used in the handler.
zeta, - tests/test_tools.py:269-272 (helper)Test case for sympy_zeta verifying that zeta(2) returns pi**2/6.
def test_zeta(self): """Test zeta function.""" result = tools.sympy_zeta("2") assert "pi**2/6" == result