PyPI release arcade-serve and arcade-tdk (#432)

This commit is contained in:
Eric Gustin 2025-06-13 13:06:11 -07:00 committed by GitHub
parent 86cde2d9bd
commit 8a9845b484
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 49 additions and 47 deletions

View file

@ -21,17 +21,21 @@ pip install arcade-core
## Usage
1. Install an arcade toolkit
```bash
pip install arcade-math
```
2. Load the toolkit
```python
from arcade_core import ToolCatalog, Toolkit, ArcadeConfig
import arcade_math
from arcade_core import ToolCatalog, Toolkit
# Create a tool catalog
catalog = ToolCatalog()
# Load a toolkit
toolkit = Toolkit.from_directory("path/to/toolkit")
# Configure Arcade
config = ArcadeConfig.from_file("config.yaml")
toolkit = Toolkit.from_module(arcade_math)
```
## License

View file

@ -20,49 +20,49 @@ pip install arcade-serve
## Usage
### FastAPI Worker
To add a toolkit to a hosted worker such as FastAPI, you can register them in the worker itself.
This allows you to explicitly define which tools should be included on a particular worker.
Here is an example of adding the math toolkit (pip install arcade-math) to a FastAPI Worker:
```python
from arcade_serve import FastAPIWorker
import arcade_math
from fastapi import FastAPI
from arcade_tdk import Toolkit
from arcade_serve.fastapi import FastAPIWorker
# Create a FastAPI worker
worker = FastAPIWorker()
app = FastAPI()
# Add tools to the worker
worker.add_toolkit("path/to/toolkit")
worker_secret = os.environ.get("ARCADE_WORKER_SECRET")
worker = FastAPIWorker(app, secret=worker_secret)
# Start the server
worker.start(host="0.0.0.0", port=8000)
worker.register_toolkit(Toolkit.from_module(arcade_math))
```
### MCP Server
Here is an example of adding the math toolkit (pip install arcade-math) to a MCP Worker
```python
from arcade_serve import StdioServer
import arcade_math
from arcade_core.catalog import ToolCatalog
from arcade_serve.mcp.stdio import StdioServer
# Create an MCP server
server = StdioServer()
# 1. Create and populate the tool catalog
catalog = ToolCatalog()
catalog.add_module(arcade_math)
# Add tools
server.add_toolkit("path/to/toolkit")
# Start the server
server.run()
```
# 2. Main entrypoint
async def main():
# Create the worker with the tool catalog
worker = StdioServer(catalog)
### Custom Worker
# Run the worker
await worker.run()
```python
from arcade_serve import BaseWorker, WorkerComponent
class MyWorker(BaseWorker):
def __init__(self):
super().__init__()
self.add_component(MyCustomComponent())
if __name__ == "__main__":
import asyncio
async def handle_request(self, request):
# Custom request handling
return await super().handle_request(request)
asyncio.run(main())
```
## License

View file

@ -1,6 +1,6 @@
[project]
name = "arcade-serve"
version = "1.0.0"
version = "2.0.0"
description = "Arcade Serve - Serving infrastructure for Arcade tools and workers"
readme = "README.md"
license = {text = "MIT"}

View file

@ -38,19 +38,17 @@ def hello_world(name: Annotated[str, "The name of the person to greet"]) -> str:
from typing import Annotated
from arcade_tdk import tool, ToolCatalog, Toolkit
from arcade_tdk.auth import Reddit
# Create tools with more complex parameters
@tool
def calculate_sum(numbers: Annotated[list[float], "The numbers to sum"]) -> float:
"""Calculate the sum of a list of numbers."""
return sum(numbers)
# Access the tool catalog
catalog = ToolCatalog()
tools = catalog.get_all_tools()
# Work with toolkits
toolkit = Toolkit.from_directory("my_toolkit")
# Create tools with auth requirement
@tool(requires_auth=Reddit(scopes=["read"]))
def get_posts_in_subreddit(
subreddit: Annotated[str, "The name of the subreddit"],
limit: Annotated[int, "The number of posts to return]
) -> dict:
"""Get posts from a specific subreddit"""
# TODO: Implement your Reddit tool
return {}
```
## License

View file

@ -1,6 +1,6 @@
[project]
name = "arcade-tdk"
version = "1.0.0"
version = "2.0.0"
description = "Arcade TDK - Toolkit Development Kit for building Arcade tools"
readme = "README.md"
license = {text = "MIT"}