-
Notifications
You must be signed in to change notification settings - Fork 18
OpenAPI docs and fix a lot of issues (#47) #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -28,6 +28,10 @@ UTCP acts as a **"manual"** that tells agents how to call your tools directly: | |||||
| *"If a human can call your API, an AI agent should be able to call it too - with the same security and no additional infrastructure."* | ||||||
| ::: | ||||||
|
|
||||||
| ## OpenAPI Compatibility | ||||||
|
|
||||||
| UTCP extends OpenAPI for AI agents while maintaining full backward compatibility. Where OpenAPI describes APIs for human developers, UTCP adds agent-focused enhancements: `tags` for categorization, `average_response_size` for resource planning, multi-protocol support (CLI, gRPC, WebSocket), and direct execution instructions. Existing OpenAPI specs can be automatically converted to UTCP manuals without requiring API changes or additional infrastructure. | ||||||
|
|
||||||
| ## Quick Start (5 Minutes) | ||||||
|
|
||||||
| ### 1. Install UTCP | ||||||
|
|
@@ -44,7 +48,12 @@ npm install @utcp/core @utcp/http | |||||
|
|
||||||
| ### 2. Expose Your First Tool | ||||||
|
|
||||||
| Add a discovery endpoint to your existing API: | ||||||
| **Option A: Discovery via existing OpenAPI spec** | ||||||
|
|
||||||
| **Generate OpenAPI endpoint**: `GET http://api.github.com/openapi.json` | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use HTTPS for the GitHub OpenAPI endpoint to avoid redirects/failures and align with the later example. Prompt for AI agents
Suggested change
|
||||||
|
|
||||||
|
|
||||||
| **Option B: Add a discovery endpoint to your existing API** | ||||||
|
|
||||||
| **Add endpoint**: `GET /utcp` | ||||||
| **Return your UTCP manual**: | ||||||
|
|
@@ -72,25 +81,50 @@ Add a discovery endpoint to your existing API: | |||||
| "var_name": "appid", | ||||||
| "location": "query" | ||||||
| } | ||||||
| } | ||||||
| }] | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ### 3. Call Your Tool | ||||||
|
|
||||||
| **Configure UTCP client**: | ||||||
| **Option A: Configure UTCP client**: | ||||||
| ```json | ||||||
| { | ||||||
| "manual_call_templates": [{ | ||||||
| "name": "weather_api", | ||||||
| "call_template_type": "http", | ||||||
| "url": "http://localhost:8000/utcp", | ||||||
| "url": "http://localhost:8000/utcp", // Or http://api.github.com/openapi.json, the openapi spec gets converted automatically | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JSON example includes a // comment, which is invalid JSON and will break copy-paste usage; move the note outside the code block or remove it. Prompt for AI agents
Suggested change
|
||||||
| "http_method": "GET" | ||||||
| }] | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| **Option B: Convert OpenAPI spec to UTCP manual manually** | ||||||
|
|
||||||
| ```python | ||||||
| async def convert_api(): | ||||||
| async with aiohttp.ClientSession() as session: | ||||||
| async with session.get("https://api.github.com/openapi.json") as response: | ||||||
| openapi_spec = await response.json() | ||||||
|
|
||||||
| converter = OpenApiConverter(openapi_spec) | ||||||
| manual = converter.convert() | ||||||
|
|
||||||
| print(f"Generated {len(manual.tools)} tools from GitHub API!") | ||||||
| return manual | ||||||
| ``` | ||||||
|
|
||||||
| Then save that to a text file and load it with the text configuration: | ||||||
| ```json | ||||||
| { | ||||||
| "manual_call_templates": [{ | ||||||
| "name": "github_manual", | ||||||
| "call_template_type": "text", | ||||||
| "file_path": "./github_manual.json", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing comma makes this JSON invalid; remove the comma after the last property. Prompt for AI agents
Suggested change
|
||||||
| }] | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
|
|
||||||
| **Call the tool**: | ||||||
| 1. Initialize UTCP client with configuration | ||||||
| 2. Discover tools from weather API | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mentioning gRPC here implies current support, but the Supported Protocols table below does not list gRPC; clarify status or remove gRPC to avoid confusion.
Prompt for AI agents