A minimal, hackable agentic framework: LLM calls via litellm, @tool-decorated functions, and MCP server support.
Project description
agentropic
A small, hackable agentic framework in ~500 lines you fully own and can read top to bottom in an afternoon:
- LLM calls go through litellm, so you get every provider (OpenAI, Anthropic, Gemini, Ollama, Bedrock, 100+ more) for free.
@tooldecorator turns any python function into an LLM-callable tool with an auto-generated JSON schema (from type hints + docstring).- MCP support — connect to any Model Context Protocol server (stdio or SSE) and its tools show up in your agent automatically, indistinguishable from local tools.
- Agent loop handles the call → tool-call → tool-result → call cycle for you, with memory, streaming, and a max-iteration safety valve.
Install (once published)
pip install agentropic
Quick start
import asyncio
from agentropic import Agent, tool
@tool()
def get_weather(city: str) -> str:
"""Get the current weather for a city."""
return f"It's sunny in {city}."
async def main():
agent = Agent(
name="assistant",
model="gpt-4o-mini", # any litellm model string
instructions="You are helpful and concise.",
tools=[get_weather],
)
print(await agent.arun("What's the weather in Paris?"))
asyncio.run(main())
Sync usage: agent.run("...") (wraps arun in asyncio.run for you).
Using MCP servers
from agentropic import Agent
from agentropic.mcp import StdioServer
agent = Agent(
name="fs-agent",
model="gpt-4o-mini",
mcp_servers=[
StdioServer(command="npx", args=["-y", "@modelcontextprotocol/server-filesystem", "."]),
],
)
print(await agent.arun("List the files in the current directory."))
Requires the optional MCP dependency: pip install "agentropic[mcp]".
Architecture
src/agentropic/
├── __init__.py # public API surface
├── agent.py # the run loop: LLM <-> tools <-> memory
├── llm.py # thin litellm wrapper (swap providers here)
├── tools.py # @tool decorator, Tool, ToolRegistry, schema generation
├── memory.py # in-memory conversation history (swap for your own store)
└── mcp/
└── client.py # MCP stdio/SSE client -> Tool adapter
Everything is a plain, editable python file — no hidden magic, no plugin
registry you can't inspect. Read agent.py first; that's the whole loop.
Extending it
- Custom memory / persistence: implement
.add(),.get(),.clear()matchingMemoryand passmemory=YourMemory()toAgent. - Streaming with tool calls:
astream()currently falls back to a non-streamedarun()when tools are registered — extend it if you need token-level streaming mid-tool-loop. - Multi-agent handoff: compose multiple
Agentinstances and route between them yourself, or wrap one agent'sarunas a tool for another.
Publishing your fork to PyPI
-
Pick a unique name and check it's free:
pip index versions your-nameor just search on https://pypi.org. Updatenameinpyproject.toml(and rename thesrc/agentropicfolder if you want the import name to match). -
Bump the version in
pyproject.tomlandsrc/agentropic/__init__.py(__version__). -
Install build tooling:
pip install build twine
-
Build:
python -m build
This produces
dist/agentropic-0.1.0.tar.gzanddist/agentropic-0.1.0-py3-none-any.whl. -
Test on TestPyPI first (highly recommended):
python -m twine upload --repository testpypi dist/* pip install --index-url https://test.pypi.org/simple/ agentropic
You'll need a free account at https://test.pypi.org and an API token (Account Settings → API tokens). Use
__token__as the username and the token (startingpypi-...) as the password, or store it in~/.pypirc:[testpypi] username = __token__ password = pypi-...your-token...
-
Publish for real once it installs and works:
python -m twine upload dist/*
(needs an API token from https://pypi.org/manage/account/ the same way).
-
Every future release: bump the version number,
python -m buildagain (delete the olddist/first),twine upload dist/*.
Running tests
pip install -e ".[dev]"
pytest
License
MIT — do whatever you want with it.
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 agentropic-0.1.0.tar.gz.
File metadata
- Download URL: agentropic-0.1.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c480e8a6e9d3fe2e4bf7aa5e98e6441c57d9c01b56d63a820fd93243cfef0bbf
|
|
| MD5 |
ab8933fa977bdce153f0791e91b4004c
|
|
| BLAKE2b-256 |
30e2582035ff2b503190d6e54bcd16028a5e235930a776ce95aa47215d5cba4d
|
File details
Details for the file agentropic-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agentropic-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc897af21e8372d66c6c7edb0b22757678bbdf577d034859f709a5397d6fc888
|
|
| MD5 |
f9bbc495e7a9db4f7ace92ad4083f27b
|
|
| BLAKE2b-256 |
29ccd28801b6b22b5ce8072c29c4865f285ff91ef731f11ed7ab5b687cd6f6d9
|