agent-utils-extensions 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_utils_extensions-0.1.0/.github/workflows/release.yml +40 -0
- agent_utils_extensions-0.1.0/.gitignore +7 -0
- agent_utils_extensions-0.1.0/LICENSE +21 -0
- agent_utils_extensions-0.1.0/PKG-INFO +78 -0
- agent_utils_extensions-0.1.0/README.md +60 -0
- agent_utils_extensions-0.1.0/llms-install.md +103 -0
- agent_utils_extensions-0.1.0/pyproject.toml +28 -0
- agent_utils_extensions-0.1.0/src/agent_utils/extensions/__init__.py +91 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: actions/setup-python@v5
|
|
13
|
+
with:
|
|
14
|
+
python-version: "3.12"
|
|
15
|
+
- name: Check tag matches version
|
|
16
|
+
run: |
|
|
17
|
+
version=$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')
|
|
18
|
+
if [ "v$version" != "$GITHUB_REF_NAME" ]; then
|
|
19
|
+
echo "tag $GITHUB_REF_NAME does not match pyproject version $version"
|
|
20
|
+
exit 1
|
|
21
|
+
fi
|
|
22
|
+
- run: python -m pip install build
|
|
23
|
+
- run: python -m build
|
|
24
|
+
- uses: actions/upload-artifact@v4
|
|
25
|
+
with:
|
|
26
|
+
name: dist
|
|
27
|
+
path: dist/
|
|
28
|
+
|
|
29
|
+
publish:
|
|
30
|
+
needs: build
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
environment: pypi
|
|
33
|
+
permissions:
|
|
34
|
+
id-token: write
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/download-artifact@v4
|
|
37
|
+
with:
|
|
38
|
+
name: dist
|
|
39
|
+
path: dist/
|
|
40
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AI Cortex LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: agent-utils-extensions
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Thin client for the agent_utils Extensions MCP server - exact math and unit conversion for AI agents. One account spans both agent_utils servers.
|
|
5
|
+
Project-URL: Homepage, https://agent-utils.ai
|
|
6
|
+
Project-URL: Repository, https://github.com/agent-utils/agent-utils-extensions-py
|
|
7
|
+
Author-email: AI Cortex LLC <support@agent-utils.ai>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: agent-utils,ai-agents,claude,math,mcp,model-context-protocol,unit-conversion
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# agent-utils-extensions
|
|
20
|
+
|
|
21
|
+
Thin Python client for the **agent_utils Extensions** server - stateless capabilities for AI agents over MCP: exact math and unit conversion.
|
|
22
|
+
|
|
23
|
+
This is a client for a hosted commercial service ([agent-utils.ai](https://agent-utils.ai)), not the service itself. Zero dependencies (standard library only). Install name `agent-utils-extensions`; import `agent_utils.extensions` (a namespace package).
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install agent-utils-extensions
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quickstart
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
import os
|
|
35
|
+
from agent_utils.extensions import AgentUtilsExtensions
|
|
36
|
+
|
|
37
|
+
# Any secret works as a token; the first call auto-provisions a free trial.
|
|
38
|
+
ext = AgentUtilsExtensions(token=os.environ["AGENT_UTILS_TOKEN"])
|
|
39
|
+
|
|
40
|
+
ext.eval_expr(expr="2^10 + 1/3")
|
|
41
|
+
ext.convert("electric_potential", "volt", "millivolt", 1.5)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
**Math** - exact expression evaluation
|
|
47
|
+
- `eval_expr(expr)`
|
|
48
|
+
|
|
49
|
+
**Units** - 56 dimension-checked converters
|
|
50
|
+
- `convert(quantity, from_unit, to_unit, amount)` - calls `convert_<quantity>`. Quantities: acceleration, amount_of_substance, angle, angular_velocity, area, capacitance, catalytic_activity, diffusion_coefficient, dynamic_viscosity, electric_charge, electric_current, electric_potential, electrical_conductance, electrical_resistance, electrical_resistivity, energy, force, frequency, heat_capacity, heat_flux_density, illuminance, inductance, information, information_rate, kinematic_viscosity, length, luminance, luminous_intensity, magnetic_flux, magnetic_flux_density, mass, mass_concentration, mass_density, mass_rate, molality, molar_concentration, molar_mass, molar_volume, moment_of_inertia, momentum, power, pressure, radioactivity, specific_heat_capacity, surface_tension, temperature, temperature_interval, thermal_conductance, thermal_conductivity, thermal_resistance, time, torque, velocity, volume, volume_rate, volumetric_heat_capacity
|
|
51
|
+
|
|
52
|
+
**Account** (on both servers) - `get_account`, `list_api_keys`, `create_api_key`, `revoke_api_key`, `list_payments`, `settle_balance`, `submit_feature_request`, `submit_exit_feedback`, `delete_account`
|
|
53
|
+
|
|
54
|
+
- `call(name, args)` - call any tool by name
|
|
55
|
+
|
|
56
|
+
Valid unit strings for each quantity are listed in that tool's input schema (`tools/list`, no auth).
|
|
57
|
+
|
|
58
|
+
Every response carries a `_meta` envelope with `account_status`, `op_cost`, and
|
|
59
|
+
`credits_remaining`. The canonical, always-current reference is the server's
|
|
60
|
+
[llms.txt](https://mcp.agent-utils.ai/llms.txt) (per service: `/docs/<service>`).
|
|
61
|
+
|
|
62
|
+
Endpoint: `https://mcp.agent-utils.ai/extensions` (staging: `STAGING_ENDPOINT`, `https://mcp-staging.agent-utils.ai/extensions`).
|
|
63
|
+
|
|
64
|
+
## One token, both servers
|
|
65
|
+
|
|
66
|
+
agent_utils is two MCP servers on one account: **extensions** (this one) and **swarm** (memory, locks, task board, pub/sub, idempotency, webhook inbox). The same token works on both and draws from one credit pool. See the [agent-utils hub](https://github.com/agent-utils/agent-utils) for the full platform, and the TypeScript client [`@agent-utils/extensions`](https://github.com/agent-utils/agent-utils-extensions-ts).
|
|
67
|
+
|
|
68
|
+
## Pricing
|
|
69
|
+
|
|
70
|
+
1 credit = $0.00001. Trial: 1,000 credits, no card. Activation: $5 -> 500,000-credit limit. Terms: [mcp.agent-utils.ai/legal.txt](https://mcp.agent-utils.ai/legal.txt).
|
|
71
|
+
|
|
72
|
+
## Contact
|
|
73
|
+
|
|
74
|
+
Questions, bugs or account issues: support@agent-utils.ai
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT. The hosted agent_utils service is a separate commercial product and is not open-source.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# agent-utils-extensions
|
|
2
|
+
|
|
3
|
+
Thin Python client for the **agent_utils Extensions** server - stateless capabilities for AI agents over MCP: exact math and unit conversion.
|
|
4
|
+
|
|
5
|
+
This is a client for a hosted commercial service ([agent-utils.ai](https://agent-utils.ai)), not the service itself. Zero dependencies (standard library only). Install name `agent-utils-extensions`; import `agent_utils.extensions` (a namespace package).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install agent-utils-extensions
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quickstart
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import os
|
|
17
|
+
from agent_utils.extensions import AgentUtilsExtensions
|
|
18
|
+
|
|
19
|
+
# Any secret works as a token; the first call auto-provisions a free trial.
|
|
20
|
+
ext = AgentUtilsExtensions(token=os.environ["AGENT_UTILS_TOKEN"])
|
|
21
|
+
|
|
22
|
+
ext.eval_expr(expr="2^10 + 1/3")
|
|
23
|
+
ext.convert("electric_potential", "volt", "millivolt", 1.5)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API
|
|
27
|
+
|
|
28
|
+
**Math** - exact expression evaluation
|
|
29
|
+
- `eval_expr(expr)`
|
|
30
|
+
|
|
31
|
+
**Units** - 56 dimension-checked converters
|
|
32
|
+
- `convert(quantity, from_unit, to_unit, amount)` - calls `convert_<quantity>`. Quantities: acceleration, amount_of_substance, angle, angular_velocity, area, capacitance, catalytic_activity, diffusion_coefficient, dynamic_viscosity, electric_charge, electric_current, electric_potential, electrical_conductance, electrical_resistance, electrical_resistivity, energy, force, frequency, heat_capacity, heat_flux_density, illuminance, inductance, information, information_rate, kinematic_viscosity, length, luminance, luminous_intensity, magnetic_flux, magnetic_flux_density, mass, mass_concentration, mass_density, mass_rate, molality, molar_concentration, molar_mass, molar_volume, moment_of_inertia, momentum, power, pressure, radioactivity, specific_heat_capacity, surface_tension, temperature, temperature_interval, thermal_conductance, thermal_conductivity, thermal_resistance, time, torque, velocity, volume, volume_rate, volumetric_heat_capacity
|
|
33
|
+
|
|
34
|
+
**Account** (on both servers) - `get_account`, `list_api_keys`, `create_api_key`, `revoke_api_key`, `list_payments`, `settle_balance`, `submit_feature_request`, `submit_exit_feedback`, `delete_account`
|
|
35
|
+
|
|
36
|
+
- `call(name, args)` - call any tool by name
|
|
37
|
+
|
|
38
|
+
Valid unit strings for each quantity are listed in that tool's input schema (`tools/list`, no auth).
|
|
39
|
+
|
|
40
|
+
Every response carries a `_meta` envelope with `account_status`, `op_cost`, and
|
|
41
|
+
`credits_remaining`. The canonical, always-current reference is the server's
|
|
42
|
+
[llms.txt](https://mcp.agent-utils.ai/llms.txt) (per service: `/docs/<service>`).
|
|
43
|
+
|
|
44
|
+
Endpoint: `https://mcp.agent-utils.ai/extensions` (staging: `STAGING_ENDPOINT`, `https://mcp-staging.agent-utils.ai/extensions`).
|
|
45
|
+
|
|
46
|
+
## One token, both servers
|
|
47
|
+
|
|
48
|
+
agent_utils is two MCP servers on one account: **extensions** (this one) and **swarm** (memory, locks, task board, pub/sub, idempotency, webhook inbox). The same token works on both and draws from one credit pool. See the [agent-utils hub](https://github.com/agent-utils/agent-utils) for the full platform, and the TypeScript client [`@agent-utils/extensions`](https://github.com/agent-utils/agent-utils-extensions-ts).
|
|
49
|
+
|
|
50
|
+
## Pricing
|
|
51
|
+
|
|
52
|
+
1 credit = $0.00001. Trial: 1,000 credits, no card. Activation: $5 -> 500,000-credit limit. Terms: [mcp.agent-utils.ai/legal.txt](https://mcp.agent-utils.ai/legal.txt).
|
|
53
|
+
|
|
54
|
+
## Contact
|
|
55
|
+
|
|
56
|
+
Questions, bugs or account issues: support@agent-utils.ai
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
MIT. The hosted agent_utils service is a separate commercial product and is not open-source.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Install - instructions for an AI agent
|
|
2
|
+
|
|
3
|
+
**Nothing to clone, build, or run.** agent_utils Extensions is a *hosted* MCP server at
|
|
4
|
+
`https://mcp.agent-utils.ai/extensions`. Installing it means pointing your MCP client at that URL with a
|
|
5
|
+
Bearer token. There is no signup, no dashboard, no API-key request, and no payment card.
|
|
6
|
+
|
|
7
|
+
If you are looking for a package to launch as a local stdio server, stop - this is a remote
|
|
8
|
+
(Streamable HTTP) server. The npm/PyPI package below is an optional convenience client, not
|
|
9
|
+
the server.
|
|
10
|
+
|
|
11
|
+
## 1. Generate a token
|
|
12
|
+
|
|
13
|
+
The token *is* the account. Any sufficiently random secret works, and the first call
|
|
14
|
+
auto-provisions a free trial (1,000 credits).
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
TOKEN=sk_$(openssl rand -hex 32)
|
|
18
|
+
echo "$TOKEN" # save this - losing it means losing the account and its data
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 2. Register the server
|
|
22
|
+
|
|
23
|
+
**Claude Code** - one command:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
claude mcp add --scope user --transport http agent-utils-extensions https://mcp.agent-utils.ai/extensions \
|
|
27
|
+
--header "Authorization: Bearer $TOKEN"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Cline / Cursor / Windsurf** - add to the MCP settings JSON:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"mcpServers": {
|
|
35
|
+
"agent-utils-extensions": {
|
|
36
|
+
"url": "https://mcp.agent-utils.ai/extensions",
|
|
37
|
+
"headers": { "Authorization": "Bearer sk_REPLACE_WITH_YOUR_TOKEN" }
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 3. Verify before spending anything
|
|
44
|
+
|
|
45
|
+
`tools/list` needs **no authentication**, so reachability can be confirmed before the first
|
|
46
|
+
billed call:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
curl -s -X POST https://mcp.agent-utils.ai/extensions \
|
|
50
|
+
-H 'Content-Type: application/json' \
|
|
51
|
+
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Expect 66 tools: math and units (general, electrical, chemistry, thermodynamics), plus the 9 shared account tools
|
|
55
|
+
(`get_account`, `create_api_key`, `list_api_keys`, `revoke_api_key`, `list_payments`,
|
|
56
|
+
`settle_balance`, `submit_feature_request`, `submit_exit_feedback`).
|
|
57
|
+
|
|
58
|
+
## 4. Confirm the account
|
|
59
|
+
|
|
60
|
+
`get_account` is free - it creates the trial account and returns its state:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
curl -s -X POST https://mcp.agent-utils.ai/extensions \
|
|
64
|
+
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
|
|
65
|
+
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_account","arguments":{}}}'
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
A successful response means installation is complete.
|
|
69
|
+
|
|
70
|
+
## Optional: the client library
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install agent-utils-extensions
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
See `README.md` in this repo for the API.
|
|
77
|
+
|
|
78
|
+
## One token, both servers
|
|
79
|
+
|
|
80
|
+
agent_utils is two MCP servers: **swarm** (`https://mcp.agent-utils.ai/swarm` - memory, mutex,
|
|
81
|
+
task board, pub/sub, idempotency, webhook inbox) and **extensions**
|
|
82
|
+
(`https://mcp.agent-utils.ai/extensions` - math, units). The same token works on
|
|
83
|
+
both and draws from a single credit pool. To add the other one, repeat step 2 with
|
|
84
|
+
`agent-utils-swarm`, `https://mcp.agent-utils.ai/swarm`, and **the same token**.
|
|
85
|
+
|
|
86
|
+
## Cost
|
|
87
|
+
|
|
88
|
+
1 credit = $0.00001. Trial: 1,000 credits, no card. A one-time $5 activation raises the limit
|
|
89
|
+
to 500,000 credits for the whole account. `get_account`, `settle_balance`, and
|
|
90
|
+
`submit_exit_feedback` are free. Terms: <https://mcp.agent-utils.ai/legal.txt>.
|
|
91
|
+
|
|
92
|
+
## Troubleshooting
|
|
93
|
+
|
|
94
|
+
- **HTTP 401** - the `Authorization` header is missing or malformed. It must be exactly
|
|
95
|
+
`Bearer <token>`.
|
|
96
|
+
- **HTTP 403 "error code: 1010"** - Cloudflare rejected your HTTP client's default
|
|
97
|
+
User-Agent (Python's `urllib` is blocked). Send any descriptive `User-Agent` header.
|
|
98
|
+
- **No tools listed / 404** - you are probably POSTing to the wrong path. The endpoint is
|
|
99
|
+
`/extensions`, not the domain root or `/mcp`.
|
|
100
|
+
- **"Key already exists" on a write** - services distinguish create from update. Check the
|
|
101
|
+
tool description returned by `tools/list`; it names the right tool.
|
|
102
|
+
- **Authoritative reference** - the server's own spec is always current:
|
|
103
|
+
<https://mcp.agent-utils.ai/llms.txt>.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agent-utils-extensions"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Thin client for the agent_utils Extensions MCP server - exact math and unit conversion for AI agents. One account spans both agent_utils servers."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [{ name = "AI Cortex LLC", email = "support@agent-utils.ai" }]
|
|
13
|
+
keywords = ["mcp", "model-context-protocol", "ai-agents", "math", "unit-conversion", "claude", "agent-utils"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
19
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
20
|
+
]
|
|
21
|
+
dependencies = []
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://agent-utils.ai"
|
|
25
|
+
Repository = "https://github.com/agent-utils/agent-utils-extensions-py"
|
|
26
|
+
|
|
27
|
+
[tool.hatch.build.targets.wheel]
|
|
28
|
+
packages = ["src/agent_utils"]
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
"""Thin MCP-over-HTTP client for the hosted agent_utils Extensions server.
|
|
3
|
+
|
|
4
|
+
Extensions is the stateless half of agent_utils: exact math and unit
|
|
5
|
+
conversion (general, electrical, chemistry, thermodynamics), all on one endpoint.
|
|
6
|
+
|
|
7
|
+
This is a client, not the service - see https://agent-utils.ai.
|
|
8
|
+
Zero dependencies: standard library only.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import json
|
|
14
|
+
import urllib.error
|
|
15
|
+
import urllib.request
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
DEFAULT_ENDPOINT = "https://mcp.agent-utils.ai/extensions"
|
|
19
|
+
STAGING_ENDPOINT = "https://mcp-staging.agent-utils.ai/extensions"
|
|
20
|
+
USER_AGENT = "agent-utils-extensions-py/0.1.0"
|
|
21
|
+
|
|
22
|
+
__all__ = ["AgentUtilsExtensions", "DEFAULT_ENDPOINT", "STAGING_ENDPOINT"]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class AgentUtilsExtensions:
|
|
26
|
+
"""Client for the agent_utils Extensions MCP server.
|
|
27
|
+
|
|
28
|
+
The same token works on both agent_utils servers (swarm and extensions) and
|
|
29
|
+
draws from one credit pool. Any secret works as a token - the first call
|
|
30
|
+
auto-provisions a free trial. See https://agent-utils.ai.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def __init__(self, token: str, endpoint: str = DEFAULT_ENDPOINT) -> None:
|
|
34
|
+
self._token = token
|
|
35
|
+
self._endpoint = endpoint
|
|
36
|
+
self._id = 0
|
|
37
|
+
|
|
38
|
+
def call(self, name: str, arguments: dict[str, Any] | None = None) -> Any:
|
|
39
|
+
"""Call any MCP tool by name and return its result."""
|
|
40
|
+
self._id += 1
|
|
41
|
+
payload = json.dumps({"jsonrpc": "2.0", "id": self._id, "method": "tools/call",
|
|
42
|
+
"params": {"name": name, "arguments": arguments or {}}}).encode()
|
|
43
|
+
req = urllib.request.Request(self._endpoint, data=payload, method="POST",
|
|
44
|
+
headers={"Authorization": f"Bearer {self._token}",
|
|
45
|
+
"Content-Type": "application/json",
|
|
46
|
+
# Cloudflare rejects urllib's default User-Agent (error 1010).
|
|
47
|
+
"User-Agent": USER_AGENT})
|
|
48
|
+
try:
|
|
49
|
+
with urllib.request.urlopen(req) as resp:
|
|
50
|
+
body = json.loads(resp.read())
|
|
51
|
+
except urllib.error.HTTPError as exc: # pragma: no cover
|
|
52
|
+
raise RuntimeError(f"agent_utils HTTP {exc.code}: {exc.read().decode()}") from exc
|
|
53
|
+
if isinstance(body, dict) and body.get("error"):
|
|
54
|
+
raise RuntimeError(f"agent_utils: {body['error'].get('message', 'unknown error')}")
|
|
55
|
+
return body.get("result") if isinstance(body, dict) else body
|
|
56
|
+
|
|
57
|
+
def eval_expr(self, **kwargs: Any) -> Any:
|
|
58
|
+
return self.call("eval_expr", kwargs)
|
|
59
|
+
|
|
60
|
+
def convert(self, quantity: str, from_unit: str, to_unit: str, amount: float) -> Any:
|
|
61
|
+
"""Convert `amount` between units of `quantity` (e.g. "length", "electric_potential")."""
|
|
62
|
+
return self.call("convert_" + quantity, {"from": from_unit, "to": to_unit, "amount": amount})
|
|
63
|
+
|
|
64
|
+
# --- account (also on swarm) ---------------------------------------------
|
|
65
|
+
|
|
66
|
+
def get_account(self) -> Any:
|
|
67
|
+
return self.call("get_account", {})
|
|
68
|
+
|
|
69
|
+
def list_api_keys(self, **kwargs: Any) -> Any:
|
|
70
|
+
return self.call("list_api_keys", kwargs)
|
|
71
|
+
|
|
72
|
+
def create_api_key(self, **kwargs: Any) -> Any:
|
|
73
|
+
return self.call("create_api_key", kwargs)
|
|
74
|
+
|
|
75
|
+
def revoke_api_key(self, **kwargs: Any) -> Any:
|
|
76
|
+
return self.call("revoke_api_key", kwargs)
|
|
77
|
+
|
|
78
|
+
def list_payments(self, **kwargs: Any) -> Any:
|
|
79
|
+
return self.call("list_payments", kwargs)
|
|
80
|
+
|
|
81
|
+
def settle_balance(self, **kwargs: Any) -> Any:
|
|
82
|
+
return self.call("settle_balance", kwargs)
|
|
83
|
+
|
|
84
|
+
def submit_feature_request(self, **kwargs: Any) -> Any:
|
|
85
|
+
return self.call("submit_feature_request", kwargs)
|
|
86
|
+
|
|
87
|
+
def submit_exit_feedback(self, **kwargs: Any) -> Any:
|
|
88
|
+
return self.call("submit_exit_feedback", kwargs)
|
|
89
|
+
|
|
90
|
+
def delete_account(self, **kwargs: Any) -> Any:
|
|
91
|
+
return self.call("delete_account", kwargs)
|