diff --git a/libs/arcade-core/README.md b/libs/arcade-core/README.md index e92ac2af..0734d49f 100644 --- a/libs/arcade-core/README.md +++ b/libs/arcade-core/README.md @@ -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 diff --git a/libs/arcade-serve/README.md b/libs/arcade-serve/README.md index 08402807..d63fc1ea 100644 --- a/libs/arcade-serve/README.md +++ b/libs/arcade-serve/README.md @@ -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 diff --git a/libs/arcade-serve/pyproject.toml b/libs/arcade-serve/pyproject.toml index c5b6e2dd..7da31f18 100644 --- a/libs/arcade-serve/pyproject.toml +++ b/libs/arcade-serve/pyproject.toml @@ -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"} diff --git a/libs/arcade-tdk/README.md b/libs/arcade-tdk/README.md index abdd705b..a67f00ab 100644 --- a/libs/arcade-tdk/README.md +++ b/libs/arcade-tdk/README.md @@ -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 diff --git a/libs/arcade-tdk/pyproject.toml b/libs/arcade-tdk/pyproject.toml index cf64e2a9..8ece37f5 100644 --- a/libs/arcade-tdk/pyproject.toml +++ b/libs/arcade-tdk/pyproject.toml @@ -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"}