Skip to main content

Python SDK for the OpenTool MCP server — manage tools, auth, and API keys programmatically.

Project description

opentool-sdk (Python)

Python SDK for the OpenTool MCP server. Manage tools, auth, and API keys programmatically.

Both sync and async clients included.

Install

pip install opentool-sdk

Quick Start (Sync)

from opentool import OpenTool

client = OpenTool(
    base_url="http://localhost:3001",
    api_key="ot_your_key_here",
)

# Check server health
health = client.health()

# List all available tools
tools = client.tools.list()

# List your connected tools
connected = client.tools.connected()

# Execute a tool
result = client.tools.execute("github.create_issue", {
    "owner": "user",
    "repo": "my-repo",
    "title": "Created via SDK",
    "body": "This issue was created programmatically.",
})

Quick Start (Async)

from opentool import AsyncOpenTool

async with AsyncOpenTool(
    base_url="http://localhost:3001",
    api_key="ot_your_key_here",
) as client:
    tools = await client.tools.connected()
    result = await client.tools.execute("slack.send_message", {
        "channel": "#general",
        "text": "Hello from the SDK",
    })

Auth

# Sign up (auto-sets API key on this client)
res = client.auth.signup(email="dev@example.com", password="my-password", name="Dev")
print(res.api_key)

# Login
res = client.auth.login(email="dev@example.com", password="my-password")

# Get OAuth URL for a provider
url = client.auth.get_connect_url("github")
# → User visits this URL to authorize

# Disconnect a provider
client.auth.disconnect("github")

API Keys

# List active keys
keys = client.keys.list()

# Create a new key (raw key returned once)
new_key = client.keys.create("CI pipeline")
print(new_key.key)

# Revoke a key
client.keys.revoke(key_id)

User Profile

# Get your profile
me = client.users.me()
print(me.email, me.connected_tools_count)

# Update profile
client.users.update_me(name="New Name")

Tools

# All tools in the registry
all_tools = client.tools.list()

# Tools you've connected
mine = client.tools.connected()

# Tools for a specific provider
github_tools = client.tools.by_provider("github")

# Execute a tool via MCP
result = client.tools.execute("slack.send_message", {
    "channel": "#general",
    "text": "Hello from the SDK",
})

Error Handling

from opentool import OpenTool, OpenToolError, AuthenticationError

try:
    client.tools.connected()
except AuthenticationError:
    print("API key is invalid or expired")
except OpenToolError as e:
    print(f"Error {e.status}: {e.body}")

Context Manager

# Sync
with OpenTool(base_url="http://localhost:3001", api_key="ot_xxx") as client:
    tools = client.tools.list()

# Async
async with AsyncOpenTool(base_url="http://localhost:3001", api_key="ot_xxx") as client:
    tools = await client.tools.list()

Configuration

client = OpenTool(
    base_url="http://localhost:3001",  # Required
    api_key="ot_xxx",                  # Optional — set later with client.set_api_key()
    timeout=30.0,                      # Request timeout in seconds (default: 30)
    http_client=custom_httpx_client,   # Custom httpx.Client instance
)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opentool_sdk-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opentool_sdk-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file opentool_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: opentool_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for opentool_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 49f33c5a27bb4e0885d3070369bf6c73f060db339f617bdbd344998685944797
MD5 5827c5734076d95a69dc5b2cf85bd715
BLAKE2b-256 fb3c0275e851b8652b2648a13669fa2f17053ebd2f5887bd1627a3ee6f979e01

See more details on using hashes here.

File details

Details for the file opentool_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: opentool_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for opentool_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92724b92e9bda7a330ffe69d2b1cbfc2b8c1b8d434eb661dffbf69a175a78f90
MD5 48f20e8bc25223b2454eb32f3fda337e
BLAKE2b-256 d703f8109be05b498d1796b3f596c901e12cc295dc3610dcf57a14d6180d6313

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page