I built pi-openapi-tools — a Pi extension that reads an OpenAPI/Swagger spec and dynamically registers one callable tool per API operation.
Instead of hand-writing wrappers for every endpoint, you point Pi at a spec URL and immediately start using generated tools.
- npm: pi-openapi-tools on npm
- Pi package: pi-openapi-tools on Pi
- GitHub: Repository
Why I built this
Most API-agent integrations still require too much manual glue code:
- mapping endpoints to functions
- defining parameter schemas
- maintaining naming consistency
- wiring auth/token handling
- repeating the process for every API
That slows experimentation and makes agent tooling fragile.
I wanted a runtime-first workflow:
spec → generated tools → live API calls
What the extension does
Given an OpenAPI or Swagger spec URL, pi-openapi-tools:
- Generates one Pi tool per operation
- Supports Swagger 2.0 and OpenAPI 3.x
- Builds structured parameter schemas automatically
- Resolves request bodies by media/content type
- Handles path, query, and header params
- Adds slash commands for managing generated toolsets
It also includes:
- prefix-scoped registrations (
/swagger-tools:list-prefixes) - prefix cleanup (
/swagger-tools:remove-prefix) - tool inspection (
/swagger-tools:describe) - token/auth helpers (
/swagger-tools:auth)
60-second quickstart
Install:
pi install npm:pi-openapi-tools
Generate tools from Petstore:
/swagger-tools https://petstore.swagger.io/v2/swagger.json --prefix pet
/swagger-tools:list
You’ll immediately get generated tools such as:
pet_getstoreorderbyidpet_postuser- etc.
A few implementation details mattered a lot in practice:
Prefix-scoped additive registration
Multiple API toolsets can coexist cleanly.Stable naming + dedupe
Generated names are sanitized and collision-safe.No unregister support in Pi? Stub instead.
Removed tools become non-executable guidance stubs instead of silently disappearing.Content-type-aware serialization
Request body handling follows declared spec media types (JSON, form-data, urlencoded, text, etc).
I also added a full walkthrough + simulation test:
- Tutorial: Petstore walkthrough
- Repo: GitHub repository
If you try it on large or messy specs, I’d especially love feedback on:
- operation naming ergonomics
- auth edge cases
- request body/media handling
- discoverability in very large APIs
If this is useful, feel free to star the repo and share your API use case.
Top comments (0)