Skip to main content

MRtrix3 Agent

Python 3.10+ PydanticAI License: MIT

AI assistant for MRtrix3 documentation and workflow guidance in the terminal

https://github.com/user-attachments/assets/0230bb50-9a90-453a-9c52-f0da3e75193a

How does the MRtrix3-agent work?

This project serves as a simple implemention of Agentic AI knowledge base generation and retrieval. This foundation can be built on to implement custom workflows or transfer the framework to other documented software. The general structure of this repo is as follows:

  1. Official MRtrix3 documentation (latest version) is stored in a PostgreSQL database (Supabase)
  2. Users install a chromaDB locally which fetches documents from Supabase and stores them locally
    • Upon every app startup, chromaDB checks itself against Supabase (ground truth) to determine if sync for up-to-date documentation is needed
  3. User chats with AI Agent (Gemini-2.5-flash)
  4. To provide accurate answers, AI Agent is equipped with a search tool to reference relevant and up-to-date documentation
  5. Monitoring and log collection is available and updated in real-time to view Agent queries and retrievals in real-time

From this basic structure, additional tools or extensions to the AI Agent's capabilities can be easily added. As an example, the current version of the repo comes with 3 sample slash commands, one of which ("/sharefile") allows the user to share their file metadata with the Agent using MRtrix's 'mrinfo' for personalized guidance.

📋 Prerequisites

  • Python 3.10 or higher
  • API keys for your Gemini (Google)
  • Currently only tested on Linux systems

For Regular Use

  1. Install with pip
pip install mrtrix3-agent
  1. Setup your API key (you will be prompted to enter)
setup-mrtrixbot
  1. Run the agent and chat!
mrtrixbot

🛠️ For Contributors/Developers

1. Clone the Repository

git clone https://github.com/yourusername/mrtrix3-agent.git
cd mrtrix3-agent

2. Set Up Virtual Environment

python -m venv .venv
source .venv/bin/activate

3. Install Dependencies

pip install -e . # For standard usage
# or
pip install -e ".[dev]" # If you want to run test scripts with pytest

4. Configure Environment Variables

'.env.example' contains configurable environment variables used in this project. The project was built with Supabase and Gemini. If wanting to replicate this project, a Supabase account is required and all the tools to populate your own database can be found in the src/knowledge_base folder. Great for anyone curious about how a knowledge base gets created, or for those trying to maybe create a "smarter" knowledge base for the AI agent!

5. Initialize Database (Optional to replicate project)

Populate the Supabase vector database with MRtrix3 documentation:

python knowledgeBase/populate_database.py

This will:

  • Clone MRtrix3 repository (sparse checkout)
  • Process documentation and source files
  • Generate embeddings and populate the database
  • Takes approximately 1-5 minutes

🎯 Usage

Basic Usage

Start the interactive CLI:

mrtrix3-agent

Or use the Python script directly:

python src/agent/cli.py
# or
python -m src.agent.cli

📊 Monitoring

The agent includes built-in monitoring:

  • Set environment variable 'COLLECT_LOGS=true'
  • Session logs in monitoring/logs/
  • Performance metrics in monitoring/metrics/
  • Error tracking with detailed stack traces

Logs within monitoring/logs/ get updated in real-time, good to look at if you are curious where the AI agent is searching for info to answer queries!

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

📬 Contact

You can reach me at rmoskwa@wisc.edu

Metadata

Release files for mrtrix3-agent 1.0.14

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

Source distribution (sdist)

Source distribution for mrtrix3-agent 1.0.14
File Size Uploaded Provenance
mrtrix3_agent-1.0.14.tar.gz 63.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mrtrix3-agent 1.0.14
File Interpreter ABI Platform
mrtrix3_agent-1.0.14-py3-none-any.whl Python 3 none any Details

Total release size: 138.4 kB

Release files / mrtrix3_agent-1.0.14.tar.gz

Download URL mrtrix3_agent-1.0.14.tar.gz
Size 63.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5fb7b8c21b932b8d5b8b8313a491b67c18ff098deb47c2af8a35e19912178c60
BLAKE2b-256 checksum
How to use checksums
5d547727ba050522351a1f29ce4cb7b3366a93b6462913207b5c786671ca51db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / mrtrix3_agent-1.0.14-py3-none-any.whl

Download URL mrtrix3_agent-1.0.14-py3-none-any.whl
Size 75.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d43b7ade6d9fef841d39f248af5b89a0b91c3d86ab5018a522e6521f98fdc108
BLAKE2b-256 checksum
How to use checksums
3699c9b8f2a72248ec8a10e5a92f072b922d97d3c8942e58e8ca17288ae142a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for mrtrix3-agent 1.0.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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