Math AI Agent
A prompt chat webapp that drives an LLM call inside an agentic loop using
the calculator_mcp MCP server for arithmetic operations. The key constraint is
that the LLM is given explicit system instructions to use the calculator_mcp
for any arithmetic operations.
Features
- FastAPI web UI — simple form-based interface for submitting prompts
- MCP client — connects to a remote calculator MCP server with optional OAuth authentication
- Configurable — MCP server URL, OAuth settings, LLM endpoint and model,
and logging are all driven by
config.yaml - Plain-text answers — the model is instructed to reply without LaTeX or
Markdown, since the web UI renders answers in a plain
<textarea>
AI Disclaimer
This project includes code and documentation created with the assistance of AI tools. For details on usage, limits, and review practices, please see the AI Disclaimer.
Installation
Prerequisites
- UNIX OS (e.g., macOS, Linux)
- curl 8.7+
- pip 26.2+
- poetry 2.4+
- python 3.14+
PyPI Package Installation
IMPORTANT: release versioning was recently reset to start again at version 0.0.1. Uninstall any previously installed version first.
- Uninstall any previously installed release
pip uninstall math-ai-agent
# purging the cache is recommended as well
pip cache purge
- Install into the user's home environment
# install "math-ai-agent" and dependencies into user local pip environment
# NOTE: use --no-cache-dir to avoid issues with an earlier cached version
pip --no-cache-dir install -U --user math-ai-agent --verbose
- Confirm the installed version matches the latest GitHub release at math-ai-agent/releases
# show the installed version
pip show math-ai-agent
Git Clone Installation
gitclone and install local project package usingpoetry
# use local `dev` folder to install the project
mkdir -p ~/dev || exit; cd ~/dev
git clone https://github.com/rubensgomes-org/math-ai-agent.git
# change to project git local directory
cd math-ai-agent
# ensure we are at the project git local root folder
cd $(git rev-parse --show-toplevel) || exit
poetry install
Usage
Configuration
The server ships with a default
config.yaml
bundled inside the PyPI package. To override it, set the MATHAIAGENT_CONFIG
environment variable to the absolute path of your custom configuration file:
# assuming config_local.yaml placed in my home folder
export MATHAIAGENT_CONFIG="${HOME}/cfg/math-ai-agent/config_local.yaml"
Running Using PyPI Package
NOTE: requires prior installation using
pip install -U --user math-ai-agent.
-
Make a copy of config_local.yaml to a local home directory (e.g.,
${HOME}/cfg/math-ai-agent/config_local.yaml). -
Launch the PyPI-installed
math-ai-agentpackage:
# config_local.yaml placed in my home folder
export MATHAIAGENT_CONFIG="${HOME}/cfg/math-ai-agent/config_local.yaml"
# using installed package from PyPI:
math-ai-agent
- Health check
# port is set by web.port in config_local.yaml
curl -v http://localhost:9090/health
# Expect: OK
- To stop, go to the running terminal and press
Ctrl+C
Running Using Git Cloned Project - MCP Server Running Locally
NOTE: requires the calculator_mcp running locally as per instructions at
calculator-mcp
-
Make a copy of config_local.yaml to a local home directory (e.g.,
${HOME}/cfg/math-ai-agent/config_local.yaml). -
Launch
math-ai-agentfrom the local Git repo folder
# On my machine the project is installed here:
pushd ~/github/rubens/dev/python/math-ai-agent/
# ensure we are at the project git local root folder
cd $(git rev-parse --show-toplevel) || exit
# config_local.yaml placed in my home folder
export MATHAIAGENT_CONFIG="${HOME}/cfg/math-ai-agent/config_local.yaml"
# ensure below port does not conflict with locally running MCP server.
poetry run math-ai-agent
- Health check
curl -v http://localhost:9090/health
# Expect: OK
- To stop, go to the running terminal and press
Ctrl+C
Calculator MCP Server Running Remotely - OAuth Authentication
NOTE: requires OAuth authentication which currently only Rubens is able to authorize using his personal GitHub account.
-
Make a copy of config_remote.yaml to a local home directory (e.g.,
${HOME}/cfg/math-ai-agent/config_remote.yaml). -
Launch
math-ai-agentfrom the local Git repo folder
# On my machine the project is installed here:
pushd ~/github/rubens/dev/python/math-ai-agent/
# ensure we are at the project git local root folder
cd $(git rev-parse --show-toplevel) || exit
# config_remote.yaml placed in my home folder
export MATHAIAGENT_CONFIG="${HOME}/cfg/math-ai-agent/config_remote.yaml"
# clean up previously created OAuth tokens
rm -fr ~/.calc-mcp-token
poetry run math-ai-agent
- Health check
curl -v http://localhost:9090/health
# Expect: OK
- To stop, go to the running terminal and press
Ctrl+C
License
The project is licensed under MIT License.
Author: Rubens Gomes
Release files for math-ai-agent 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| math_ai_agent-0.0.2.tar.gz | 19.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| math_ai_agent-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.4 kB
Release files / math_ai_agent-0.0.2.tar.gz
| Download URL | math_ai_agent-0.0.2.tar.gz |
|---|---|
| Size | 19.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
997c64c3a2ce02bd472884172f5219cad91345bf553dca2ba94380d65a5385d5
|
|
BLAKE2b-256 checksum How to use checksums |
92eb8359b064ab47c1d52cbf538b1941b5726f2ad372bbec195c62f11440d43d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.3 CPython/3.14.7 Linux/6.17.0-1022-azure
|
Release files / math_ai_agent-0.0.2-py3-none-any.whl
| Download URL | math_ai_agent-0.0.2-py3-none-any.whl |
|---|---|
| Size | 29.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de742282ed56a6b2d22434b25532ca0096419848ee73cbc400f1373a3e8e17ca
|
|
BLAKE2b-256 checksum How to use checksums |
be731d8e0a5cbca1da7ece83dc57d19de29e868a918dae6f1a78a48041e02004
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.3 CPython/3.14.7 Linux/6.17.0-1022-azure
|