MTPX
MTPX is a Python SDK and CLI for building agents that can use tools without turning your application into a pile of prompt glue.
It gives you a small runtime for model-tool-model loops, provider adapters for popular LLM APIs, local toolkits for files and code work, session storage, streaming events, and MCP-compatible transports when you need interoperability.
Why MTPX
- Build agents with explicit tool contracts instead of hidden ad hoc callbacks.
- Run dependency-aware batches of tool calls, including references between calls.
- Swap providers without rewriting your agent loop.
- Stream text, reasoning, tool events, and usage metadata from one runtime.
- Persist sessions in JSON, Postgres, or MySQL.
- Expose the same tools through SDK code, a CLI/TUI, Streamlit Agent OS, or MCP JSON-RPC.
MTPX is still alpha, but the shape is practical: install it, register tools, choose a provider, and start building.
Install
pip install mtpx
Common extras:
pip install "mtpx[groq,dotenv]"
pip install "mtpx[openai,anthropic,dotenv]"
pip install "mtpx[ollama,lmstudio]"
pip install "mtpx[toolkits-web]"
pip install "mtpx[stores-db]"
pip install "mtpx[all]"
From source:
git clone https://github.com/GodBoii/Model-Tool-protocol-.git
cd Model-Tool-protocol-
python -m venv .venv
.venv\Scripts\activate
pip install -e ".[dotenv,groq]"
MTPX does not load .env automatically. Install python-dotenv and call Agent.load_dotenv_if_available(), or export provider keys in your shell.
SDK Quickstart
from mtp import Agent
from mtp.providers import Groq
from mtp.toolkits import CalculatorToolkit, FileToolkit
Agent.load_dotenv_if_available()
tools = Agent.ToolRegistry()
tools.register_toolkit_loader("calculator", CalculatorToolkit())
tools.register_toolkit_loader("file", FileToolkit(base_dir="."))
agent = Agent.MTPAgent(
provider=Groq(model="llama-3.3-70b-versatile"),
tools=tools,
instructions="Use tools when they improve correctness. Keep answers concise.",
strict_dependency_mode=True,
)
print(agent.run("What is 25 * 4 + 10? Then list the project files.", max_rounds=4))
Streaming:
agent.print_response(
"Inspect this project and summarize the CLI entry points.",
max_rounds=6,
stream=True,
stream_events=True,
)
Persistent sessions:
from mtp import Agent, JsonSessionStore
from mtp.providers import OpenAI
store = JsonSessionStore(db_path="tmp/mtp_json_db")
agent = Agent.MTPAgent(provider=OpenAI(model="gpt-4o"), tools=tools, session_store=store)
agent.run("Remember: project codename is Atlas.", session_id="chat-1", user_id="u1")
agent.run("What is the project codename?", session_id="chat-1", user_id="u1")
User-owned sessions must be read with the same user_id; this prevents accidental cross-user session reads.
CLI Quickstart
mtp --help
mtp providers list
mtp doctor
mtp new my-agent --template minimal
mtp run my-agent
Interactive terminal agent:
pip install "mtpx[groq,dotenv]"
mtp tui
Streamlit Agent OS:
pip install "mtpx[dotenv,ui-streamlit,groq,openai,openrouter]"
mtp agent-os
Agent OS starts with safer defaults: calculator and file tools are enabled first, while shell/Python/web tools are opt-in from the sidebar.
Providers
Supported adapters include:
- OpenAI
- Groq
- Anthropic
- Gemini
- OpenRouter
- Mistral
- Cohere
- Cerebras
- DeepSeek
- SambaNova
- Together AI
- Fireworks AI
- Xiaomi MiMo
- Ollama
- LM Studio
- Mock planner for deterministic tests
Xiaomi MiMo uses MIMO_API_KEY. You can override its endpoint with MIMO_BASE_URL, and live tests require both MIMO_API_KEY and RUN_LIVE_XIAOMI=1.
Toolkits
Built-in toolkit loaders:
CalculatorToolkit: arithmetic helpers.FileToolkit: scoped file listing, reading, writing, and search.PythonToolkit: isolated subprocess execution for code snippets/files.ShellToolkit: bare-command allowlist execution in a scoped directory.WebsiteToolkit: public HTTP/HTTPS page text extraction with private-network blocking by default.WikipediaToolkit,NewspaperToolkit,Newspaper4kToolkit,Crawl4aiToolkit: optional web research helpers.
Local code execution tools are powerful. Keep their base directory narrow, use policy controls, and do not expose them to untrusted users without an approval layer.
MCP And Transports
MTPX includes:
- line-delimited stdio envelopes
- HTTP envelope transport
- optional WebSocket transport
- MCP-compatible JSON-RPC server
- MCP HTTP and WebSocket transports with progress replay
MCP auth is explicit: require_auth=True must be paired with an auth_token, auth_validator, or auth_provider.
Testing
Fast local checks:
python -m pytest -q -m "not integration and not live"
python -m compileall -q src tests
Integration checks:
python -m pytest -q -m "integration and not live"
Live provider tests are opt-in. For Xiaomi:
set RUN_LIVE_XIAOMI=1
set MIMO_API_KEY=...
python -m pytest -q tests/test_e2e_xiaomi.py
Docs
- MTP Docs Website
- Quickstart
- Agent API Reference
- Storage and Sessions
- Providers
- Provider Guides
- Local Inference
- Local Toolkits
- Creating Tools
- Events Contract
- Transport
- MCP Interop Adapter
- Architecture
- Testing
- Publishing
Repository Map
src/mtp/agent.py: agent loop, streaming, sessions, orchestration modes.src/mtp/runtime.py: tool registry, lazy toolkit loading, policy checks, execution plans.src/mtp/protocol.py: protocol dataclasses.src/mtp/schema.py: envelope and argument validation.src/mtp/providers/: LLM provider adapters.src/mtp/toolkits/: local and web toolkit loaders.src/mtp/cli/: CLI, TUI, scaffolding, doctor, Agent OS launcher.src/mtp/mcp.py: MCP-compatible JSON-RPC adapter.src/mtp/mcp_transport.py: MCP HTTP/WebSocket transports.docs/: guides and reference material.examples/: runnable provider and toolkit examples.
License
MIT License. See LICENSE.
Metadata
Release files for mtpx 0.1.38
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mtpx-0.1.38.tar.gz | 322.3 kB | Without provenance | Details for mtpx-0.1.38.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mtpx-0.1.38-py3-none-any.whl | Python 3 | none | any | Details for mtpx-0.1.38-py3-none-any.whl |
Total release size: 631.6 kB
Release files / mtpx-0.1.38.tar.gz
| Download URL | mtpx-0.1.38.tar.gz |
|---|---|
| Size | 322.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2970fe142cc9c638a53a0ed51d26c16921e9851b4a1833526f34a271531bb70a
|
|
BLAKE2b-256 checksum How to use checksums |
cd4f2d0c90f7642b7a5121941fe3eed287030d5978cddf72bd19ce924dadb006
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.3
|
Release files / mtpx-0.1.38-py3-none-any.whl
| Download URL | mtpx-0.1.38-py3-none-any.whl |
|---|---|
| Size | 309.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6f1dcca243a8807e0776224340e34186e399032bfe071a89d4de854473a04498
|
|
BLAKE2b-256 checksum How to use checksums |
3d16021ae80176594b49b955be1c7d9b98b6a81d7054578bde79d12caba8d284
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.3
|
Security for mtpx 0.1.38
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.