Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions python/xquik_openapi_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Xquik OpenAPI UTCP example

This example shows how to register Xquik's public OpenAPI document as a UTCP HTTP provider. It lets a UTCP client discover Xquik tools for X data workflows such as tweet search, user lookup, follower export, monitoring, webhooks, and write actions.

The script only lists matching tools by default. Set a real `XQUIK_API_KEY` before calling any Xquik endpoint.

## Setup

```sh
pip install -r requirements.txt
```

Edit `example.env` and replace the placeholder value:

```sh
XQUIK_API_KEY=xq_replace_with_your_key
```

## Run

```sh
python xquik_openapi_example.py
```

The example loads `providers.json`, fetches <https://xquik.com/openapi.json>, registers the discovered tools, and prints the first matching tools.

## Notes

- Keep API keys in local environment files or a secret store.
- Do not commit real API keys.
- Xquik MCP setup is documented at <https://docs.xquik.com/mcp/overview>.
1 change: 1 addition & 0 deletions python/xquik_openapi_example/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
XQUIK_API_KEY=xq_replace_with_your_key
31 changes: 31 additions & 0 deletions python/xquik_openapi_example/providers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"load_variables_from": [
{
"variable_loader_type": "dotenv",
"env_file_path": "example.env"
}
],
"tool_repository": {
"tool_repository_type": "in_memory"
},
"tool_search_strategy": {
"tool_search_strategy_type": "tag_and_description_word_match",
"description_weight": 1,
"tag_weight": 3
},
"manual_call_templates": [
{
"name": "xquik",
"call_template_type": "http",
"http_method": "GET",
"url": "https://xquik.com/openapi.json",
"content_type": "application/json",
"auth_tools": {
"auth_type": "api_key",
"api_key": "$XQUIK_API_KEY",
"var_name": "x-api-key",
"location": "header"
}
}
]
}
3 changes: 3 additions & 0 deletions python/xquik_openapi_example/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
python-dotenv
utcp
utcp-http
31 changes: 31 additions & 0 deletions python/xquik_openapi_example/xquik_openapi_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import asyncio
import json
from pathlib import Path

from utcp.data.utcp_client_config import UtcpClientConfigSerializer
from utcp.utcp_client import UtcpClient


async def main():
base_dir = Path(__file__).parent
config_path = base_dir / "providers.json"
config_data = json.loads(config_path.read_text(encoding="utf-8"))

for variable_loader in config_data.get("load_variables_from", []):
if variable_loader.get("variable_loader_type") == "dotenv":
variable_loader["env_file_path"] = str(base_dir / "example.env")

config = UtcpClientConfigSerializer().validate_dict(config_data)
client = await UtcpClient.create(root_dir=str(base_dir), config=config)

tools = await client.search_tools("tweet search user lookup follower export", limit=12)
print("Matching Xquik tools:")
for tool in tools:
description = getattr(tool, "description", "")
print(f" - {tool.name}: {description}")

print("\nSet XQUIK_API_KEY in example.env before calling a Xquik tool.")


if __name__ == "__main__":
asyncio.run(main())