Skip to main content

A tiny RAG to wipe away API hallucinations

Project description

Towelette

A tiny RAG to wipe away API hallucinations.

LLMs hallucinate API calls for domain-specific libraries -- niche packages like pythonocc, potpourri3d, libigl, and Geometry Central have sparse or outdated training data. Towelette auto-discovers a project's dependencies, researches each library, builds a local RAG index, and serves it via MCP so your coding assistant gets the APIs right.

Quick Start

pip install towelette    # or: pipx install towelette / uv tool install towelette
cd your-project/
towelette init

That's it. Towelette scans your dependencies, dispatches AI scouts to investigate each niche library, indexes source into a local vector DB, and writes an MCP server config to .mcp.json. Next time your AI assistant opens the project, it has accurate API knowledge.

If you're an AI assistant and someone asked you to "set up towelette": run towelette init in the project root. It handles discovery, scouting, indexing, and MCP configuration automatically.

What It Does

  1. Discovers your project's dependencies from pyproject.toml, requirements.txt, or environment.yml
  2. Filters well-known libraries (numpy, pandas, torch, etc.) that LLMs already know
  3. Scouts unfamiliar libraries with LLM subagents that research repos and recommend indexing strategies
  4. Indexes source code (Python, C++, Rust) and documentation (Markdown) into ChromaDB with semantic embeddings
  5. Plugins Support for custom language parsers via a dynamic plugin system
  6. Serves an MCP server with search, lookup, and goto-definition tools

CLI

towelette init [path]                     Scout all dependencies, show report, exit.
towelette init --agent-cmd "cmd"          Use a specific agent CLI for scouting.
towelette serve                           Start the MCP server.
towelette status                          Show what's indexed.
towelette refresh                         Re-scan deps, index new/updated ones.
towelette add <library> [--repo <url>]    Scout a library (use --repo for non-PyPI libs).
towelette add <library> -y                Scout and index immediately.
towelette remove <library>                Remove a library from the index.
towelette reset                           Wipe .towelette/ and start fresh.

Agent-Agnostic Scouting

Towelette is agent-agnostic. While it defaults to claude, you can use any agent CLI that supports a prompt flag:

# Use Gemini CLI
towelette init --agent-cmd "gemini chat -p"

# Or set it globally
export TOWELETTE_AGENT_CMD="gemini chat -p"

Indexing Strategies

Strategy When What
python_ast Pure Python libraries AST-extracted classes, functions, docstrings
tree_sitter_cpp C/C++ headers/source tree-sitter parsed classes, functions, declarations
tree_sitter_rust Rust source code tree-sitter parsed structs, enums, functions
markdown Documentation Semantic chunks based on headers (#, ##)
custom Niche languages User-defined plugins in .towelette/plugins/

Custom Parsers (Plugins)

You can extend Towelette to handle any language by adding a plugin to .towelette/plugins/. For example, a kcl_plugin.py allows Towelette to index KittyCAD Language files. See docs/CUSTOM_PARSERS.md for details.

MCP Tools

Once running, Towelette exposes these tools to your AI assistant:

Tool Purpose
towelette_search Semantic search across indexed libraries
towelette_lookup Exact name lookup for classes/functions
towelette_goto_definition Find definition location (file:line)
towelette_index_status Show indexed libraries and versions

How It Works

your-project/
+-- pyproject.toml          <-- Towelette reads this
+-- src/
+-- .towelette/             <-- Created by `towelette init`
|   +-- config.toml         <-- What's indexed, strategies, versions
|   +-- chroma/             <-- Vector store (ChromaDB)
|   +-- repos/              <-- Cloned library repos
|   +-- plugins/            <-- Custom language parsers (*_plugin.py)
|   +-- definitions.db      <-- Symbol -> file:line (SQLite)
+-- .claude/
    +-- settings.json       <-- MCP server auto-configured

Development

git clone https://github.com/graphitical/towelette.git
cd towelette
python -m venv .venv
.venv/bin/pip install -e ".[dev]"
.venv/bin/pytest

Status

v0.2.0 -- Pluggable & Agent-Agnostic:

  • Discovery (pyproject.toml, requirements.txt, environment.yml, import scanning)
  • Indexing (Python, C++, Rust, Markdown + Custom Plugins)
  • Search (semantic + exact lookup + goto-definition)
  • MCP server (4 query tools)
  • CLI (Agent-agnostic scouting via --agent-cmd)

License

MIT

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

towelette-0.2.0.tar.gz (46.2 kB view details)

Uploaded Source

Built Distribution

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

towelette-0.2.0-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

Details for the file towelette-0.2.0.tar.gz.

File metadata

  • Download URL: towelette-0.2.0.tar.gz
  • Upload date:
  • Size: 46.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for towelette-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6dd1f1558e269a50a242fab6d0c3964c32a33abd9ecd3bc07d7c7ccbeeef6075
MD5 3464958f2599a728893e068cd8151bca
BLAKE2b-256 402184e4ef97f453679633671f348aa1e1ef4800da9d2d090d827cc4bad6c04e

See more details on using hashes here.

Provenance

The following attestation bundles were made for towelette-0.2.0.tar.gz:

Publisher: publish.yml on graphitical/towelette

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file towelette-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: towelette-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 38.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for towelette-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 877da1f8f47f0b4aafe8ec7a1e9452a0db827385a4a4b0857b9b3e787d9d5925
MD5 e30d26567c3afc4893b91a3d5e9e61d4
BLAKE2b-256 77d4aac25b8094d445ddf8a639d662b37d283be0e5839ef58d309187d435594a

See more details on using hashes here.

Provenance

The following attestation bundles were made for towelette-0.2.0-py3-none-any.whl:

Publisher: publish.yml on graphitical/towelette

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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