Skip to main content

python License AI--Assisted

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.

  1. Uninstall any previously installed release
pip uninstall math-ai-agent
# purging the cache is recommended as well
pip cache purge
  1. 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
  1. 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

  1. git clone and install local project package using poetry
# 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.

  1. Make a copy of config_local.yaml to a local home directory (e.g., ${HOME}/cfg/math-ai-agent/config_local.yaml).

  2. Launch the PyPI-installed math-ai-agent package:

# 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
  1. Health check
# port is set by web.port in config_local.yaml
curl -v http://localhost:9090/health
# Expect: OK
  1. 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

  1. Make a copy of config_local.yaml to a local home directory (e.g., ${HOME}/cfg/math-ai-agent/config_local.yaml).

  2. Launch math-ai-agent from 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
  1. Health check
curl -v http://localhost:9090/health
# Expect: OK
  1. 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.

  1. Make a copy of config_remote.yaml to a local home directory (e.g., ${HOME}/cfg/math-ai-agent/config_remote.yaml).

  2. Launch math-ai-agent from 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
  1. Health check
curl -v http://localhost:9090/health
# Expect: OK
  1. 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.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for math-ai-agent 0.0.4
File Size Uploaded
math_ai_agent-0.0.4.tar.gz 21.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for math-ai-agent 0.0.4
File Interpreter ABI Platform
math_ai_agent-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 55.2 kB

Release files / math_ai_agent-0.0.4.tar.gz

Download URL math_ai_agent-0.0.4.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e606f1c987337c4195c8370ce0fda49e2ae72d390f8e72a1232e2c7810627cc7
BLAKE2b-256 checksum
How to use checksums
584544d9b6a08e1924b3a1d1ad766aec8c5caa5b1facf54719c350aec4908ac3
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.4-py3-none-any.whl

Download URL math_ai_agent-0.0.4-py3-none-any.whl
Size 33.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
59b1a18f36653677318f8165da78e831bd41fdd50d9606ef115f7fb79374a1b9
BLAKE2b-256 checksum
How to use checksums
2e5b1a9ebe9c9fa3ced4c0dee3cfd5634070d00de525292f49ba474ed8578a1d
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 history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page