Dynamic tool discovery for AI agents using the MCP-Zero Active Discovery pattern
Project description
Magetools
A Portable Grimorium for Agentic Tool Discovery.
Magetools gives autonomous AI agents scalable access to thousands of tools ("Spells") without overwhelming their context window. It uses a Hierarchical Active Discovery pattern to organize tools into collections ("Grimoriums") and lets agents discover only what they need, when they need it.
Features
- Active Discovery Protocol: Agents search for capabilities, not specific function names.
- Safe by Default: Strict Mode requires explicit
manifest.jsonto load any code. - Auto-Summarization: Uses Google Gemini to automatically generate technical summaries for your tool collections.
- Stale Summary Detection: Automatically detects code changes via folder hashing and triggers re-summarization.
- Framework Agnostic: Works with LangChain, Google ADK, or any custom agent loop.
- Graceful Degradation: Works without API keys using MockProvider (limited functionality).
Installation
Using uv (Recommended):
# Core package (minimal dependencies)
uv add magetools
# Full installation with all features
uv add magetools[full]
Using pip:
pip install magetools[full]
Optional Dependencies
| Extra | Description |
|---|---|
[google] |
Google GenAI provider for embeddings and summaries |
[vectordb] |
ChromaDB for vector storage |
[adk] |
Google ADK integration for agents |
[full] |
All of the above |
Usage
Quick Start
# 1. Create a collection folder
mkdir -p .magetools/file_ops
# 2. Initialize with manifest.json (required for Strict Mode)
uv run -m magetools init .magetools/file_ops
Add Spells (Tools)
# .magetools/file_ops/files.py
from magetools import spell
@spell
def list_files(path: str = "."):
"""Lists all files in the given directory."""
import os
return os.listdir(path)
@spell
def read_file(path: str):
"""Reads and returns the contents of a file."""
with open(path, "r") as f:
return f.read()
Use with an Agent
import asyncio
from magetools import Grimorium
async def main():
# Initialize (scans .magetools folder and indexes spells)
grimorium = Grimorium()
try:
# Get tools for your agent
tools = await grimorium.get_tools()
# Use with your agent framework
# agent = Agent(tools=tools)
# await agent.run("Find and read data.csv")
finally:
await grimorium.close()
if __name__ == "__main__":
asyncio.run(main())
Agent Discovery Flow
Magetools exposes 3 tools to your agent:
discover_grimoriums(query)– Search collection summariesdiscover_spells(grimorium_id, query)– Search within a collectionexecute_spell(spell_name, arguments)– Run a spell
Example:
User: "Find and read the data.csv file."
Agent:
discover_grimoriums("file reading")→file_opsdiscover_spells("file_ops", "read csv")→read_fileexecute_spell("file_ops.read_file", {"path": "data.csv"})
Strict Mode (Security)
⚠️ Magetools runs in Strict Mode by default.
Collections require a manifest.json file to load any Python code. This prevents accidental execution of arbitrary code.
# Enable a collection
uv run -m magetools init .magetools/my_collection
manifest.json example:
{
"version": "1.0",
"enabled": true,
"whitelist": ["list_files", "read_file"]
}
To disable Strict Mode (development only):
grimorium = Grimorium(strict_mode=False)
Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
GOOGLE_API_KEY |
– | Required for Google GenAI provider |
MAGETOOLS_MODEL |
gemini-2.5-flash |
LLM model for summaries |
MAGETOOLS_DEBUG |
false |
Enable debug logging |
YAML Configuration
Create magetools.yaml in your project root:
model_name: gemini-2.5-flash
embedding_model: models/text-embedding-004
debug: false
CLI Reference
uv run -m magetools init <directory> # Generate manifest.json
uv run -m magetools scan # Scan and sync spells
uv run -m magetools --help # Show help
Support
- Documentation: Full documentation site
- Issues: GitHub Issues
- Discussions: Open an issue for questions
Roadmap
- Local embedding provider (no API key required)
- LangChain integration example
- Web UI for spell management
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Run tests:
uv run pytest - Submit a pull request
For major changes, open an issue first to discuss.
Authors
- Malcom Godlike - Initial work
License
Project Status
🚀 Active Development – This project is actively maintained and accepting contributions.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file magetools-1.0.0.tar.gz.
File metadata
- Download URL: magetools-1.0.0.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fb1087d2676fff5fe6439a044b166a94974280aa609047f5abc85632cbc60e7
|
|
| MD5 |
99126af3ae32bde4524945d4b7844079
|
|
| BLAKE2b-256 |
2378893af48cff543ca4e4427882708910c33f6209e063154992baeccfc8245f
|
Provenance
The following attestation bundles were made for magetools-1.0.0.tar.gz:
Publisher:
release.yml on IAmNo1Special/magetools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
magetools-1.0.0.tar.gz -
Subject digest:
3fb1087d2676fff5fe6439a044b166a94974280aa609047f5abc85632cbc60e7 - Sigstore transparency entry: 911928974
- Sigstore integration time:
-
Permalink:
IAmNo1Special/magetools@11d6dc9b6fa1fe92162500efe389ddc7c6f38f0c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/IAmNo1Special
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@11d6dc9b6fa1fe92162500efe389ddc7c6f38f0c -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file magetools-1.0.0-py3-none-any.whl.
File metadata
- Download URL: magetools-1.0.0-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86f73da3975b7e41a9f874e507f688bd2232d2b41b8ab50ad997c84192313e51
|
|
| MD5 |
c27037c8b82376c2e54c110ea16bf474
|
|
| BLAKE2b-256 |
45ac1cb85e4a988bb2f4f3e80c884f7026f40fc2e69414e7a3b27da8fca6f59a
|
Provenance
The following attestation bundles were made for magetools-1.0.0-py3-none-any.whl:
Publisher:
release.yml on IAmNo1Special/magetools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
magetools-1.0.0-py3-none-any.whl -
Subject digest:
86f73da3975b7e41a9f874e507f688bd2232d2b41b8ab50ad997c84192313e51 - Sigstore transparency entry: 911929059
- Sigstore integration time:
-
Permalink:
IAmNo1Special/magetools@11d6dc9b6fa1fe92162500efe389ddc7c6f38f0c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/IAmNo1Special
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@11d6dc9b6fa1fe92162500efe389ddc7c6f38f0c -
Trigger Event:
workflow_dispatch
-
Statement type: