A lightweight framework to expose any API as an agent-compatible tool
Project description
B2A Toolkit 🚀
A lightweight framework to expose any API as an agent-compatible tool. B2A Toolkit makes it easy to create tools that can be used by AI agents, with built-in support for OpenAI's MCP spec, LangChain, and CrewAI.
Features
- 🎯 Simple decorator-based tool definition
- 🔒 Built-in authentication handling
- 📝 Automatic tool manifest generation
- 🔄 Support for multiple agent frameworks
- 🛠️ CLI for building and testing tools
Installation
pip install b2a-toolkit
Quick Start
- Define a tool using the
@define_tooldecorator:
from toolkit import define_tool, ToolAuth
@define_tool(
name="create_expense",
description="Creates an expense in the system",
inputs={
"amount": "number",
"category": "string",
"description": "string",
"date": "string"
},
output_type="object",
output_description="The created expense object",
auth=ToolAuth(
type="oauth",
required=True,
scopes=["expenses:write"]
)
)
def create_expense(amount: float, category: str, description: str, date: str):
# Your implementation here
return {"id": "exp_123", "amount": amount, ...}
- Build the tool manifest:
toolkit build examples/expense_tool.py -o manifest.json
- Test the tool:
toolkit test create_expense examples/expense_tool.py
Tool Definition
The @define_tool decorator takes the following parameters:
name: Name of the tooldescription: Description of what the tool doesinputs: Dictionary mapping input parameter names to their typesoutput_type: Type of the tool's outputoutput_description: Description of the tool's outputauth: Optional authentication configurationversion: Version of the tool (default: "0.1.0")tags: Optional list of tags/categories
Authentication
ToolPilot supports different authentication types:
- OAuth
- API Key
- None (for public APIs)
Example OAuth configuration:
auth = ToolAuth(
type="oauth",
required=True,
scopes=["expenses:write"]
)
CLI Commands
Build Manifest
toolkit build <module_path> [--output <output_file>] [--format <json|openapi>]
Test Tool
toolkit test <tool_name> <module_path>
Examples
Check out the examples/ directory for more examples:
expense_tool.py: A simple expense creation tool- More examples coming soon...
Current Capabilities
-
Tool Definition
- Simple decorator-based API
- Input/output validation
- Type checking and conversion
- Built-in documentation support
-
Authentication
- OAuth support
- API key support
- Configurable scopes
- Optional auth requirements
-
Manifest Generation
- JSON format export
- CLI tool for building manifests
- Validation of tool definitions
- Support for metadata and tags
-
Agent Framework Support
- OpenAI MCP spec compatibility
- LangChain tool format
- CrewAI integration
Coming Soon 🚀
-
Enhanced Manifest Support
- OpenAPI format export
- GraphQL schema generation
- Custom format plugins
- Schema validation
-
Hosted Dashboard
- Tool registry and discovery
- Live testing interface
- Usage analytics
- Error tracking
-
Advanced Features
- Rate limiting and quotas
- Retry handling
- Error recovery
- Request/response logging
-
Enterprise Features
- Team management
- Access control
- Audit logging
- Custom authentication providers
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
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 b2a_toolkit-0.1.1.tar.gz.
File metadata
- Download URL: b2a_toolkit-0.1.1.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37e88e82aac745349631ba863d06981926292d41cbc9e3ec5e2ea14ecd514fc3
|
|
| MD5 |
a1b03239de868eb9d4c774c406c315cb
|
|
| BLAKE2b-256 |
7ecfcc903319c3d32fa5aa4de9d957516ac5e281682f2d0163d9f8094d3d740c
|
File details
Details for the file b2a_toolkit-0.1.1-py3-none-any.whl.
File metadata
- Download URL: b2a_toolkit-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7b186163b399e6b11eaf205b17ed65ac835d6a07d82d2b6bee5b83db389798d
|
|
| MD5 |
64929811c0b2bd23dd0c4897d234995f
|
|
| BLAKE2b-256 |
755dcc2ecabb77f7a086b30655572deadef2385a19561637f88898af455357ce
|