query-wolfram-alpha
Answer complex mathematical questions and perform symbolic computations using computational intelligence. Submit queries to solve problems requiring advanced calculation or analysis.
Instructions
Use Wolfram Alpha to answer a question. This tool should be used when you need complex math or symbolic intelligence.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- src/mcp_wolfram_alpha/server.py:89-125 (handler)Executes the 'query-wolfram-alpha' tool: calls the Wolfram client with the query, processes the response pods and subpods to extract plaintext and images (downloading and base64 encoding images), and returns a list of TextContent or ImageContent.if name == "query-wolfram-alpha": results: list[types.TextContent | types.ImageContent | types.EmbeddedResource] = [] query = arguments.get("query") if not query: raise ValueError("Missing 'query' parameter for Wolfram Alpha tool") try: response = await client.aquery(query) except Exception as e: raise Exception("Failed to query Wolfram Alpha") from e try: async with httpx.AsyncClient() as http_client: for pod in response.pods: for subpod in pod.subpods: if subpod.plaintext: # Handle text content results.append(types.TextContent( type="text", text=subpod.plaintext )) elif subpod.img: # Handle image content img_url = subpod.img.get("src") if img_url: img_response = await http_client.get(img_url) if img_response.status_code == 200: img_base64 = base64.b64encode(img_response.content).decode('utf-8') results.append(types.ImageContent( type="image", data=img_base64, mimeType="image/png" )) except Exception as e: raise Exception("Failed to parse response from Wolfram Alpha") from e return results
- src/mcp_wolfram_alpha/server.py:64-75 (registration)Registers the 'query-wolfram-alpha' tool in the list_tools() method, specifying its name, description, and input JSON schema.types.Tool( name="query-wolfram-alpha", description="Use Wolfram Alpha to answer a question. This tool should be used when you need complex math or symbolic intelligence.", inputSchema={ "type": "object", "properties": { "query": {"type": "string"} # Correct property: `query` with type `string` }, "required": ["query"] # Marking `query` as required }, ) ]
- JSON schema for tool input: requires a single 'query' property of type string.inputSchema={ "type": "object", "properties": { "query": {"type": "string"} # Correct property: `query` with type `string` }, "required": ["query"] # Marking `query` as required },
- src/mcp_wolfram_alpha/server.py:6-6 (helper)Imports the WolframAlpha client used by the tool handler to perform the actual API query.from .wolfram_client import client