Skip to main content

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.
  • @tool decorator 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() matching Memory and pass memory=YourMemory() to Agent.
  • Streaming with tool calls: astream() currently falls back to a non-streamed arun() when tools are registered — extend it if you need token-level streaming mid-tool-loop.
  • Multi-agent handoff: compose multiple Agent instances and route between them yourself, or wrap one agent's arun as a tool for another.

Publishing your fork to PyPI

  1. Pick a unique name and check it's free: pip index versions your-name or just search on https://pypi.org. Update name in pyproject.toml (and rename the src/agentropic folder if you want the import name to match).

  2. Bump the version in pyproject.toml and src/agentropic/__init__.py (__version__).

  3. Install build tooling:

    pip install build twine
    
  4. Build:

    python -m build
    

    This produces dist/agentropic-0.1.0.tar.gz and dist/agentropic-0.1.0-py3-none-any.whl.

  5. 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 (starting pypi-...) as the password, or store it in ~/.pypirc:

    [testpypi]
    username = __token__
    password = pypi-...your-token...
    
  6. 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).

  7. Every future release: bump the version number, python -m build again (delete the old dist/ 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

agentropic-0.1.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentropic-0.1.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

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

Hashes for agentropic-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c480e8a6e9d3fe2e4bf7aa5e98e6441c57d9c01b56d63a820fd93243cfef0bbf
MD5 ab8933fa977bdce153f0791e91b4004c
BLAKE2b-256 30e2582035ff2b503190d6e54bcd16028a5e235930a776ce95aa47215d5cba4d

See more details on using hashes here.

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

Hashes for agentropic-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fc897af21e8372d66c6c7edb0b22757678bbdf577d034859f709a5397d6fc888
MD5 f9bbc495e7a9db4f7ace92ad4083f27b
BLAKE2b-256 29ccd28801b6b22b5ce8072c29c4865f285ff91ef731f11ed7ab5b687cd6f6d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page